#include <arpa/inet.h>
#include <unistd.h>
-#include "common/username.h"
#include "libpq/auth.h"
#include "libpq/crypt.h"
#include "libpq/ip.h"
char ident_user[IDENT_USERNAME_MAX + 1];
uid_t uid;
gid_t gid;
- const char *user_name;
- char *errstr;
+ struct passwd *pass;
errno = 0;
if (getpeereid(port->sock, &uid, &gid) != 0)
return STATUS_ERROR;
}
- user_name = get_user_name(&errstr);
- if (!user_name)
+ pass = getpwuid(uid);
+
+ if (pass == NULL)
{
- ereport(LOG, (errmsg_internal("%s", errstr)));
- pfree(errstr);
+ ereport(LOG,
+ (errmsg("local user with ID %d does not exist",
+ (int) uid)));
return STATUS_ERROR;
}
- strlcpy(ident_user, user_name, IDENT_USERNAME_MAX + 1);
+ strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
return check_usermap(port->hba->usermap, port->user_name, ident_user, false);
}
static char username[256 + 1];
DWORD len = sizeof(username) - 1;
+ *errstr = NULL;
+
if (!GetUserName(username, &len))
{
*errstr = psprintf(_("user name lookup failure: %s"), strerror(errno));