Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-23 Thread Tom Lane
Matthew Stickney writes: > The attached is a patch that uses the _fileno/_get_osfhandle approach. > This doesn't address the stdin fallback, or error handling if opening > termin fails; however, it should be no worse than what's there now, and > it fixes the immediate problem. LGTM; pushed wit

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-23 Thread Matthew Stickney
The attached is a patch that uses the _fileno/_get_osfhandle approach. This doesn't address the stdin fallback, or error handling if opening termin fails; however, it should be no worse than what's there now, and it fixes the immediate problem. I'm still thinking about the fallback in terms of

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-22 Thread Matthew Stickney
On Tue, May 22, 2018 at 6:14 PM, Tom Lane wrote: > Well, the question that ought to be answered first is whether to do > anything at all, beyond not-crashing. It doesn't seem to me that > refusing to accept a password if we can't disable echo is a net win, > so I'm inclined to think it's okay to

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-22 Thread Tom Lane
Matthew Stickney writes: > On Tue, May 22, 2018 at 4:09 PM, Tom Lane wrote: >> 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'

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-22 Thread Matthew Stickney
On Tue, May 22, 2018 at 4:09 PM, Tom Lane 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 (

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-22 Thread Tom Lane
[ please don't top-post ] Matthew Stickney writes: > On Tue, May 22, 2018 at 2:55 PM, Tom Lane wrote: >> Is it possible to operate on "termin" instead of doing a second open >> (which might fail, which we are failing to cope with :-()? > It is possible, at the cost of two extra function calls,

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-22 Thread Matthew Stickney
It is possible, at the cost of two extra function calls, which could theoretically fail (and require a little extra munging to work on Windows CE -- is that a target platform for postgres?). Similar to using CreateFile, I think the cases in which those calls could fail are so extraordinary that ps

Re: [PATCH] (Windows) psql echoes password when reading from pipe

2018-05-22 Thread Tom Lane
Matthew Stickney writes: > On windows, if you pipe data to psql, the password prompt correctly > reads from and writes to the console, but the password text is echoed to > the console. This is because echoing is disabled on the handle for > stdin, but as part of a pipeline stdin doesn't refer t

[PATCH] (Windows) psql echoes password when reading from pipe

2018-05-21 Thread Matthew Stickney
This is my first time submitting a patch here; apologies in advance if I flub the process. On windows, if you pipe data to psql, the password prompt correctly reads from and writes to the console, but the password text is echoed to the console. This is because echoing is disabled on the handle