Re: BUG #10347: Can't write password to psql or pg_dump

From: Noah Misch <noah(at)leadboat(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: derek_ealy(at)rapid7(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #10347: Can't write password to psql or pg_dump
Date: 2014-05-31 02:42:27
Message-ID: 20140531024227.GA248952@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, May 18, 2014 at 12:23:24PM +0200, Andres Freund wrote:
> On 2014-05-16 20:34:09 +0000, derek_ealy(at)rapid7(dot)com wrote:
> > On Windows systems the psql or pg_dump process always hangs after sending
> > the password to stdin of the process.
> >
> > I've gotten around this problem by setting an environment variable before
> > exec'ing the process. I set OSTYPES=msys. This forces psql to use stdin when
> > reading the password.
>
> I think the important point - and why I asked for a bugreport after
> talking about it on irc - is that sprompt.c on windows uses
> CONIN$/CONOUT$ for io. Ignoring stdin/stdout except when the OSTYPE is
> set to msys. Given that CONIN$/OUT seem to refer to the shell that
> started a processtree from a shell that doesn't seem to be optimal.

That code is trying to mimic the non-Windows behavior, which is to interact
with /dev/tty when available. Unfortunately, CONIN$/CONOUT$ are ~always
nominally available, but they may not route to anything visible to the user.
The OSTYPE test is a crude attempt to anticipate that problem.
IsWindowVisible(GetConsoleWindow()) looked more reliable, but it still didn't
cover everything:
http://www.postgresql.org/message-id/flat/20121010110555(dot)GA21405(at)tornado(dot)leadboat(dot)com

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2014-05-31 13:28:41 Re: uninterruptable loop: concurrent delete in progress within table
Previous Message Bruce Momjian 2014-05-30 21:25:26 Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts