From 613c6d26bd42dd8c2dd0664315be9551475b8864 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 18 Dec 2013 12:16:16 -0500 Subject: 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 --- src/bin/scripts/common.c | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'src/bin/scripts/common.c') 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 #include #include @@ -29,38 +28,6 @@ static PGcancel *volatile cancelConn = NULL; 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. -- cgit v1.2.3