fix initdb -U - Mailing list pgsql-patches
From | Andrew Dunstan |
---|---|
Subject | fix initdb -U |
Date | |
Msg-id | 43FDEED9.8090901@dunslane.net Whole thread Raw |
List | pgsql-patches |
the attached patch makes initdb -U username work as advertised. Barring objection I will apply it to head and backpatch to 8.0 and 8.1 branches. I guess nobody uses this much, or we'd surely have had reports of breakage long before now. cheers andrew Index: src/bin/initdb/initdb.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/initdb/initdb.c,v retrieving revision 1.110 diff -c -r1.110 initdb.c *** src/bin/initdb/initdb.c 18 Feb 2006 16:15:23 -0000 1.110 --- src/bin/initdb/initdb.c 23 Feb 2006 17:12:40 -0000 *************** *** 113,119 **** 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]; --- 113,118 ---- *************** *** 1385,1391 **** exit_nicely(); } ! bki_lines = replace_token(bki_lines, "POSTGRES", effective_user); bki_lines = replace_token(bki_lines, "ENCODING", encodingid); --- 1384,1390 ---- exit_nicely(); } ! bki_lines = replace_token(bki_lines, "POSTGRES", username); bki_lines = replace_token(bki_lines, "ENCODING", encodingid); *************** *** 1547,1553 **** PG_CMD_OPEN; PG_CMD_PRINTF2("ALTER USER \"%s\" WITH PASSWORD '%s';\n", ! effective_user, pwd1); PG_CMD_CLOSE; --- 1546,1552 ---- PG_CMD_OPEN; PG_CMD_PRINTF2("ALTER USER \"%s\" WITH PASSWORD '%s';\n", ! username, pwd1); PG_CMD_CLOSE; *************** *** 1866,1872 **** PG_CMD_OPEN; priv_lines = replace_token(privileges_setup, ! "$POSTGRES_SUPERUSERNAME", effective_user); for (line = priv_lines; *line != NULL; line++) PG_CMD_PUTS(*line); --- 1865,1871 ---- PG_CMD_OPEN; priv_lines = replace_token(privileges_setup, ! "$POSTGRES_SUPERUSERNAME", username); for (line = priv_lines; *line != NULL; line++) PG_CMD_PUTS(*line); *************** *** 2446,2451 **** --- 2445,2451 ---- ret; int option_index; char *short_version; + char *effective_user; char *pgdenv; /* PGDATA value gotten from and sent to * environment */ char bin_dir[MAXPGPATH]; *************** *** 2735,2744 **** exit(1); } ! if (strlen(username)) ! effective_user = username; ! else ! effective_user = get_id(); if (strlen(encoding)) encodingid = get_encoding_id(encoding); --- 2735,2744 ---- exit(1); } ! effective_user = get_id(); ! if (strlen(username) == 0) ! username = effective_user; ! if (strlen(encoding)) encodingid = get_encoding_id(encoding); *************** *** 2767,2773 **** "PG_HBA_SAMPLE=%s\nPG_IDENT_SAMPLE=%s\n", PG_VERSION, pg_data, share_path, bin_path, ! effective_user, bki_file, desc_file, shdesc_file, conf_file, hba_file, ident_file); --- 2767,2773 ---- "PG_HBA_SAMPLE=%s\nPG_IDENT_SAMPLE=%s\n", PG_VERSION, pg_data, share_path, bin_path, ! username, bki_file, desc_file, shdesc_file, conf_file, hba_file, ident_file);
pgsql-patches by date: