Re: [PATCHES] psql patch for displaying the username when asking password
Adrian Maier wrote: On 6/30/05, Peter Eisentraut [EMAIL PROTECTED] wrote: Am Donnerstag, 30. Juni 2005 09:34 schrieb Adrian Maier: The attached patch modifies the message displayed by psql when asking the password Password: to include the username as well: Password for user postgres : . I can't decode your attachment so I don't know if this is a typo or actually in the patch, but there shouldn't be a space after the user name. There was a space there. I've removed the space between username and colons.The space after the colons is ok, I hope ? I'm attaching the modified patch. I made this adjustment in the applied version. Thanks. -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [PATCHES] psql patch for displaying the username when asking password
Patch adjusted slightly, attached, and applied. Thanks. --- Adrian Maier wrote: On 6/30/05, Peter Eisentraut [EMAIL PROTECTED] wrote: Am Donnerstag, 30. Juni 2005 09:34 schrieb Adrian Maier: The attached patch modifies the message displayed by psql when asking the password Password: to include the username as well: Password for user postgres : . I can't decode your attachment so I don't know if this is a typo or actually in the patch, but there shouldn't be a space after the user name. There was a space there. I've removed the space between username and colons.The space after the colons is ok, I hope ? I'm attaching the modified patch. Cheers, Adrian Maier [ Attachment, skipping... ] ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 Index: src/bin/psql/command.c === RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.150 diff -c -c -r1.150 command.c *** src/bin/psql/command.c 18 Jul 2005 20:57:53 - 1.150 --- src/bin/psql/command.c 25 Jul 2005 17:13:42 - *** *** 911,916 --- 911,917 const char *dbparam = NULL; const char *userparam = NULL; const char *pwparam = NULL; + char *password_prompt = NULL; char *prompted_password = NULL; boolneed_pass; boolsuccess = false; *** *** 930,938 else userparam = new_user; /* need to prompt for password? */ if (pset.getPassword) ! pwparam = prompted_password = simple_prompt(Password: , 100, false); /* * Use old password (if any) if no new one given and we are --- 931,948 else userparam = new_user; + if (userparam == NULL) + password_prompt = strdup(Password: ); + else + { + password_prompt = malloc(strlen(Password for user %s: ) - 2 + + strlen(userparam) + 1); + sprintf(password_prompt,Password for user %s: , userparam); + } + /* need to prompt for password? */ if (pset.getPassword) ! pwparam = prompted_password = simple_prompt(password_prompt, 100, false); /* * Use old password (if any) if no new one given and we are *** *** 956,966 need_pass = true; free(prompted_password); prompted_password = NULL; ! pwparam = prompted_password = simple_prompt(Password: , 100, false); } } while (need_pass); free(prompted_password); /* * If connection failed, try at least keep the old one. That's --- 966,977 need_pass = true; free(prompted_password); prompted_password = NULL; ! pwparam = prompted_password = simple_prompt(password_prompt, 100, false); } } while (need_pass); free(prompted_password); + free(password_prompt); /* * If connection failed, try at least keep the old one. That's Index: src/bin/psql/startup.c === RCS file: /cvsroot/pgsql/src/bin/psql/startup.c,v retrieving revision 1.119 diff -c -c -r1.119 startup.c *** src/bin/psql/startup.c 14 Jul 2005 08:42:37 - 1.119 --- src/bin/psql/startup.c 25 Jul 2005 17:13:42 - *** *** 106,111 --- 106,112 char *username = NULL; char *password = NULL; + char *password_prompt = NULL; boolneed_pass; set_pglocale_pgservice(argv[0], psql); *** *** 188,195 username = pg_strdup(options.username); } if (pset.getPassword) ! password = simple_prompt(Password: , 100, false); /* loop until we have a password if requested by backend */ do --- 189,205 username = pg_strdup(options.username); } + if (options.username == NULL) + password_prompt = strdup(Password: ); + else + { + password_prompt = malloc(strlen(Password for user %s: ) - 2 + +
[PATCHES] psql patch for displaying the username when asking password
Hello all, The attached patch modifies the message displayed by psql when asking the password Password: to include the username as well: Password for user postgres : . Displaying the username is useful when running sql scripts which are setting the session authorization (like the dump scripts generated by older versions of pg_dump) and you don't have all the usernames/passwords in ~/.pgpass. In such cases it can happen that psql is asking several times : Password: Password: Password: Password: and you don't know whether it's asking the pasword of the 'postgres' user or the password of user that is importing the data . I have the feeling that asking for Password: several times no longer happens when running scripts generated by recent versions of pg_dump. However, the patch might be useful for people who are upgrading . Cheers, Adrian Maier *** ./src/bin/psql/command.c.orig 2005-06-30 09:06:41.953634513 +0300 --- ./src/bin/psql/command.c 2005-06-30 09:49:41.216208791 +0300 *** *** 912,917 --- 912,918 const char *dbparam = NULL; const char *userparam = NULL; const char *pwparam = NULL; + char *password_prompt = NULL; char *prompted_password = NULL; bool need_pass; bool success = false; *** *** 931,939 else userparam = new_user; /* need to prompt for password? */ if (pset.getPassword) ! pwparam = prompted_password = simple_prompt(Password: , 100, false); /* * Use old password (if any) if no new one given and we are --- 932,951 else userparam = new_user; + if (userparam == NULL) + { + password_prompt = malloc(strlen(Password: )+1); + sprintf(password_prompt,Password: ); + } + else + { + password_prompt = malloc(strlen(userparam)+30); + sprintf(password_prompt,Password for user %s : ,userparam); + } + /* need to prompt for password? */ if (pset.getPassword) ! pwparam = prompted_password = simple_prompt(password_prompt, 100, false); /* * Use old password (if any) if no new one given and we are *** *** 957,967 need_pass = true; free(prompted_password); prompted_password = NULL; ! pwparam = prompted_password = simple_prompt(Password: , 100, false); } } while (need_pass); free(prompted_password); /* * If connection failed, try at least keep the old one. That's --- 969,980 need_pass = true; free(prompted_password); prompted_password = NULL; ! pwparam = prompted_password = simple_prompt(password_prompt, 100, false); } } while (need_pass); free(prompted_password); + free(password_prompt); /* * If connection failed, try at least keep the old one. That's *** ./src/bin/psql/startup.c.orig 2005-06-30 09:06:34.816798114 +0300 --- ./src/bin/psql/startup.c 2005-06-30 09:22:50.487536877 +0300 *** *** 106,111 --- 106,112 char *username = NULL; char *password = NULL; + char *password_prompt = NULL; bool need_pass; set_pglocale_pgservice(argv[0], psql); *** *** 187,194 username = pg_strdup(options.username); } if (pset.getPassword) ! password = simple_prompt(Password: , 100, false); /* loop until we have a password if requested by backend */ do --- 188,206 username = pg_strdup(options.username); } + if (username == NULL) + { + password_prompt = malloc(strlen(Password: )+1); + strcat(password_prompt,Password: ); + } + else + { + password_prompt = malloc(strlen(username)+30); + sprintf(password_prompt,Password for user %s : ,username); + } + if (pset.getPassword) ! password = simple_prompt(password_prompt, 100, false); /* loop until we have a password if requested by backend */ do *** *** 206,217 need_pass = true; free(password); password = NULL; ! password = simple_prompt(Password: , 100, false); } } while (need_pass); free(username); free(password); if (PQstatus(pset.db) == CONNECTION_BAD) { --- 218,230 need_pass = true; free(password); password = NULL; ! password = simple_prompt(password_prompt, 100, false); } } while (need_pass); free(username); free(password); + free(password_prompt); if (PQstatus(pset.db) == CONNECTION_BAD) { ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [PATCHES] psql patch for displaying the username when asking password
Am Donnerstag, 30. Juni 2005 09:34 schrieb Adrian Maier: The attached patch modifies the message displayed by psql when asking the password Password: to include the username as well: Password for user postgres : . I can't decode your attachment so I don't know if this is a typo or actually in the patch, but there shouldn't be a space after the user name. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [PATCHES] psql patch for displaying the username when asking password
On 6/30/05, Peter Eisentraut [EMAIL PROTECTED] wrote: Am Donnerstag, 30. Juni 2005 09:34 schrieb Adrian Maier: The attached patch modifies the message displayed by psql when asking the password Password: to include the username as well: Password for user postgres : . I can't decode your attachment so I don't know if this is a typo or actually in the patch, but there shouldn't be a space after the user name. There was a space there. I've removed the space between username and colons.The space after the colons is ok, I hope ? I'm attaching the modified patch. Cheers, Adrian Maier psql_password_prompt_v2.diff.gz Description: GNU Zip compressed data ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings