|
39 | 39 | * Portions Copyright (c) 1994, Regents of the University of California |
40 | 40 | * Portions taken from FreeBSD. |
41 | 41 | * |
42 | | - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.41 2004/07/01 00:51:36 tgl Exp $ |
| 42 | + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.42 2004/07/12 01:54:10 momjian Exp $ |
43 | 43 | * |
44 | 44 | *------------------------------------------------------------------------- |
45 | 45 | */ |
@@ -1137,7 +1137,7 @@ get_set_pwd(void) |
1137 | 1137 | PG_CMD_OPEN; |
1138 | 1138 |
|
1139 | 1139 | if (fprintf(pg, |
1140 | | - "ALTER USER \"%s\" WITH PASSWORD '%s';\n", username, pwd1) < 0) |
| 1140 | + "ALTER USER \"%s\" WITH PASSWORD '%s';\n", effective_user, pwd1) < 0) |
1141 | 1141 | { |
1142 | 1142 | /* write failure */ |
1143 | 1143 | exit_nicely(); |
@@ -1433,7 +1433,7 @@ setup_privileges(void) |
1433 | 1433 | PG_CMD_OPEN; |
1434 | 1434 |
|
1435 | 1435 | priv_lines = replace_token(privileges_setup, |
1436 | | - "$POSTGRES_SUPERUSERNAME", username); |
| 1436 | + "$POSTGRES_SUPERUSERNAME", effective_user); |
1437 | 1437 | for (line = priv_lines; *line != NULL; line++) |
1438 | 1438 | PG_CMD_PUTLINE; |
1439 | 1439 |
|
@@ -2002,9 +2002,10 @@ main(int argc, char *argv[]) |
2002 | 2002 | exit(1); |
2003 | 2003 | } |
2004 | 2004 |
|
2005 | | - effective_user = get_id(); |
2006 | | - if (!strlen(username)) |
2007 | | - username = effective_user; |
| 2005 | + if (strlen(username)) |
| 2006 | + effective_user = username; |
| 2007 | + else |
| 2008 | + effective_user = get_id(); |
2008 | 2009 |
|
2009 | 2010 | if (strlen(encoding)) |
2010 | 2011 | encodingid = get_encoding_id(encoding); |
@@ -2033,7 +2034,7 @@ main(int argc, char *argv[]) |
2033 | 2034 | PG_VERSION, |
2034 | 2035 | pg_data, share_path, bin_path, |
2035 | 2036 | encoding, encodingid, |
2036 | | - username, bki_file, |
| 2037 | + effective_user, bki_file, |
2037 | 2038 | desc_file, conf_file, |
2038 | 2039 | hba_file, ident_file); |
2039 | 2040 | if (show_setting) |
|
0 commit comments