[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Jul 2 21:33:01 MDT 2012


The branch, master has been updated
       via  3fe2c54 Fix the waf/autoconf builds to detect correctly the 32-bit or 64-bit syscall ABI on Linux.
       via  ec9aae6 Ensure we select the correct syscall numbers on a 32-bit Linux system.
      from  4b47e1b VERSION: Move on to beta4!

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 3fe2c54a5b122acc1d96c0e01d802b4f4a4c84b4
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jul 2 14:08:41 2012 -0700

    Fix the waf/autoconf builds to detect correctly the 32-bit or 64-bit syscall ABI on Linux.
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Jul  3 05:32:21 CEST 2012 on sn-devel-104

commit ec9aae6251e7d6d1a073924b6e58908454001625
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jul 2 10:22:10 2012 -0700

    Ensure we select the correct syscall numbers on a 32-bit Linux system.

-----------------------------------------------------------------------

Summary of changes:
 lib/util/setid.c     |   46 +++++++++++++++++++++++++
 source3/configure.in |   91 +++++++++++++++++++++++++++++++++++++++-----------
 source3/wscript      |   77 ++++++++++++++++++++++++++++++++++--------
 3 files changed, 180 insertions(+), 34 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/setid.c b/lib/util/setid.c
index 885b8bf..ed86155 100644
--- a/lib/util/setid.c
+++ b/lib/util/setid.c
@@ -109,13 +109,25 @@ int samba_setgroups(size_t setlen, const gid_t *gidset);
 #if defined(HAVE_SYS_SYSCALL_H)
 #include <sys/syscall.h>
 #endif
+
+/* Ensure we can't compile in a mixed syscall setup. */
+#if !defined(USE_LINUX_32BIT_SYSCALLS)
+#if defined(SYS_setresuid32) || defined(SYS_setresgid32) || defined(SYS_setreuid32) || defined(SYS_setregid32) || defined(SYS_setuid32) || defined(SYS_setgid32) || defined(SYS_setgroups32)
+#error Mixture of 32-bit Linux system calls and 64-bit calls.
+#endif
+#endif
+
 #endif
 
 /* All the setXX[ug]id functions and setgroups Samba uses. */
 int samba_setresuid(uid_t ruid, uid_t euid, uid_t suid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setresuid32, ruid, euid, suid);
+#else
 	return syscall(SYS_setresuid, ruid, euid, suid);
+#endif
 #elif defined(HAVE_SETRESUID)
 	return setresuid(ruid, euid, suid);
 #else
@@ -127,7 +139,11 @@ int samba_setresuid(uid_t ruid, uid_t euid, uid_t suid)
 int samba_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setresgid32, rgid, egid, sgid);
+#else
 	return syscall(SYS_setresgid, rgid, egid, sgid);
+#endif
 #elif defined(HAVE_SETRESGID)
 	return setresgid(rgid, egid, sgid);
 #else
@@ -139,7 +155,11 @@ int samba_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
 int samba_setreuid(uid_t ruid, uid_t euid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setreuid32, ruid, euid);
+#else
 	return syscall(SYS_setreuid, ruid, euid);
+#endif
 #elif defined(HAVE_SETREUID)
 	return setreuid(ruid, euid);
 #else
@@ -151,7 +171,11 @@ int samba_setreuid(uid_t ruid, uid_t euid)
 int samba_setregid(gid_t rgid, gid_t egid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setregid32, rgid, egid);
+#else
 	return syscall(SYS_setregid, rgid, egid);
+#endif
 #elif defined(HAVE_SETREGID)
 	return setregid(rgid, egid);
 #else
@@ -163,8 +187,13 @@ int samba_setregid(gid_t rgid, gid_t egid)
 int samba_seteuid(uid_t euid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	/* seteuid is not a separate system call. */
+	return syscall(SYS_setresuid32, -1, euid, -1);
+#else
 	/* seteuid is not a separate system call. */
 	return syscall(SYS_setresuid, -1, euid, -1);
+#endif
 #elif defined(HAVE_SETEUID)
 	return seteuid(euid);
 #else
@@ -176,8 +205,13 @@ int samba_seteuid(uid_t euid)
 int samba_setegid(gid_t egid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	/* setegid is not a separate system call. */
+	return syscall(SYS_setresgid32, -1, egid, -1);
+#else
 	/* setegid is not a separate system call. */
 	return syscall(SYS_setresgid, -1, egid, -1);
+#endif
 #elif defined(HAVE_SETEGID)
 	return setegid(egid);
 #else
@@ -189,7 +223,11 @@ int samba_setegid(gid_t egid)
 int samba_setuid(uid_t uid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setuid32, uid);
+#else
 	return syscall(SYS_setuid, uid);
+#endif
 #elif defined(HAVE_SETUID)
 	return setuid(uid);
 #else
@@ -201,7 +239,11 @@ int samba_setuid(uid_t uid)
 int samba_setgid(gid_t gid)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setgid32, gid);
+#else
 	return syscall(SYS_setgid, gid);
+#endif
 #elif defined(HAVE_SETGID)
 	return setgid(gid);
 #else
@@ -235,7 +277,11 @@ int samba_setgidx(int flags, gid_t gid)
 int samba_setgroups(size_t setlen, const gid_t *gidset)
 {
 #if defined(USE_LINUX_THREAD_CREDENTIALS)
+#if defined(USE_LINUX_32BIT_SYSCALLS)
+	return syscall(SYS_setgroups32, setlen, gidset);
+#else
 	return syscall(SYS_setgroups, setlen, gidset);
+#endif
 #elif defined(HAVE_SETGROUPS)
 	return setgroups(setlen, gidset);
 #else
diff --git a/source3/configure.in b/source3/configure.in
index 4def9cd..4379ce7 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -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,[
diff --git a/source3/wscript b/source3/wscript
index e372fcc..5fcf86e 100755
--- a/source3/wscript
+++ b/source3/wscript
@@ -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


-- 
Samba Shared Repository


More information about the samba-cvs mailing list