Re: [PATCH] (Windows) psql echoes password when reading from pipe
Matthew Stickney <mtstickney@gmail.com>
From: Matthew Stickney <mtstickney@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2018-05-22T20:56:40Z
Lists: pgsql-hackers
On Tue, May 22, 2018 at 4:09 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > [ please don't top-post ] Sorry, I'm used to using a better mail client than this. > Hm. The failure mode I was thinking about was insufficient resources > to allocate another handle You have a point here; CreateFile does create a new handle (as would DuplicateHandle), while _fileno and _get_osfhandle just retrieve the existing file descriptor and handle, respectively. I checked the docs more carefully, and both calls should never fail unless the input stream is invalid. > But perhaps it's worth adding logic to deal with failure of the call? I think it would be sufficient to check whether the SetConsoleMode call fails, because that can fail even on a valid handle (e.g. if you don't have a handle with write access). That would catch the case where opening termin fails, too, although that might deserve it's own check to get better error information. simple_prompt seems to be used in a lot of different utilities for different reasons; there seem to be a number of conventions for reporting errors in src/port/ code, but it looks like other interactive utilities generally print a message to stderr, and return a basic success/failure value. Does that sound like the right approach? I'm not sure if it's obvious how to handle errors in the other utilities, but I can take a look. -Matt Stickney
Commits
-
Fix simple_prompt() to disable echo on Windows when stdin != terminal.
- bed74e9d4959 10.5 landed
- bbaf75ee0c3a 9.6.10 landed
- 50485b3e201d 11.0 landed
- 3466b0202cd6 9.3.24 landed
- 09fb2d5d3b8f 9.4.19 landed
- 085791b8aace 9.5.14 landed