s3: FreeBSD has getpeereid(), use it
authorVolker Lendecke <vl@samba.org>
Fri, 10 Dec 2010 22:02:19 +0000 (23:02 +0100)
committerVolker Lendecke <vlendec@samba.org>
Sun, 19 Dec 2010 22:25:06 +0000 (23:25 +0100)
source3/configure.in
source3/lib/system.c

index 5f81a193ca8ed5e0fb9f48bc5ce11d010ee3308f..b43d0b34de846545035b5df922c7e992a6257494 100644 (file)
@@ -6353,6 +6353,18 @@ if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
 fi
 
+AC_CACHE_CHECK([for getpeereid],samba_cv_HAVE_GETPEEREID,[
+AC_TRY_LINK([#include <sys/types.h>
+#include <unistd.h>],
+[uid_t uid; gid_t gid; int ret;
+ ret = getpeereid(0, &uid, &gid);
+],
+samba_cv_HAVE_GETPEEREID=yes,samba_cv_HAVE_GETPEEREID=no)])
+if test x"$samba_cv_HAVE_GETPEEREID" = xyes; then
+   AC_DEFINE(HAVE_GETPEEREID,1,
+            [Whether we have getpeereid to get socket credentials])
+fi
+
 
 #################################################
 # Check to see if we should use the included popt
index 1c00ad87e4de092268dafde831c82150de51b645..02322b72b51b56b7d0c9ca1c6f1c7be198ae1a22 100644 (file)
@@ -2630,6 +2630,10 @@ int sys_getpeereid( int s, uid_t *uid)
        *uid = cred.uid;
        return 0;
 #else
+#if defined(HAVE_GETPEEREID)
+       gid_t gid;
+       return getpeereid(s, uid, &gid);
+#endif
        errno = ENOSYS;
        return -1;
 #endif