Skip to content

Commit 66d56a8

Browse files
committed
Fix username mismatch in initdb. Magnus.
1 parent a919fdf commit 66d56a8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/bin/initdb/initdb.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Portions Copyright (c) 1994, Regents of the University of California
4040
* Portions taken from FreeBSD.
4141
*
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 $
4343
*
4444
*-------------------------------------------------------------------------
4545
*/
@@ -1137,7 +1137,7 @@ get_set_pwd(void)
11371137
PG_CMD_OPEN;
11381138

11391139
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)
11411141
{
11421142
/* write failure */
11431143
exit_nicely();
@@ -1433,7 +1433,7 @@ setup_privileges(void)
14331433
PG_CMD_OPEN;
14341434

14351435
priv_lines = replace_token(privileges_setup,
1436-
"$POSTGRES_SUPERUSERNAME", username);
1436+
"$POSTGRES_SUPERUSERNAME", effective_user);
14371437
for (line = priv_lines; *line != NULL; line++)
14381438
PG_CMD_PUTLINE;
14391439

@@ -2002,9 +2002,10 @@ main(int argc, char *argv[])
20022002
exit(1);
20032003
}
20042004

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();
20082009

20092010
if (strlen(encoding))
20102011
encodingid = get_encoding_id(encoding);
@@ -2033,7 +2034,7 @@ main(int argc, char *argv[])
20332034
PG_VERSION,
20342035
pg_data, share_path, bin_path,
20352036
encoding, encodingid,
2036-
username, bki_file,
2037+
effective_user, bki_file,
20372038
desc_file, conf_file,
20382039
hba_file, ident_file);
20392040
if (show_setting)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy