pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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 14:55:54 -0400
Message-ID: <14853.1527015354@sss.pgh.pa.us> (raw)
In-Reply-To: <502a1fff-862b-da52-1031-f68df6ed5a2d@gmail.com>
References: <502a1fff-862b-da52-1031-f68df6ed5a2d@gmail.com>

Matthew Stickney <mtstickney@gmail.com> 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 to the console. 
> I've attached a patch that gets a handle to the console's input buffer 
> by opening CONIN$ instead, which corrects the problem.

Thanks for the report and patch!

I know zip about Windows coding, but I can't help comparing this:

-		t = GetStdHandle(STD_INPUT_HANDLE);
+		t = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);

to the code a little bit above:

	termin = fopen("CONIN$", "r");

Is it possible to operate on "termin" instead of doing a second open
(which might fail, which we are failing to cope with :-()?

			regards, tom lane




view thread (9+ messages)  latest in thread

Message-ID: <14853.1527015354@sss.pgh.pa.us>
Permalink:  ../14853.1527015354@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14853.1527015354@sss.pgh.pa.us

 · 

reply

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: <14853.1527015354@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