summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-connect.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-31 02:43:14 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-31 02:43:14 +0000
commit3405f2b92532cb9559aed1316b3df2262aaadaef (patch)
tree7bc8067b5b80cef7ef751871efc07eef34ce91d2 /src/interfaces/libpq/fe-connect.c
parentc5f11f9d19964b8dc568bc4b9bfff7d31ee26db0 (diff)
downloadpostgresql-3405f2b92532cb9559aed1316b3df2262aaadaef.tar.gz
Use error message wordings for permissions checks on .pgpass and SSL private
key files that are similar to the one for the postmaster's data directory permissions check. (I chose to standardize on that one since it's the most heavily used and presumably best-wordsmithed by now.) Also eliminate explicit tests on file ownership in these places, since the ensuing read attempt must fail anyway if it's wrong, and there seems no value in issuing the same error message for distinct problems. (But I left in the explicit ownership test in postmaster.c, since it had its own error message anyway.) Also be more specific in the documentation's descriptions of these checks. Per a gripe from Kevin Hunter.
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r--src/interfaces/libpq/fe-connect.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 90f9d4334e..dd6c988790 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.356 2008/01/29 02:06:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.357 2008/03/31 02:43:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3718,11 +3718,10 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
}
/* If password file cannot be opened, ignore it. */
- if (stat(pgpassfile, &stat_buf) == -1)
+ if (stat(pgpassfile, &stat_buf) != 0)
return NULL;
#ifndef WIN32
-
if (!S_ISREG(stat_buf.st_mode))
{
fprintf(stderr,
@@ -3735,7 +3734,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
{
fprintf(stderr,
- libpq_gettext("WARNING: password file \"%s\" has world or group read access; permission should be u=rw (0600)\n"),
+ libpq_gettext("WARNING: password file \"%s\" has group or world access; permissions should be u=rw (0600) or less\n"),
pgpassfile);
return NULL;
}