- Notifications
You must be signed in to change notification settings - Fork28
Commit15be274
committed
Avoid misleading psql password prompt when username is multiply specified.
When a password is needed, cases such aspsql -d "postgresql://alice@localhost/testdb" -U bobwould incorrectly prompt for "Password for user bob: ", when actually theconnection will be attempted with username alice. The priority order ofwhich name to use isn't that important here, but the misleading prompt is.When we are prompting for a password after initial connection failure,we can fix this reliably by looking at PQuser(conn) to see how libpqinterpreted the connection arguments. But when we're doing a forcedpassword prompt because of a -W switch, we can't use that solution.Fortunately, because the main use of -W is for noninteractive situations,it's less critical to produce a helpful prompt in such cases. I madethe startup prompt for -W just say "Password: " all the time, ratherthan expending extra code on trying to identify which username to use.In the case of a \c command (after -W has been given), there's alreadylogic in do_connect that determines whether the "dbname" is a connstringor URI, so we can avoid lobotomizing the prompt except in cases thatare actually dubious. (We could do similarly in startup.c if anyonecomplains, but for now it seems not worthwhile, especially since thatwould still be only a partial solution.)Per bug #15025 from Akos Vandra. Although this is arguably a bug fix,it doesn't seem worth back-patching. The case where it matters seemslike a very corner-case usage, and someone might complain that we'dchanged the behavior of -W in a minor release.Discussion:https://postgr.es/m/20180123130013.7407.24749@wrigleys.postgresql.org1 parent35a5280 commit15be274
2 files changed
+35
-13
lines changedLines changed: 14 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2829 | 2829 |
| |
2830 | 2830 |
| |
2831 | 2831 |
| |
2832 |
| - | |
| 2832 | + | |
2833 | 2833 |
| |
2834 | 2834 |
| |
2835 | 2835 |
| |
| |||
2960 | 2960 |
| |
2961 | 2961 |
| |
2962 | 2962 |
| |
2963 |
| - | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
2964 | 2971 |
| |
2965 | 2972 |
| |
2966 | 2973 |
| |
| |||
3026 | 3033 |
| |
3027 | 3034 |
| |
3028 | 3035 |
| |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
3029 | 3041 |
| |
3030 |
| - | |
3031 | 3042 |
| |
3032 | 3043 |
| |
3033 | 3044 |
| |
|
Lines changed: 21 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
104 |
| - | |
105 | 104 |
| |
106 | 105 |
| |
107 | 106 |
| |
| |||
205 | 204 |
| |
206 | 205 |
| |
207 | 206 |
| |
208 |
| - | |
209 |
| - | |
210 |
| - | |
211 |
| - | |
212 |
| - | |
213 |
| - | |
214 | 207 |
| |
215 | 208 |
| |
216 |
| - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
217 | 215 |
| |
218 | 216 |
| |
219 | 217 |
| |
| |||
252 | 250 |
| |
253 | 251 |
| |
254 | 252 |
| |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
255 | 266 |
| |
| 267 | + | |
256 | 268 |
| |
| 269 | + | |
257 | 270 |
| |
258 | 271 |
| |
259 | 272 |
| |
260 | 273 |
| |
261 | 274 |
| |
262 |
| - | |
263 |
| - | |
264 | 275 |
| |
265 | 276 |
| |
266 | 277 |
| |
|
0 commit comments
Comments
(0)