[SCM] UID Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Dec 4 09:59:01 MST 2013


The branch, master has been updated
       via  7e534a7 tests: Add a test for setgroups().
       via  d9f5ea1 tests: Add a test for setgid().
      from  764af96 cmake: Set _FORTIFY_SOURCE only for optimized builds.

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


- Log -----------------------------------------------------------------
commit 7e534a70cede4c8516e25f7754909285a3bc7d6b
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Wed Dec 4 17:58:44 2013 +0100

    tests: Add a test for setgroups().

commit d9f5ea16e37ccc2fcffc90f6e263e1bf73ee895b
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Wed Dec 4 17:44:53 2013 +0100

    tests: Add a test for setgid().

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

Summary of changes:
 tests/testsuite.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tests/testsuite.c b/tests/testsuite.c
index ddf3ee4..1a36346 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -14,6 +14,8 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#include <grp.h>
+
 #ifdef HAVE_SYS_SYSCALL_H
 #include <sys/syscall.h>
 #endif
@@ -22,6 +24,7 @@
 #endif
 
 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
 static void test_uwrap_seteuid(void **state)
 {
@@ -108,6 +111,30 @@ static void test_uwrap_setegid(void **state)
 	assert_int_equal(u, 42);
 }
 
+static void test_uwrap_setgid(void **state)
+{
+	int rc;
+	gid_t u;
+	char *env;
+
+	env = getenv("UID_WRAPPER");
+	if (env == NULL) {
+		printf("UID_WRAPPER env not set, uid_wrapper is disabled\n");
+		return;
+	}
+
+	(void) state; /* unused */
+
+	rc = setgid(-1);
+	assert_int_equal(rc, -1);
+
+	rc = setgid(42);
+	assert_int_equal(rc, 0);
+
+	u = getgid();
+	assert_int_equal(u, 42);
+}
+
 static void test_uwrap_syscall(void **state)
 {
 	long int rc;
@@ -206,6 +233,23 @@ static void test_uwrap_syscall_setregid(void **state)
 	assert_int_equal(g, 42);
 }
 
+static void test_uwrap_setgroups(void **state)
+{
+	gid_t glist[] = { 100, 200, 300, 400, 500 };
+	gid_t rlist[16];
+	int rc;
+
+	(void) state; /* unused */
+
+	rc = setgroups(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));
+}
+
 int main(void) {
 	int rc;
 
@@ -214,8 +258,10 @@ int main(void) {
 		unit_test(test_uwrap_seteuid),
 		unit_test(test_uwrap_setuid),
 		unit_test(test_uwrap_setegid),
+		unit_test(test_uwrap_setgid),
 		unit_test(test_uwrap_syscall_setreuid),
 		unit_test(test_uwrap_syscall_setregid),
+		unit_test(test_uwrap_setgroups),
 	};
 
 	rc = run_tests(tests);


-- 
UID Wrapper Repository


More information about the samba-cvs mailing list