[SCM] UID Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Oct 28 09:26:09 UTC 2015


The branch, master has been updated
       via  f0a2720 tests: Rename test_syscall_gid32 to test_syscall_setgroups32
       via  9d6423c tests: Move syscall setregid32 test to own executable
       via  7927d70 tests: Move syscall setregid32 test to own executable
       via  1a90764 tests: Move syscall setgid32 test to own executable
       via  5ebd9cd tests: Rename syscall setresuid32 test and improve it
       via  b9c3fc4 tests: Move syscall setreuid32 test to own executable
       via  78cc57f tests: Move syscall setuid32 test to own executable
       via  218e642 uwrap: Fix build warning with release build
       via  c273d99 Ignore build and all obj* directories
      from  82ff081 cmake: Run threaded tests also on BSD and Solaris

https://git.samba.org/?p=uid_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f0a2720817d5d340ebda554939d303c282359be1
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 09:34:18 2015 +0100

    tests: Rename test_syscall_gid32 to test_syscall_setgroups32
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9d6423cc1e33e5444b8e459e515ca889799656e5
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 09:33:16 2015 +0100

    tests: Move syscall setregid32 test to own executable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 7927d700b632377d23649c0a325d00047631f345
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 09:23:23 2015 +0100

    tests: Move syscall setregid32 test to own executable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1a90764f7effea83b54f3e85bfdf2579ef796218
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 08:36:53 2015 +0100

    tests: Move syscall setgid32 test to own executable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5ebd9cd421eda784ecf095e945860631ebbb1a33
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 08:26:32 2015 +0100

    tests: Rename syscall setresuid32 test and improve it
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit b9c3fc40cd946c7807cf5afb9c14de8289639c73
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 08:19:43 2015 +0100

    tests: Move syscall setreuid32 test to own executable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 78cc57fb564738e8e0df11719a60de3b6ebe0c6c
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 08:15:37 2015 +0100

    tests: Move syscall setuid32 test to own executable
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 218e64271dc0947721a0592e48f9f59f73565580
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 08:05:11 2015 +0100

    uwrap: Fix build warning with release build
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit c273d99f9091b089081b5bc7a5cfbe00cd164164
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 09:24:08 2015 +0100

    Ignore build and all obj* directories
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

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

Summary of changes:
 .gitignore                                         |   4 +-
 CPackConfig.cmake                                  |   2 +-
 src/uid_wrapper.c                                  |   8 ++
 tests/CMakeLists.txt                               |   9 +-
 tests/test_syscall_gid32.c                         | 127 ---------------------
 tests/{test_setgid.c => test_syscall_setgid32.c}   |  39 ++++---
 ...test_setgroups.c => test_syscall_setgroups32.c} |  34 ++----
 .../{test_setregid.c => test_syscall_setregid32.c} |  36 +++---
 ...test_setresgid.c => test_syscall_setresgid32.c} |  39 ++++---
 ...test_setresuid.c => test_syscall_setresuid32.c} |  80 +++++++------
 .../{test_setreuid.c => test_syscall_setreuid32.c} |  21 ++--
 tests/{test_setuid.c => test_syscall_setuid32.c}   |  21 ++--
 tests/test_syscall_uid32.c                         | 101 ----------------
 13 files changed, 170 insertions(+), 351 deletions(-)
 delete mode 100644 tests/test_syscall_gid32.c
 copy tests/{test_setgid.c => test_syscall_setgid32.c} (78%)
 copy tests/{test_setgroups.c => test_syscall_setgroups32.c} (62%)
 copy tests/{test_setregid.c => test_syscall_setregid32.c} (83%)
 copy tests/{test_setresgid.c => test_syscall_setresgid32.c} (83%)
 copy tests/{test_setresuid.c => test_syscall_setresuid32.c} (74%)
 copy tests/{test_setreuid.c => test_syscall_setreuid32.c} (84%)
 copy tests/{test_setuid.c => test_syscall_setuid32.c} (80%)
 delete mode 100644 tests/test_syscall_uid32.c


Changeset truncated at 500 lines:

diff --git a/.gitignore b/.gitignore
index 8fd1310..0baa4fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,7 @@
 .*
 *.swp
 *~$
-build
-obj
 cscope.*
 tags
+/build
+/obj*
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index dc74dfa..6c40f4d 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -19,7 +19,7 @@ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO
 
 ### source generator
 set(CPACK_SOURCE_GENERATOR "TGZ")
-set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;/obj/;tags;cscope.*")
+set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;/obj*/;tags;cscope.*")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
 
 if (WIN32)
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 2702bd7..ab47dd0 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -1148,7 +1148,9 @@ static int uwrap_setreuid_args(uid_t ruid, uid_t euid,
 
 static int uwrap_setreuid_thread(uid_t ruid, uid_t euid)
 {
+#ifndef NDEBUG
 	struct uwrap_thread *id = uwrap_tls_id;
+#endif
 	uid_t new_ruid = -1, new_euid = -1, new_suid = -1;
 	int rc;
 
@@ -1167,7 +1169,9 @@ static int uwrap_setreuid_thread(uid_t ruid, uid_t euid)
 #ifdef HAVE_SETREUID
 static int uwrap_setreuid(uid_t ruid, uid_t euid)
 {
+#ifndef NDEBUG
 	struct uwrap_thread *id = uwrap_tls_id;
+#endif
 	uid_t new_ruid = -1, new_euid = -1, new_suid = -1;
 	int rc;
 
@@ -1431,7 +1435,9 @@ static int uwrap_setregid_args(gid_t rgid, gid_t egid,
 
 static int uwrap_setregid_thread(gid_t rgid, gid_t egid)
 {
+#ifndef NDEBUG
 	struct uwrap_thread *id = uwrap_tls_id;
+#endif
 	gid_t new_rgid = -1, new_egid = -1, new_sgid = -1;
 	int rc;
 
@@ -1450,7 +1456,9 @@ static int uwrap_setregid_thread(gid_t rgid, gid_t egid)
 #ifdef HAVE_SETREGID
 static int uwrap_setregid(gid_t rgid, gid_t egid)
 {
+#ifndef NDEBUG
 	struct uwrap_thread *id = uwrap_tls_id;
+#endif
 	gid_t new_rgid = -1, new_egid = -1, new_sgid = -1;
 	int rc;
 
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c04d788..8201d94 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -68,8 +68,13 @@ set(UWRAP_TESTS
 if (HAVE_LINUX_32BIT_SYSCALLS)
     set(UWRAP_TESTS
         ${UWRAP_TESTS}
-        test_syscall_uid32
-        test_syscall_gid32)
+        test_syscall_setuid32
+        test_syscall_setreuid32
+        test_syscall_setresuid32
+        test_syscall_setgid32
+        test_syscall_setregid32
+        test_syscall_setresgid32
+        test_syscall_setgroups32)
 endif (HAVE_LINUX_32BIT_SYSCALLS)
 
 foreach(_UWRAP_TEST ${UWRAP_TESTS})
diff --git a/tests/test_syscall_gid32.c b/tests/test_syscall_gid32.c
deleted file mode 100644
index 04b8c9e..0000000
--- a/tests/test_syscall_gid32.c
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "config.h"
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <grp.h>
-
-#ifdef HAVE_SYS_SYSCALL_H
-#include <sys/syscall.h>
-#endif
-#ifdef HAVE_SYSCALL_H
-#include <syscall.h>
-#endif
-
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
-static void test_uwrap_syscall_setgid32(void **state)
-{
-	long int rc;
-	gid_t g;
-
-	(void) state; /* unused */
-
-	rc = syscall(SYS_setgid32, 1);
-	assert_int_equal(rc, 0);
-
-	g = getgid();
-	assert_int_equal(g, 1);
-	assert_int_equal(g, syscall(SYS_getgid32));
-}
-
-static void test_uwrap_syscall_setregid32(void **state)
-{
-	long int rc;
-	gid_t g;
-
-	(void) state; /* unused */
-
-	rc = syscall(SYS_setregid32, 2, 0);
-	assert_int_equal(rc, 0);
-
-	g = getegid();
-	assert_int_equal(g, 0);
-	assert_int_equal(g, syscall(SYS_getegid32));
-
-	rc = syscall(SYS_setregid32, -1, 42);
-	assert_int_equal(rc, 0);
-
-	g = getgid();
-	assert_int_equal(g, 2);
-	g = getegid();
-	assert_int_equal(g, 42);
-}
-
-static void test_uwrap_syscall_setresgid32(void **state)
-{
-	long int rc;
-	gid_t g;
-	gid_t g_r, g_e, g_s;
-
-	(void) state; /* unused */
-
-	rc = syscall(SYS_setresgid32, 42, 0, -1);
-	assert_int_equal(rc, 0);
-
-	g = getegid();
-	rc = syscall(SYS_getresgid32, &g_r, &g_e, &g_s);
-	assert_return_code(rc, errno);
-
-	assert_int_equal(g_r, 42);
-	assert_int_equal(g, g_e);
-
-	rc = syscall(SYS_setregid32, -1, 42);
-	assert_return_code(rc, errno);
-
-	g = getegid();
-	assert_int_equal(g, 42);
-}
-
-static void test_uwrap_syscall_setgroups32(void **state)
-{
-	gid_t glist[] = { 100, 200, 300, 400, 500 };
-	gid_t rlist[16];
-	int rc = -1;
-
-	(void) state; /* unused */
-
-	rc = syscall(SYS_setgroups32, ARRAY_SIZE(glist), glist);
-	assert_int_equal(rc, 0);
-
-	rc = getgroups(ARRAY_SIZE(rlist), rlist);
-	assert_int_equal(rc, 5);
-
-	assert_memory_equal(glist, rlist, sizeof(glist));
-
-	/* Drop all supplementary groups. This is often done by daemons */
-	memset(rlist, 0, sizeof(rlist));
-	rc = syscall(SYS_setgroups32, 0, NULL);
-	assert_int_equal(rc, 0);
-
-	rc = getgroups(ARRAY_SIZE(rlist), rlist);
-	assert_int_equal(rc, 0);
-
-	assert_int_equal(rlist[0], 0);
-}
-
-int main(void) {
-	int rc;
-
-	const struct CMUnitTest uwrap_tests[] = {
-		cmocka_unit_test(test_uwrap_syscall_setgid32),
-		cmocka_unit_test(test_uwrap_syscall_setregid32),
-		cmocka_unit_test(test_uwrap_syscall_setresgid32),
-		cmocka_unit_test(test_uwrap_syscall_setgroups32),
-	};
-
-	rc = cmocka_run_group_tests(uwrap_tests, NULL, NULL);
-
-	return rc;
-}
diff --git a/tests/test_setgid.c b/tests/test_syscall_setgid32.c
similarity index 78%
copy from tests/test_setgid.c
copy to tests/test_syscall_setgid32.c
index d387178..e01a2b4 100644
--- a/tests/test_setgid.c
+++ b/tests/test_syscall_setgid32.c
@@ -6,12 +6,20 @@
 #include <cmocka.h>
 
 #include <errno.h>
+#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <pwd.h>
+#include <grp.h>
 
-static void test_uwrap_setgid_root(void **state)
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
+#ifdef HAVE_SYSCALL_H
+#include <syscall.h>
+#endif
+
+static void test_uwrap_syscall_setgid32_root(void **state)
 {
 	int rc;
 	uid_t u;
@@ -42,7 +50,7 @@ static void test_uwrap_setgid_root(void **state)
 	g = getegid();
 	assert_int_equal(g, 0x0);
 
-	rc = setgid(-1);
+	rc = syscall(SYS_setgid32, -1);
 	assert_int_equal(rc, -1);
 	assert_int_equal(errno, EINVAL);
 
@@ -55,29 +63,29 @@ static void test_uwrap_setgid_root(void **state)
 	assert_int_equal(cp_sgid, 0);
 #endif
 
-	rc = setgid(5555);
+	rc = syscall(SYS_setgid32, 0x5555);
 	assert_return_code(rc, errno);
 
 #ifdef HAVE_GETRESGID
 	cp_rgid = cp_egid = cp_sgid = -1;
 	rc = getresgid(&cp_rgid, &cp_egid, &cp_sgid);
 	assert_return_code(rc, errno);
-	assert_int_equal(cp_rgid, 5555);
-	assert_int_equal(cp_egid, 5555);
-	assert_int_equal(cp_sgid, 5555);
+	assert_int_equal(cp_rgid, 0x5555);
+	assert_int_equal(cp_egid, 0x5555);
+	assert_int_equal(cp_sgid, 0x5555);
 #endif
 
 	g = getgid();
-	assert_int_equal(g, 5555);
+	assert_int_equal(g, 0x5555);
 
 	g = getegid();
-	assert_int_equal(g, 5555);
+	assert_int_equal(g, 0x5555);
 
 	rc = setgid(0);
 	assert_return_code(rc, errno);
 }
 
-static void test_uwrap_setgid_user(void **state)
+static void test_uwrap_syscall_setgid32_user(void **state)
 {
 	int rc;
 	uid_t u;
@@ -101,7 +109,7 @@ static void test_uwrap_setgid_user(void **state)
 	assert_int_equal(cp_sgid, 0);
 #endif
 
-	rc = setuid(0x5555);
+	setuid(0x5555);
 	assert_return_code(rc, errno);
 
 	u = getuid();
@@ -118,7 +126,7 @@ static void test_uwrap_setgid_user(void **state)
 	assert_int_equal(cp_sgid, 0);
 #endif
 
-	rc = setgid(5555);
+	rc = syscall(SYS_setgid32, 0x5555);
 	assert_int_equal(rc, -1);
 	assert_int_equal(errno, EPERM);
 
@@ -131,7 +139,7 @@ static void test_uwrap_setgid_user(void **state)
 	assert_int_equal(cp_sgid, 0);
 #endif
 
-	rc = setgid(0);
+	rc = syscall(SYS_setgid32, 0x0);
 	assert_return_code(rc, errno);
 }
 
@@ -139,11 +147,12 @@ int main(void) {
 	int rc;
 
 	const struct CMUnitTest uwrap_tests[] = {
-		cmocka_unit_test(test_uwrap_setgid_root),
-		cmocka_unit_test(test_uwrap_setgid_user),
+		cmocka_unit_test(test_uwrap_syscall_setgid32_root),
+		cmocka_unit_test(test_uwrap_syscall_setgid32_user),
 	};
 
 	rc = cmocka_run_group_tests(uwrap_tests, NULL, NULL);
 
 	return rc;
 }
+
diff --git a/tests/test_setgroups.c b/tests/test_syscall_setgroups32.c
similarity index 62%
copy from tests/test_setgroups.c
copy to tests/test_syscall_setgroups32.c
index 45d2803..3ac482c 100644
--- a/tests/test_setgroups.c
+++ b/tests/test_syscall_setgroups32.c
@@ -12,32 +12,24 @@
 
 #include <grp.h>
 
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
-static void test_uwrap_getgroups(void **state)
-{
-	gid_t rlist[20] = {0};
-	int num_groups;
-	int rc;
-
-	(void) state; /* unused */
-	num_groups = getgroups(0, NULL);
-	assert_int_not_equal(num_groups, -1);
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
+#ifdef HAVE_SYSCALL_H
+#include <syscall.h>
+#endif
 
-	rc = getgroups(ARRAY_SIZE(rlist), rlist);
-	assert_int_equal(rc, num_groups);
-	assert_int_equal(rlist[0], getegid());
-}
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
-static void test_uwrap_setgroups(void **state)
+static void test_uwrap_syscall_setgroups32(void **state)
 {
 	gid_t glist[] = { 100, 200, 300, 400, 500 };
 	gid_t rlist[16];
-	int rc;
+	int rc = -1;
 
 	(void) state; /* unused */
 
-	rc = setgroups(ARRAY_SIZE(glist), glist);
+	rc = syscall(SYS_setgroups32, ARRAY_SIZE(glist), glist);
 	assert_int_equal(rc, 0);
 
 	rc = getgroups(ARRAY_SIZE(rlist), rlist);
@@ -47,8 +39,7 @@ static void test_uwrap_setgroups(void **state)
 
 	/* Drop all supplementary groups. This is often done by daemons */
 	memset(rlist, 0, sizeof(rlist));
-
-	rc = setgroups(0, NULL);
+	rc = syscall(SYS_setgroups32, 0, NULL);
 	assert_int_equal(rc, 0);
 
 	rc = getgroups(ARRAY_SIZE(rlist), rlist);
@@ -61,8 +52,7 @@ int main(void) {
 	int rc;
 
 	const struct CMUnitTest uwrap_tests[] = {
-		cmocka_unit_test(test_uwrap_getgroups),
-		cmocka_unit_test(test_uwrap_setgroups),
+		cmocka_unit_test(test_uwrap_syscall_setgroups32),
 	};
 
 	rc = cmocka_run_group_tests(uwrap_tests, NULL, NULL);
diff --git a/tests/test_setregid.c b/tests/test_syscall_setregid32.c
similarity index 83%
copy from tests/test_setregid.c
copy to tests/test_syscall_setregid32.c
index f4844f8..49615f3 100644
--- a/tests/test_setregid.c
+++ b/tests/test_syscall_setregid32.c
@@ -6,14 +6,22 @@
 #include <cmocka.h>
 
 #include <errno.h>
+#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <pwd.h>
+#include <grp.h>
 
-static void test_uwrap_setregid_root(void **state)
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
+#ifdef HAVE_SYSCALL_H
+#include <syscall.h>
+#endif
+
+static void test_uwrap_syscall_setregid32_root(void **state)
 {
-	int rc;
+	long int rc;
 	uid_t u;
 	gid_t g;
 #ifdef HAVE_GETRESGID
@@ -42,10 +50,10 @@ static void test_uwrap_setregid_root(void **state)
 	g = getegid();
 	assert_int_equal(g, 0x0);
 
-	rc = setregid(-1, -1);
+	rc = syscall(SYS_setregid32, -1, -1);
 	assert_int_equal(rc, 0);
 
-	rc = setregid(0x4444, 0x5555);
+	rc = syscall(SYS_setregid32, 0x4444, 0x5555);
 	assert_int_equal(rc, 0);
 
 #ifdef HAVE_GETRESGID
@@ -63,7 +71,7 @@ static void test_uwrap_setregid_root(void **state)
 	g = getegid();
 	assert_int_equal(g, 0x5555);
 
-	rc = setregid(0, -1);
+	rc = syscall(SYS_setregid32, 0, -1);
 	assert_return_code(rc, errno);
 
 #ifdef HAVE_GETRESGID
@@ -75,7 +83,7 @@ static void test_uwrap_setregid_root(void **state)
 	assert_int_equal(cp_sgid, 0x5555);
 #endif
 
-	rc = setregid(-1, 0);
+	rc = syscall(SYS_setregid32, -1, 0);
 	assert_return_code(rc, errno);
 
 #ifdef HAVE_GETRESGID
@@ -97,9 +105,9 @@ static void test_uwrap_setregid_root(void **state)
 #endif
 }
 
-static void test_uwrap_setregid_user(void **state)
+static void test_uwrap_syscall_setregid32_user(void **state)
 {
-	int rc;
+	long int rc;
 	uid_t u;
 #ifdef HAVE_GETRESGID
 	gid_t cp_rgid, cp_egid, cp_sgid;
@@ -138,7 +146,7 @@ static void test_uwrap_setregid_user(void **state)
 	assert_int_equal(cp_sgid, 0);
 #endif
 
-	rc = setregid(0x4444, 0x5555);
+	rc = syscall(SYS_setregid32, 0x4444, 0x5555);
 	assert_int_equal(rc, -1);
 	assert_int_equal(errno, EPERM);
 
@@ -151,7 +159,7 @@ static void test_uwrap_setregid_user(void **state)
 	assert_int_equal(cp_sgid, 0);
 #endif


-- 
UID Wrapper Repository



More information about the samba-cvs mailing list