diff options
author | Bruce Momjian <bruce@momjian.us> | 2013-12-18 12:16:16 -0500 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2013-12-18 12:16:21 -0500 |
commit | 613c6d26bd42dd8c2dd0664315be9551475b8864 (patch) | |
tree | e0eb178bf76220fc9b082d9e849bee67c03f9e13 /src/bin/scripts/common.c | |
parent | 11ac4c73cb89551d7e0d0180b58d82186f072f8d (diff) | |
download | postgresql-613c6d26bd42dd8c2dd0664315be9551475b8864.tar.gz postgresql-613c6d26bd42dd8c2dd0664315be9551475b8864.zip |
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
Diffstat (limited to 'src/bin/scripts/common.c')
-rw-r--r-- | src/bin/scripts/common.c | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index 4645bc137f9..e57e5207c6b 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -14,7 +14,6 @@ #include "postgres_fe.h" -#include <pwd.h> #include <signal.h> #include <unistd.h> @@ -30,38 +29,6 @@ static CRITICAL_SECTION cancelConnLock; #endif /* - * Returns the current user name. - */ -const char * -get_user_name(const char *progname) -{ -#ifndef WIN32 - struct passwd *pw; - - pw = getpwuid(geteuid()); - if (!pw) - { - fprintf(stderr, _("%s: could not obtain information about current user: %s\n"), - progname, strerror(errno)); - exit(1); - } - return pw->pw_name; -#else - static char username[128]; /* remains after function exit */ - DWORD len = sizeof(username) - 1; - - if (!GetUserName(username, &len)) - { - fprintf(stderr, _("%s: could not get current user name: %s\n"), - progname, strerror(errno)); - exit(1); - } - return username; -#endif -} - - -/* * Provide strictly harmonized handling of --help and --version * options. */ |