Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLCS0-0003H2-Ir for pgsql-hackers@arkaria.postgresql.org; Tue, 22 May 2018 18:56:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fLCRz-00069I-EP for pgsql-hackers@arkaria.postgresql.org; Tue, 22 May 2018 18:55:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLCRz-000649-3q for pgsql-hackers@lists.postgresql.org; Tue, 22 May 2018 18:55:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLCRw-0001Sx-HF for pgsql-hackers@lists.postgresql.org; Tue, 22 May 2018 18:55:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w4MItsMS014854; Tue, 22 May 2018 14:55:54 -0400 From: Tom Lane To: Matthew Stickney cc: pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] (Windows) psql echoes password when reading from pipe In-reply-to: <502a1fff-862b-da52-1031-f68df6ed5a2d@gmail.com> References: <502a1fff-862b-da52-1031-f68df6ed5a2d@gmail.com> Comments: In-reply-to Matthew Stickney message dated "Tue, 22 May 2018 00:27:48 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14852.1527015354.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 22 May 2018 14:55:54 -0400 Message-ID: <14853.1527015354@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 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 =3D GetStdHandle(STD_INPUT_HANDLE); + t =3D CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_REA= D | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); to the code a little bit above: termin =3D 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