Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1Rf1-0004s1-9a for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Aug 2019 08:44:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i1Rez-0002Tv-NQ for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Aug 2019 08:44:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1Rez-0002To-CG for pgsql-bugs@lists.postgresql.org; Sat, 24 Aug 2019 08:44:33 +0000 Received: from georg.so ([89.238.75.224]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i1Res-0000bc-CY for pgsql-bugs@lists.postgresql.org; Sat, 24 Aug 2019 08:44:32 +0000 Received: from dell12.lru.li (unknown [IPv6:2001:1a80:303a:0:faca:b8ff:fe50:d072]) (Authenticated sender: georg) by georg.so (Postfix) with ESMTPSA id F1BFE4AE85A; Sat, 24 Aug 2019 10:44:21 +0200 (CEST) Received: by dell12.lru.li (Postfix, from userid 1000) id D7A643088CE; Sat, 24 Aug 2019 10:44:20 +0200 (CEST) Date: Sat, 24 Aug 2019 10:44:20 +0200 From: Georg Sauthoff To: Arthur Zakirov Cc: rhpatrick@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15961: psql should be able to read password from stdin Message-ID: <20190824084420.GA6873@dell12.lru.li> References: <15961-a17e673003b92f17@postgresql.org> <174993ee-33da-4b5a-8568-7575b7f9e9dc@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <174993ee-33da-4b5a-8568-7575b7f9e9dc@postgrespro.ru> User-Agent: Mutt/1.12.0 (2019-05-25) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Aug 19, 2019 at 12:40:05PM +0300, Arthur Zakirov wrote: > On 16.08.2019 17:20, PG Bug reporting form wrote: > > My use case is that I am writing terraform scripts to standup Sonarqube in > > AWS. After creating the AWS RDS PostgreSQL database, I need to be able to > > create the sonarqube user and grant access to the sonarqube database that > > was created with the RDS instance. I can work around this using the > > PGPASSWORD environment variable but that seems to be deprecated. I don't > > want to use the .pgpass solution since I don't want/need the postgres user's > > credentials in my EC2 instance where the Sonarqube server will be running... > Is PGPASSWORD really deprecated? The documentation just says that it is not > recommended to use it for security reasons, and it doesn't say that the > variable is deprecated: > https://www.postgresql.org/docs/current/libpq-envars.html PGPASSWORD isn't deprecated. The documentation states that 'is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps'. IOW, it's only not recommended if one plans to use Postgres on such systems. The only example for such an operating system I know is the ancient Solaris 9. That means under Solaris 9 a non-root user is able to read the environment variables of processes owned by other users. The also ancient Solaris 10 fixed that. Under Linux, the environment of a processed is only readable for the process-owning user and root. The PGPASSWORD handling in psql can be even made more secure under Linux: https://www.postgresql.org/message-id/15930-1a5562cad4a72900%40postgresql.org > I guess passing a password by command-line might have similar security > problems. If it suits you then PGPASSWORD should work for you too. Under Linux, passing the password on the command line is definitely more insecure because the argument vector of a process is world-readable. Best regards Georg