diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/libpq/auth.c | 17 | ||||
-rw-r--r-- | src/include/port.h | 2 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 10 | ||||
-rw-r--r-- | src/tools/msvc/Mkvcbuild.pm | 2 |
4 files changed, 17 insertions, 14 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index c12b810c3d5..5399144c20c 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -77,9 +77,7 @@ static int ident_inet(hbaPort *port); * Peer authentication *---------------------------------------------------------------- */ -#ifdef HAVE_UNIX_SOCKETS static int auth_peer(hbaPort *port); -#endif /*---------------------------------------------------------------- @@ -559,11 +557,7 @@ ClientAuthentication(Port *port) break; case uaPeer: -#ifdef HAVE_UNIX_SOCKETS status = auth_peer(port); -#else - Assert(false); -#endif break; case uaIdent: @@ -1984,16 +1978,16 @@ ident_inet_done: * * Iff authorized, return STATUS_OK, otherwise return STATUS_ERROR. */ -#ifdef HAVE_UNIX_SOCKETS - static int auth_peer(hbaPort *port) { uid_t uid; gid_t gid; +#ifndef WIN32 struct passwd *pw; char *peer_user; int ret; +#endif if (getpeereid(port->sock, &uid, &gid) != 0) { @@ -2009,6 +2003,7 @@ auth_peer(hbaPort *port) return STATUS_ERROR; } +#ifndef WIN32 errno = 0; /* clear errno before call */ pw = getpwuid(uid); if (!pw) @@ -2030,8 +2025,12 @@ auth_peer(hbaPort *port) pfree(peer_user); return ret; +#else + /* should have failed with ENOSYS above */ + Assert(false); + return STATUS_ERROR; +#endif } -#endif /* HAVE_UNIX_SOCKETS */ /*---------------------------------------------------------------- diff --git a/src/include/port.h b/src/include/port.h index bfd2e2759f6..9567590581b 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -354,7 +354,7 @@ extern int fls(int mask); #define ftello(a) ftell(a) #endif -#if !defined(HAVE_GETPEEREID) && !defined(WIN32) +#ifndef HAVE_GETPEEREID extern int getpeereid(int sock, uid_t *uid, gid_t *gid); #endif diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 66a91286056..3ca7e0560cd 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -2733,8 +2733,6 @@ keep_going: /* We will come back to here until there is char *startpacket; int packetlen; -#ifdef HAVE_UNIX_SOCKETS - /* * Implement requirepeer check, if requested and it's a * Unix-domain socket. @@ -2742,10 +2740,12 @@ keep_going: /* We will come back to here until there is if (conn->requirepeer && conn->requirepeer[0] && IS_AF_UNIX(conn->raddr.addr.ss_family)) { +#ifndef WIN32 char pwdbuf[BUFSIZ]; struct passwd pass_buf; struct passwd *pass; int passerr; +#endif uid_t uid; gid_t gid; @@ -2766,6 +2766,7 @@ keep_going: /* We will come back to here until there is goto error_return; } +#ifndef WIN32 passerr = pqGetpwuid(uid, &pass_buf, pwdbuf, sizeof(pwdbuf), &pass); if (pass == NULL) { @@ -2788,8 +2789,11 @@ keep_going: /* We will come back to here until there is conn->requirepeer, pass->pw_name); goto error_return; } +#else /* WIN32 */ + /* should have failed with ENOSYS above */ + Assert(false); +#endif /* WIN32 */ } -#endif /* HAVE_UNIX_SOCKETS */ if (IS_AF_UNIX(conn->raddr.addr.ss_family)) { diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 275f3bb6991..3d6ef0de84b 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -94,7 +94,7 @@ sub mkvcbuild $solution = CreateSolution($vsVersion, $config); our @pgportfiles = qw( - chklocale.c explicit_bzero.c fls.c fseeko.c getrusage.c inet_aton.c random.c + chklocale.c explicit_bzero.c fls.c fseeko.c getpeereid.c getrusage.c inet_aton.c random.c srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c dirent.c dlopen.c getopt.c getopt_long.c |