mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Fix incorrect error message reported for non-existent users
Previously, lookups of non-existent user names could return "Success"; it will now return "User does not exist" by resetting errno. This also centralizes the user name lookup code in libpgport. Report and analysis by Nicolas Marchildon; patch by me
This commit is contained in:
@ -265,10 +265,13 @@ exec_command(const char *cmd,
|
||||
#ifndef WIN32
|
||||
struct passwd *pw;
|
||||
|
||||
errno = 0; /* clear errno before call */
|
||||
pw = getpwuid(geteuid());
|
||||
if (!pw)
|
||||
{
|
||||
psql_error("could not get home directory: %s\n", strerror(errno));
|
||||
psql_error("could not get home directory for user id %d: %s\n",
|
||||
(int) geteuid(), errno ?
|
||||
strerror(errno) : "user does not exist");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
dir = pw->pw_dir;
|
||||
|
Reference in New Issue
Block a user