aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/user.c6
-rw-r--r--src/backend/libpq/crypt.c37
-rw-r--r--src/backend/libpq/hba.c22
-rw-r--r--src/backend/libpq/password.c7
4 files changed, 34 insertions, 38 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 2164c516f9b..25150818a72 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.66 2000/08/03 16:34:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.67 2000/08/27 21:50:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,7 +72,7 @@ write_password_file(Relation rel)
fp = AllocateFile(tempname, "w");
umask(oumask);
if (fp == NULL)
- elog(ERROR, "%s: %m", tempname);
+ elog(ERROR, "write_password_file: unable to write %s: %m", tempname);
/* read table */
scan = heap_beginscan(rel, false, SnapshotSelf, 0, NULL);
@@ -156,7 +156,7 @@ write_password_file(Relation rel)
filename = crypt_getpwdreloadfilename();
flagfd = BasicOpenFile(filename, O_WRONLY | O_CREAT, 0600);
if (flagfd < 0)
- elog(NOTICE, "%s: %m", filename);
+ elog(NOTICE, "write_password_file: unable to write %s: %m", filename);
else
close(flagfd);
pfree((void *) filename);
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index 6cc9abb90ea..0145951418a 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -9,11 +9,12 @@
* Dec 17, 1997 - Todd A. Brandys
* Orignal Version Completed.
*
- * $Id: crypt.c,v 1.28 2000/07/12 22:58:59 petere Exp $
+ * $Id: crypt.c,v 1.29 2000/08/27 21:50:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
+#include <errno.h>
#include <unistd.h>
#include "postgres.h"
@@ -32,11 +33,10 @@ int pwd_cache_count = 0;
/*-------------------------------------------------------------------------*/
char *
-crypt_getpwdfilename()
+crypt_getpwdfilename(void)
{
-
- static char *pfnam = NULL;
int bufsize;
+ char *pfnam;
bufsize = strlen(DataDir) + 8 + strlen(CRYPT_PWD_FILE) + 1;
pfnam = (char *) palloc(bufsize);
@@ -48,12 +48,11 @@ crypt_getpwdfilename()
/*-------------------------------------------------------------------------*/
char *
-crypt_getpwdreloadfilename()
+crypt_getpwdreloadfilename(void)
{
-
- static char *rpfnam = NULL;
char *pwdfilename;
int bufsize;
+ char *rpfnam;
pwdfilename = crypt_getpwdfilename();
bufsize = strlen(pwdfilename) + strlen(CRYPT_PWD_RELOAD_SUFX) + 1;
@@ -65,9 +64,8 @@ crypt_getpwdreloadfilename()
/*-------------------------------------------------------------------------*/
-static
-FILE *
-crypt_openpwdfile()
+static FILE *
+crypt_openpwdfile(void)
{
char *filename;
FILE *pwdfile;
@@ -75,13 +73,16 @@ crypt_openpwdfile()
filename = crypt_getpwdfilename();
pwdfile = AllocateFile(filename, PG_BINARY_R);
+ if (pwdfile == NULL)
+ fprintf(stderr, "Couldn't read %s: %s\n",
+ filename, strerror(errno));
+
return pwdfile;
}
/*-------------------------------------------------------------------------*/
-static
-int
+static int
compar_user(const void *user_a, const void *user_b)
{
@@ -115,9 +116,8 @@ compar_user(const void *user_a, const void *user_b)
/*-------------------------------------------------------------------------*/
-static
-void
-crypt_loadpwdfile()
+static void
+crypt_loadpwdfile(void)
{
char *filename;
@@ -176,8 +176,7 @@ crypt_loadpwdfile()
/*-------------------------------------------------------------------------*/
-static
-void
+static void
crypt_parsepwdentry(char *buffer, char **pwd, char **valdate)
{
@@ -212,11 +211,9 @@ crypt_parsepwdentry(char *buffer, char **pwd, char **valdate)
/*-------------------------------------------------------------------------*/
-static
-int
+static int
crypt_getloginfo(const char *user, char **passwd, char **valuntil)
{
-
char *pwd,
*valdate;
void *fakeout;
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index dca3cf4fc3c..5dbf7d61db9 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -5,7 +5,7 @@
* wherein you authenticate a user by seeing what IP address the system
* says he comes from and possibly using ident).
*
- * $Id: hba.c,v 1.53 2000/07/08 03:04:39 tgl Exp $
+ * $Id: hba.c,v 1.54 2000/08/27 21:50:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -427,10 +427,8 @@ find_hba_entry(hbaPort *port, bool *hba_ok_p)
/* The open of the config file failed. */
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "find_hba_entry: Host-based authentication config file "
- "does not exist or permissions are not setup correctly! "
- "Unable to open file \"%s\".\n",
- conf_file);
+ "find_hba_entry: Unable to open authentication config file \"%s\": %s\n",
+ conf_file, strerror(errno));
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
}
@@ -812,16 +810,13 @@ verify_against_usermap(const char *pguser,
{
/* The open of the map file failed. */
- *checks_out_p = false;
-
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "verify_against_usermap: usermap file for Ident-based "
- "authentication "
- "does not exist or permissions are not setup correctly! "
- "Unable to open file \"%s\".\n",
- map_file);
+ "verify_against_usermap: Unable to open usermap file \"%s\": %s\n",
+ map_file, strerror(errno));
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);
+
+ *checks_out_p = false;
}
else
{
@@ -981,7 +976,10 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
snprintf(map_file, bufsize, "%s/%s", DataDir, CHARSET_FILE);
file = AllocateFile(map_file, PG_BINARY_R);
if (file == NULL)
+ {
+ /* XXX should we log a complaint? */
return;
+ }
while (!eof)
{
c = getc(file);
diff --git a/src/backend/libpq/password.c b/src/backend/libpq/password.c
index d34ca4cdf42..1eede3799ab 100644
--- a/src/backend/libpq/password.c
+++ b/src/backend/libpq/password.c
@@ -2,10 +2,11 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: password.c,v 1.31 2000/07/08 03:04:40 tgl Exp $
+ * $Id: password.c,v 1.32 2000/08/27 21:50:18 tgl Exp $
*
*/
+#include <errno.h>
#include <unistd.h>
#include "postgres.h"
@@ -36,8 +37,8 @@ verify_password(const Port *port, const char *user, const char *password)
if (!pw_file)
{
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "verify_password: couldn't open password file '%s'\n",
- pw_file_fullname);
+ "verify_password: Unable to open password file \"%s\": %s\n",
+ pw_file_fullname, strerror(errno));
fputs(PQerrormsg, stderr);
pqdebug("%s", PQerrormsg);