From: Andrew Dunstan Date: Fri, 24 Feb 2006 00:55:27 +0000 (+0000) Subject: make initdb -U username work as advertised; back out bogus patch at rev 1.42 X-Git-Tag: REL8_1_4~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=400606f3a8314ae586f3bca1da2d3aaf1d2c38d7;p=postgresql make initdb -U username work as advertised; back out bogus patch at rev 1.42 and supply real fix for problem it tried to address. --- diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 6d27546d32..c8ab77a2e7 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.99.2.1 2005/11/22 18:23:26 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.99.2.2 2006/02/24 00:55:27 adunstan Exp $ * *------------------------------------------------------------------------- */ @@ -107,7 +107,6 @@ static char *conversion_file; static char *info_schema_file; static char *features_file; static char *system_views_file; -static char *effective_user; static bool made_new_pgdata = false; static bool found_existing_pgdata = false; static char infoversion[100]; @@ -1323,7 +1322,7 @@ bootstrap_template1(char *short_version) exit_nicely(); } - bki_lines = replace_token(bki_lines, "POSTGRES", effective_user); + bki_lines = replace_token(bki_lines, "POSTGRES", username); bki_lines = replace_token(bki_lines, "ENCODING", encodingid); @@ -1485,7 +1484,7 @@ get_set_pwd(void) PG_CMD_OPEN; PG_CMD_PRINTF2("ALTER USER \"%s\" WITH PASSWORD '%s';\n", - effective_user, pwd1); + username, pwd1); PG_CMD_CLOSE; @@ -1767,7 +1766,7 @@ setup_privileges(void) PG_CMD_OPEN; priv_lines = replace_token(privileges_setup, - "$POSTGRES_SUPERUSERNAME", effective_user); + "$POSTGRES_SUPERUSERNAME", username); for (line = priv_lines; *line != NULL; line++) PG_CMD_PUTS(*line); @@ -2205,6 +2204,7 @@ main(int argc, char *argv[]) ret; int option_index; char *short_version; + char *effective_user; char *pgdenv; /* PGDATA value gotten from and sent to * environment */ char bin_dir[MAXPGPATH]; @@ -2451,10 +2451,10 @@ main(int argc, char *argv[]) exit(1); } - if (strlen(username)) - effective_user = username; - else - effective_user = get_id(); + effective_user = get_id(); + if (strlen(username) == 0) + username = effective_user; + if (strlen(encoding)) encodingid = get_encoding_id(encoding); @@ -2481,7 +2481,7 @@ main(int argc, char *argv[]) "PG_HBA_SAMPLE=%s\nPG_IDENT_SAMPLE=%s\n", PG_VERSION, pg_data, share_path, bin_path, - effective_user, bki_file, + username, bki_file, desc_file, conf_file, hba_file, ident_file); if (show_setting)