1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Sort out getpeereid() and peer auth handling on Windows

The getpeereid() uses have so far been protected by HAVE_UNIX_SOCKETS,
so they didn't ever care about Windows support.  But in anticipation
of Unix-domain socket support on Windows, that needs to be handled
differently.

Windows doesn't support getpeereid() at this time, so we use the
existing not-supported code path.  We let configure do its usual thing
of picking up the replacement from libpgport, instead of the custom
overrides that it was doing before.

But then Windows doesn't have struct passwd, so this patch sprinkles
some additional #ifdef WIN32 around to make it work.  This is similar
to existing code that deals with this issue.

Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/5974caea-1267-7708-40f2-6009a9d653b0@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2019-10-30 12:58:32 +01:00
parent 956ef58753
commit f14413b684
6 changed files with 36 additions and 42 deletions

36
configure vendored
View File

@ -15685,6 +15685,19 @@ esac
fi
ac_fn_c_check_func "$LINENO" "getpeereid" "ac_cv_func_getpeereid"
if test "x$ac_cv_func_getpeereid" = xyes; then :
$as_echo "#define HAVE_GETPEEREID 1" >>confdefs.h
else
case " $LIBOBJS " in
*" getpeereid.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS getpeereid.$ac_objext"
;;
esac
fi
ac_fn_c_check_func "$LINENO" "getrusage" "ac_cv_func_getrusage"
if test "x$ac_cv_func_getrusage" = xyes; then :
$as_echo "#define HAVE_GETRUSAGE 1" >>confdefs.h
@ -15863,19 +15876,13 @@ $as_echo "$as_me: On $host_os we will use our strtof wrapper." >&6;}
esac
case $host_os in
# Windows uses a specialised env handler
# and doesn't need a replacement getpeereid because it doesn't use
# Unix sockets.
mingw*)
$as_echo "#define HAVE_UNSETENV 1" >>confdefs.h
$as_echo "#define HAVE_GETPEEREID 1" >>confdefs.h
ac_cv_func_unsetenv=yes
ac_cv_func_getpeereid=yes;;
;;
*)
ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv"
if test "x$ac_cv_func_unsetenv" = xyes; then :
@ -15890,21 +15897,8 @@ esac
fi
ac_fn_c_check_func "$LINENO" "getpeereid" "ac_cv_func_getpeereid"
if test "x$ac_cv_func_getpeereid" = xyes; then :
$as_echo "#define HAVE_GETPEEREID 1" >>confdefs.h
else
case " $LIBOBJS " in
*" getpeereid.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS getpeereid.$ac_objext"
;;
esac
fi
;;
;;
esac
# System's version of getaddrinfo(), if any, may be used only if we found