From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matthew Stickney <mtstickney@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] (Windows) psql echoes password when reading from pipe
Date: Tue, 22 May 2018 18:14:13 -0400
Message-ID: <23826.1527027253@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKH_Ld4j51U+k9_MHoA=HCx5=PP5i=6US7Lyum-2xXxAPZFG5A@mail.gmail.com>
References: <502a1fff-862b-da52-1031-f68df6ed5a2d@gmail.com>
<14853.1527015354@sss.pgh.pa.us>
<CAKH_Ld7A=3dFAvUFN1hFq-67=Ronx3Aq-muDhFKh4iHu3MMk6Q@mail.gmail.com>
<18079.1527019746@sss.pgh.pa.us>
<CAKH_Ld4j51U+k9_MHoA=HCx5=PP5i=6US7Lyum-2xXxAPZFG5A@mail.gmail.com>
Matthew Stickney <mtstickney@gmail.com> writes:
> On Tue, May 22, 2018 at 4:09 PM, Tom Lane <tgl@sss.pgh.pa.us> 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'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.
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 silently ignore failure to
turn off echo.
The other aspect of this code that maybe needs consideration is the
silent fallback to use stdin/stderr if we can't open the console.
It seems like that could be a really bad idea if stdin is a pipe.
But on the other hand, maybe somebody is depending on it somewhere?
I'm not sure I'd want to back-patch a change in that behavior, anyway.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, mtstickney@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] (Windows) psql echoes password when reading from pipe
In-Reply-To: <23826.1527027253@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox