pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #10347: Can't write password to psql or pg_dump
5+ messages / 5 participants
[nested] [flat]

* BUG #10347: Can't write password to psql or pg_dump
@ 2014-05-16 20:34 derek_ealy@rapid7.com
  2014-05-18 10:15 ` Re: BUG #10347: Can't write password to psql or pg_dump hubert depesz lubaczewski <depesz@depesz.com>
  2014-05-18 10:23 ` Re: BUG #10347: Can't write password to psql or pg_dump Andres Freund <andres@2ndquadrant.com>
  0 siblings, 2 replies; 5+ messages in thread

From: derek_ealy@rapid7.com @ 2014-05-16 20:34 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      10347
Logged by:          Derek Ealy
Email address:      derek_ealy@rapid7.com
PostgreSQL version: 9.3.4
Operating system:   Windows
Description:        

When exec'ing a command to pg_dump or psql from Java there is no "normal"
way to send the password to the psql process.

On Linux systems it works as expected because I write the password to the
input stream of the process running psql.

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.

It's not a documented feature, but I found it in the source code. I think
there should be a documented way of telling psql and pg_dump to pull the
password from stdin.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #10347: Can't write password to psql or pg_dump
  2014-05-16 20:34 BUG #10347: Can't write password to psql or pg_dump derek_ealy@rapid7.com
@ 2014-05-18 10:15 ` hubert depesz lubaczewski <depesz@depesz.com>
  1 sibling, 0 replies; 5+ messages in thread

From: hubert depesz lubaczewski @ 2014-05-18 10:15 UTC (permalink / raw)
  To: derek_ealy@rapid7.com; +Cc: pgsql-bugs

On Fri, May 16, 2014 at 08:34:09PM +0000, derek_ealy@rapid7.com wrote:
> When exec'ing a command to pg_dump or psql from Java there is no "normal"
> way to send the password to the psql process.
> 
> On Linux systems it works as expected because I write the password to the
> input stream of the process running psql.

Normal way of providing password is either to use PGPASSWORD environment
variable, as shown here:
http://www.postgresql.org/docs/current/interactive/libpq-envars.html
or pgpass file, as shown here:
http://www.postgresql.org/docs/current/interactive/libpq-pgpass.html

depesz

Attachments:

  signature.asc (application/pgp-signature, 800B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #10347: Can't write password to psql or pg_dump
  2014-05-16 20:34 BUG #10347: Can't write password to psql or pg_dump derek_ealy@rapid7.com
@ 2014-05-18 10:23 ` Andres Freund <andres@2ndquadrant.com>
  2014-05-18 14:41   ` Re: BUG #10347: Can't write password to psql or pg_dump Tom Lane <tgl@sss.pgh.pa.us>
  2014-05-31 02:42   ` Re: BUG #10347: Can't write password to psql or pg_dump Noah Misch <noah@leadboat.com>
  1 sibling, 2 replies; 5+ messages in thread

From: Andres Freund @ 2014-05-18 10:23 UTC (permalink / raw)
  To: derek_ealy@rapid7.com; +Cc: pgsql-bugs

Hi,

On 2014-05-16 20:34:09 +0000, derek_ealy@rapid7.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 said, I am not a big fan of relying on sending the passwort to
stdin...

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #10347: Can't write password to psql or pg_dump
  2014-05-16 20:34 BUG #10347: Can't write password to psql or pg_dump derek_ealy@rapid7.com
  2014-05-18 10:23 ` Re: BUG #10347: Can't write password to psql or pg_dump Andres Freund <andres@2ndquadrant.com>
@ 2014-05-18 14:41   ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2014-05-18 14:41 UTC (permalink / raw)
  To: Andres Freund <andres@2ndquadrant.com>; +Cc: derek_ealy@rapid7.com; pgsql-bugs

Andres Freund <andres@2ndquadrant.com> writes:
> 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.

I have some recollection we changed to that after determining that the
alternatives were worse.  [ Checks git logs ]  You should investigate the
discussion leading up to commit 1068771abfeec148a9c1ce4782785bddc1982070
before proposing any change here.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #10347: Can't write password to psql or pg_dump
  2014-05-16 20:34 BUG #10347: Can't write password to psql or pg_dump derek_ealy@rapid7.com
  2014-05-18 10:23 ` Re: BUG #10347: Can't write password to psql or pg_dump Andres Freund <andres@2ndquadrant.com>
@ 2014-05-31 02:42   ` Noah Misch <noah@leadboat.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Noah Misch @ 2014-05-31 02:42 UTC (permalink / raw)
  To: Andres Freund <andres@2ndquadrant.com>; +Cc: derek_ealy@rapid7.com; 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@rapid7.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.GA21405@tornado.leadboat.com

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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2014-05-31 02:42 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-05-16 20:34 BUG #10347: Can't write password to psql or pg_dump derek_ealy@rapid7.com
2014-05-18 10:15 ` hubert depesz lubaczewski <depesz@depesz.com>
2014-05-18 10:23 ` Andres Freund <andres@2ndquadrant.com>
2014-05-18 14:41   ` Tom Lane <tgl@sss.pgh.pa.us>
2014-05-31 02:42   ` Noah Misch <noah@leadboat.com>

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