1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Fix up the PQconnectionUsedPassword mess: create a separate

PQconnectionNeedsPassword function that tells the right thing for whether to
prompt for a password, and improve PQconnectionUsedPassword so that it checks
whether the password used by the connection was actually supplied as a
connection argument, instead of coming from environment or a password file.
Per bug report from Mark Cave-Ayland and subsequent discussion.
This commit is contained in:
Tom Lane
2007-12-09 19:01:40 +00:00
parent cb1ab30fdc
commit 4f9bf7fc5a
13 changed files with 102 additions and 41 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.247 2007/11/28 15:42:31 petere Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.248 2007/12/09 19:01:40 tgl Exp $ -->
<chapter id="libpq">
<title><application>libpq</application> - C Library</title>
@ -1145,12 +1145,33 @@ typedef struct
</listitem>
</varlistentry>
<varlistentry>
<term><function>PQconnectionNeedsPassword</function><indexterm><primary>PQconnectionNeedsPassword</></></term>
<listitem>
<para>
Returns true (1) if the connection authentication method
required a password, but none was available.
Returns false (0) if not.
<synopsis>
int PQconnectionNeedsPassword(const PGconn *conn);
</synopsis>
</para>
<para>
This function can be applied after a failed connection attempt
to decide whether to prompt the user for a password.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>PQconnectionUsedPassword</function><indexterm><primary>PQconnectionUsedPassword</></></term>
<listitem>
<para>
Returns true (1) if the connection authentication method
required a password to be supplied. Returns false (0) if not.
used a caller-supplied password. Returns false (0) if not.
<synopsis>
int PQconnectionUsedPassword(const PGconn *conn);
@ -1159,9 +1180,10 @@ typedef struct
</para>
<para>
This function can be applied after either successful or failed
connection attempts. In the case of failure, it can for example
be used to decide whether to prompt the user for a password.
This function detects whether a password supplied to the connection
function was actually used. Passwords obtained from other
sources (such as the <filename>.pgpass</> file) are not considered
caller-supplied.
</para>
</listitem>
</varlistentry>

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.563 2007/12/08 17:24:03 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.564 2007/12/09 19:01:40 tgl Exp $ -->
<!--
Typical markup:
@ -2184,8 +2184,9 @@ current_date &lt; 2017-11-17
<listitem>
<para>
Add <function>PQconnectionUsedPassword()</function> that returns
true if the server required a password (Joe Conway)
Add <function>PQconnectionNeedsPassword()</function> that returns
true if the server required a password but none was supplied
(Joe Conway, Tom)
</para>
<para>
@ -2197,6 +2198,19 @@ current_date &lt; 2017-11-17
</para>
</listitem>
<listitem>
<para>
Add <function>PQconnectionUsedPassword()</function> that returns
true if the supplied password was actually used
(Joe Conway, Tom)
</para>
<para>
This is useful in some security contexts where it is important
to know whether a user-supplied password is actually valid.
</para>
</listitem>
</itemizedlist>
</sect3>