Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDD3O-00031f-Oz for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Sep 2020 20:38:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDD3M-0001m1-JO for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Sep 2020 20:38:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDD3M-0001lu-Bq for pgsql-bugs@lists.postgresql.org; Tue, 01 Sep 2020 20:38:52 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDD3J-0001Um-JV for pgsql-bugs@lists.postgresql.org; Tue, 01 Sep 2020 20:38:51 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1kDD3G-0003S7-At; Tue, 01 Sep 2020 16:38:46 -0400 Date: Tue, 1 Sep 2020 16:38:46 -0400 From: Bruce Momjian To: Tom Lane Cc: "David G. Johnston" , exclusion@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #16486: Prompted password is ignored when password specified in connection string Message-ID: <20200901203846.GA13613@momjian.us> References: <16486-b9c93d71c02c4907@postgresql.org> <2090524.1591652199@sss.pgh.pa.us> <2110959.1591655226@sss.pgh.pa.us> <2142411.1591667958@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="6zdv2QT/q3FMhpsV" Content-Disposition: inline In-Reply-To: <2142411.1591667958@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --6zdv2QT/q3FMhpsV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 8, 2020 at 09:59:18PM -0400, Tom Lane wrote: > I wrote: > > Hmm ... I had thought that the docs explained -W in more or less the same > > way I did above, but I see that (at least on the psql page) things are > > indeed pretty vague. I'll see about improving that. > > Concretely, it looks like we need edits as attached for psql, and > likewise for all our other programs with similar options. > > The thing that was really missing here IMO is the specification that a > conninfo string overrides other command-line parameters. It's somewhat > debatable whether a -W prompt is a "command line parameter", but it > acts that way for this purpose. In any case, I'm disinclined to document > that specific interaction, because it would amount to blessing a pretty > damfool practice, which is to make your password visible on the program's > command line. (I wonder whether section 33.1.2 ought to specifically > caution against putting passwords into command-line conninfo strings.) I used a later version of Tom's patch to add documentation of how connection strings can override command-line options, plus it has the password description improvements. I would like to apply this to all supported versions. -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --6zdv2QT/q3FMhpsV Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="passwd.diff" diff --git a/doc/src/sgml/ref/clusterdb.sgml b/doc/src/sgml/ref/clusterdb.sgml index 177856ca74..3049c915bb 100644 --- a/doc/src/sgml/ref/clusterdb.sgml +++ b/doc/src/sgml/ref/clusterdb.sgml @@ -95,7 +95,9 @@ PostgreSQL documentation ) is not used, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is - used. + used. Connction strings + can also be used for connection specifications, and these can + override other command-line options. diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index aa0b27c9f3..19c7d098b9 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -653,8 +653,9 @@ PostgreSQL documentation - Specifies parameters used to connect to the server, as a connection - string. See for more information. + Specifies parameters used to connect to the server, as a connction strings; these + can override other command-line options. The option is called --dbname for consistency with other diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0b2e2de87b..f4b209af83 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1130,14 +1130,10 @@ PostgreSQL documentation Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option - argument on the command line. - - - If this parameter contains an = sign or starts - with a valid URI prefix - (postgresql:// - or postgres://), it is treated as a - conninfo string. See for more information. + argument on the command line. Connction strings can also be + used for connection specifications, and these can override other + command-line options. diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml index 43abc530a0..e7868091b9 100644 --- a/doc/src/sgml/ref/pg_dumpall.sgml +++ b/doc/src/sgml/ref/pg_dumpall.sgml @@ -550,8 +550,9 @@ PostgreSQL documentation - Specifies parameters used to connect to the server, as a connection - string. See for more information. + Specifies parameters used to connect to the server, as a connction strings; these + can override other command-line options. The option is called --dbname for consistency with other diff --git a/doc/src/sgml/ref/pg_isready.sgml b/doc/src/sgml/ref/pg_isready.sgml index 3d5b551b87..63ef1d785a 100644 --- a/doc/src/sgml/ref/pg_isready.sgml +++ b/doc/src/sgml/ref/pg_isready.sgml @@ -47,15 +47,10 @@ PostgreSQL documentation - Specifies the name of the database to connect to. - - - If this parameter contains an = sign or starts - with a valid URI prefix - (postgresql:// - or postgres://), it is treated as a - conninfo string. See for more information. + Specifies the name of the database to connect to. Connction strings can also be + used for connection specifications, and these can override other + command-line options. diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml index 865ec84262..76d2ba48fa 100644 --- a/doc/src/sgml/ref/pg_receivewal.sgml +++ b/doc/src/sgml/ref/pg_receivewal.sgml @@ -252,8 +252,9 @@ PostgreSQL documentation - Specifies parameters used to connect to the server, as a connection - string. See for more information. + Specifies parameters used to connect to the server, as a connction strings; these + can override other command-line options. The option is called --dbname for consistency with other diff --git a/doc/src/sgml/ref/pg_recvlogical.sgml b/doc/src/sgml/ref/pg_recvlogical.sgml index 41508fdc1e..a9651b0921 100644 --- a/doc/src/sgml/ref/pg_recvlogical.sgml +++ b/doc/src/sgml/ref/pg_recvlogical.sgml @@ -277,10 +277,11 @@ PostgreSQL documentation - The database to connect to. See the description of the actions for - what this means in detail. This can be a libpq connection string; - see for more information. Defaults - to user name. + The database to connect to. See the description + of the actions for what this means in detail. Connction strings can also + be used for connection specifications, and these can override + other command-line options. Defaults to the user name. diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index 27eab2f02a..a4f2ee9f43 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -156,7 +156,9 @@ PostgreSQL documentation Connect to database dbname and restore directly - into the database. + into the database. Connction + strings can also be used for connection specifications, + and these can override other command-line options. diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 201946990f..b9a0ab245a 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -168,15 +168,10 @@ EOF Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option - argument on the command line. - - - If this parameter contains an = sign or starts - with a valid URI prefix - (postgresql:// - or postgres://), it is treated as a - conninfo string. See for more information. + argument on the command line. Connction strings can also be + used for connection specifications, and these can override other + command-line options. @@ -498,7 +493,7 @@ EOF Never issue a password prompt. If the server requires password - authentication and a password is not available by other means + authentication and a password is not available from other sources such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. @@ -518,13 +513,15 @@ EOF Force psql to prompt for a - password before connecting to a database. + password before connecting to a database, even if the password will + not be used. - This option is never essential, since psql - will automatically prompt for a password if the server demands - password authentication. However, psql + If the server requires password authentication and a password is not + available from other sources such as a .pgpass + file, psql will prompt for a + password in any case. However, psql will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing to avoid the extra connection attempt. diff --git a/doc/src/sgml/ref/reindexdb.sgml b/doc/src/sgml/ref/reindexdb.sgml index 026fd018d9..f8e27d82c2 100644 --- a/doc/src/sgml/ref/reindexdb.sgml +++ b/doc/src/sgml/ref/reindexdb.sgml @@ -139,7 +139,9 @@ PostgreSQL documentation ) is not used, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is - used. + used. Connction strings + can also be used for connection specifications, and these can + override other command-line options. diff --git a/doc/src/sgml/ref/vacuumdb.sgml b/doc/src/sgml/ref/vacuumdb.sgml index 95d6894cb0..04975656bb 100644 --- a/doc/src/sgml/ref/vacuumdb.sgml +++ b/doc/src/sgml/ref/vacuumdb.sgml @@ -97,7 +97,9 @@ PostgreSQL documentation ) is not used, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is - used. + used. Connction strings + can also be used for connection specifications, and these can + override other command-line options. --6zdv2QT/q3FMhpsV--