aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2014-03-28 12:50:11 -0400
committerBruce Momjian <bruce@momjian.us>2014-03-28 12:50:15 -0400
commite1827012ed4119150e29c3afcf462d3353f3a405 (patch)
treef8beec5da93ade62887138546e1d1e54aeb32590
parenta87c729153e372f3731689a7be007bc2b53f1410 (diff)
downloadpostgresql-e1827012ed4119150e29c3afcf462d3353f3a405.tar.gz
postgresql-e1827012ed4119150e29c3afcf462d3353f3a405.zip
Adjust getpwuid() fix commit to display errno string on failure
This adjusts patch 613c6d26bd42dd8c2dd0664315be9551475b8864.
-rw-r--r--src/backend/libpq/auth.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index a2f1c96b8bc..31ade0bdbe4 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -1559,9 +1559,8 @@ auth_peer(hbaPort *port)
char ident_user[IDENT_USERNAME_MAX + 1];
uid_t uid;
gid_t gid;
- struct passwd *pass;
+ struct passwd *pw;
- errno = 0;
if (getpeereid(port->sock, &uid, &gid) != 0)
{
/* Provide special error message if getpeereid is a stub */
@@ -1576,17 +1575,17 @@ auth_peer(hbaPort *port)
return STATUS_ERROR;
}
- pass = getpwuid(uid);
-
- if (pass == NULL)
+ errno = 0; /* clear errno before call */
+ pw = getpwuid(uid);
+ if (!pw)
{
ereport(LOG,
- (errmsg("local user with ID %d does not exist",
- (int) uid)));
+ (errmsg("failed to look up local user id %ld: %s",
+ (long) uid, errno ? strerror(errno) : _("user does not exist"))));
return STATUS_ERROR;
}
- strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
+ strlcpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
return check_usermap(port->hba->usermap, port->user_name, ident_user, false);
}