Fix the waf/autoconf builds to detect correctly the 32-bit or 64-bit syscall ABI...
authorJeremy Allison <jra@samba.org>
Mon, 2 Jul 2012 21:08:41 +0000 (14:08 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 3 Jul 2012 03:32:21 +0000 (05:32 +0200)
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jul  3 05:32:21 CEST 2012 on sn-devel-104

source3/configure.in
source3/wscript

index 4def9cd80aecde456f81a41780bcfc9fa8eb7031..4379ce7eb1e75c223d8b2dbb7e0fdbfc72dd05ba 100644 (file)
@@ -2766,26 +2766,77 @@ AC_CHECK_FUNCS(getpagesize)
 # look for a method of setting the effective uid
 seteuid=no;
 
-#
-# Disable for now until Linux-64 and Linux-32 specific versions
-# are separated out.
-#
-#case "$host_os" in
-#*linux*)
-#if test $seteuid = no; then
-#AC_CACHE_CHECK([for Linux thread-specific credentials],samba_cv_USE_LINUX_THREAD_CREDENTIALS,[
-#AC_TRY_RUN([
-##define AUTOCONF_TEST 1
-##define USE_LINUX_THREAD_CREDENTIALS 1
-##include "${srcdir-.}/../lib/util/setid.c"
-##include "${srcdir-.}/lib/util_sec.c"],
-#           samba_cv_USE_LINUX_THREAD_CREDENTIALS=yes,samba_cv_USE_LINUX_THREAD_CREDENTIALS=no,samba_cv_USE_LINUX_THREAD_CREDENTIALS=cross)])
-#if test x"$samba_cv_USE_LINUX_THREAD_CREDENTIALS" = x"yes"; then
-#    seteuid=yes;AC_DEFINE(USE_LINUX_THREAD_CREDENTIALS,1,[Whether we can use Linux thread-specific credentials])
-#fi
-#fi
-#;;
-#esac
+################################################
+# Start by checking for 32-bit system call definitions on Linux.
+
+case "$host_os" in
+*linux*)
+AC_CACHE_CHECK([for Linux 32-bit system calls],samba_cv_USE_LINUX_32BIT_SYSCALLS,[
+AC_TRY_COMPILE([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+
+#ifdef HAVE_SYS_PRIV_H
+#include <sys/priv.h>
+#endif
+#ifdef HAVE_SYS_ID_H
+#include <sys/id.h>
+#endif
+
+#if defined(HAVE_SYSCALL_H)
+#include <syscall.h>
+#endif
+
+#if defined(HAVE_SYS_SYSCALL_H)
+#include <sys/syscall.h>
+#endif
+],
+[
+syscall(SYS_setresuid32, -1, -1, -1);
+syscall(SYS_setresgid32, -1, -1, -1);
+syscall(SYS_setreuid32, -1, -1);
+syscall(SYS_setregid32, -1, -1);
+syscall(SYS_setuid32, -1);
+syscall(SYS_setgid32, -1);
+syscall(SYS_setgroups32, 0, NULL);
+], samba_cv_USE_LINUX_32BIT_SYSCALLS=yes,samba_cv_USE_LINUX_32BIT_SYSCALLS=no,samba_cv_USE_LINUX_32BIT_SYSCALLS=cross)])
+
+if test x"$samba_cv_USE_LINUX_32BIT_SYSCALLS" = x"yes"; then
+    AC_DEFINE(USE_LINUX_32BIT_SYSCALLS,1,[Use Linux 32-bit system calls])
+    AC_CACHE_CHECK([for Linux thread-specific credentials with 32-bit system calls],samba_cv_USE_LINUX_THREAD_CREDENTIALS,[
+    AC_TRY_RUN([
+#define AUTOCONF_TEST 1
+#define USE_LINUX_THREAD_CREDENTIALS 1
+#define USE_LINUX_32BIT_SYSCALLS 1
+#include "${srcdir-.}/../lib/util/setid.c"
+#include "${srcdir-.}/lib/util_sec.c"],
+           samba_cv_USE_LINUX_THREAD_CREDENTIALS=yes,samba_cv_USE_LINUX_THREAD_CREDENTIALS=no,samba_cv_USE_LINUX_THREAD_CREDENTIALS=cross)])
+if test x"$samba_cv_USE_LINUX_THREAD_CREDENTIALS" = x"yes"; then
+    seteuid=yes;
+    AC_DEFINE(USE_LINUX_THREAD_CREDENTIALS,1,[Whether we can use Linux thread-specific credentials with 32-bit system calls])
+fi
+fi
+
+if test $seteuid = no; then
+AC_CACHE_CHECK([for Linux thread-specific credentials],samba_cv_USE_LINUX_THREAD_CREDENTIALS,[
+AC_TRY_RUN([
+#define AUTOCONF_TEST 1
+#define USE_LINUX_THREAD_CREDENTIALS 1
+#include "${srcdir-.}/../lib/util/setid.c"
+#include "${srcdir-.}/lib/util_sec.c"],
+           samba_cv_USE_LINUX_THREAD_CREDENTIALS=yes,samba_cv_USE_LINUX_THREAD_CREDENTIALS=no,samba_cv_USE_LINUX_THREAD_CREDENTIALS=cross)])
+if test x"$samba_cv_USE_LINUX_THREAD_CREDENTIALS" = x"yes"; then
+    seteuid=yes;AC_DEFINE(USE_LINUX_THREAD_CREDENTIALS,1,[Whether we can use Linux thread-specific credentials])
+fi
+fi
+
+;;
+esac
 
 if test $seteuid = no; then
 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
index e372fcc5ae43cd7a0278722f7d627b45b16c4b97..5fcf86ea187b7f598ea15ed71e37cae211dab029 100755 (executable)
@@ -728,22 +728,71 @@ int i; i = PAM_RADIO_TYPE;
             conf.DEFINE('WITH_PAM', 1)
             conf.DEFINE('WITH_PAM_MODULES', 1)
 
-    seteuid = False
 #
-# Disable for now until Linux-64 and Linux-32 specific versions
-# are separated out.
+# Ensure we select the correct set of system calls on Linux.
 #
-#    if not seteuid:
-#        seteuid = conf.CHECK_CODE('''
-#                                #define AUTOCONF_TEST 1
-#                                #define USE_LINUX_THREAD_CREDENTIALS 1
-#                                #include "../lib/util/setid.c"
-#                                #include "./lib/util_sec.c"
-#                                ''',
-#                                'USE_LINUX_THREAD_CREDENTIALS',
-#                                addmain=False,
-#                                execute=True,
-#                                msg="Checking whether we can use Linux thread-specific credentials")
+    if (host_os.rfind('linux') > -1):
+        conf.CHECK_CODE('''
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+
+#ifdef HAVE_SYS_PRIV_H
+#include <sys/priv.h>
+#endif
+#ifdef HAVE_SYS_ID_H
+#include <sys/id.h>
+#endif
+
+#if defined(HAVE_SYSCALL_H)
+#include <syscall.h>
+#endif
+
+#if defined(HAVE_SYS_SYSCALL_H)
+#include <sys/syscall.h>
+#endif
+
+syscall(SYS_setresuid32, -1, -1, -1);
+syscall(SYS_setresgid32, -1, -1, -1);
+syscall(SYS_setreuid32, -1, -1);
+syscall(SYS_setregid32, -1, -1);
+syscall(SYS_setuid32, -1);
+syscall(SYS_setgid32, -1);
+syscall(SYS_setgroups32, 0, NULL);
+''',
+            'USE_LINUX_32BIT_SYSCALLS',
+            msg="Checking whether Linux should use 32-bit credential calls");
+
+    seteuid = False
+
+    if not seteuid:
+       if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
+               seteuid = conf.CHECK_CODE('''
+                                #define AUTOCONF_TEST 1
+                                #define USE_LINUX_THREAD_CREDENTIALS 1
+                                #define USE_LINUX_32BIT_SYSCALLS 1
+                                #include "../lib/util/setid.c"
+                                #include "./lib/util_sec.c"
+                                ''',
+                                'USE_LINUX_THREAD_CREDENTIALS',
+                                addmain=False,
+                                execute=True,
+                                msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
+       else:
+               seteuid = conf.CHECK_CODE('''
+                                #define AUTOCONF_TEST 1
+                                #define USE_LINUX_THREAD_CREDENTIALS 1
+                                #include "../lib/util/setid.c"
+                                #include "./lib/util_sec.c"
+                                ''',
+                                'USE_LINUX_THREAD_CREDENTIALS',
+                                addmain=False,
+                                execute=True,
+                                msg="Checking whether we can use Linux thread-specific credentials")
     if not seteuid:
         seteuid = conf.CHECK_CODE('''
                                 #define AUTOCONF_TEST 1