[SCM] UID Wrapper Repository - branch master updated
Andreas Schneider
asn at samba.org
Wed Dec 18 09:25:39 MST 2013
The branch, master has been updated
via b36c8e1 tests: Add test_uwrap_syscall_setgroups().
via c4326d1 tests: Add test_uwrap_setresuid().
via c1b1430 tests: Add test_uwrap_setreuid().
via a1341ef tests: Add test_uwrap_setresgid().
via d0270b9 tests: Add test_uwrap_setregid().
via b4fdaa9 tests: The tests should always be executed with uid_wrapper.
via 1cbcd32 nwrap: Fix prototype of libc_setresuid().
via 280d918 cmake: Fix defines for setres(u|g)id.
from 8f8e057 uwrap: Remove obsolete uwrap_libc_fn().
http://gitweb.samba.org/?p=uid_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit b36c8e1e269daacc60031fa437477665a0171f7c
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 17:23:31 2013 +0100
tests: Add test_uwrap_syscall_setgroups().
commit c4326d1ac83ad239822e2b65a228a3078e641c92
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 17:11:14 2013 +0100
tests: Add test_uwrap_setresuid().
commit c1b14304e4b3677dc69398958739f387925ee2ca
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 17:09:15 2013 +0100
tests: Add test_uwrap_setreuid().
commit a1341eff5e63842d8367039220a446fe1d9875b7
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 17:06:46 2013 +0100
tests: Add test_uwrap_setresgid().
commit d0270b9d54b3e7aa9e76940deeeb5aba8db5e6b3
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 16:59:54 2013 +0100
tests: Add test_uwrap_setregid().
commit b4fdaa903d71651751a7d535ea7eb854da7c64d1
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 16:53:17 2013 +0100
tests: The tests should always be executed with uid_wrapper.
commit 1cbcd32be96a8116e036d272cc8f8c82d3990649
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 17:05:57 2013 +0100
nwrap: Fix prototype of libc_setresuid().
commit 280d918269e63f971402fbae4418ab2bc64876bb
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 17:02:08 2013 +0100
cmake: Fix defines for setres(u|g)id.
-----------------------------------------------------------------------
Summary of changes:
config.h.cmake | 4 +-
src/uid_wrapper.c | 2 +-
tests/testsuite.c | 163 +++++++++++++++++++++++++++++++++++++----------------
3 files changed, 117 insertions(+), 52 deletions(-)
Changeset truncated at 500 lines:
diff --git a/config.h.cmake b/config.h.cmake
index a714ccf..679390c 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -29,7 +29,7 @@
#cmakedefine HAVE_SETREUID 1
/* Define to 1 if you have the `setresuid' function. */
-#cmakedefine HAVE_SETREUID 1
+#cmakedefine HAVE_SETRESUID 1
/* Define to 1 if you have the `setegid' function. */
#cmakedefine HAVE_SETEGID 1
@@ -38,7 +38,7 @@
#cmakedefine HAVE_SETREGID 1
/* Define to 1 if you have the `setresgid' function. */
-#cmakedefine HAVE_SETREGID 1
+#cmakedefine HAVE_SETRESGID 1
/* Define to 1 if you have the `setgroups' function. */
#cmakedefine HAVE_SETGROUPS 1
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 2f3d3ad..ff2639f 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -281,7 +281,7 @@ static int libc_setreuid(uid_t ruid, uid_t euid)
#endif
#ifdef HAVE_SETRESUID
-int libc_setresuid(uid_t ruid, uid_t euid, uid_t suid);
+static int libc_setresuid(uid_t ruid, uid_t euid, uid_t suid)
{
uwrap_load_lib_function(UWRAP_LIBC, setresuid);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 67836fa..412b50f 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -30,13 +30,6 @@ static void test_uwrap_seteuid(void **state)
{
int rc;
uid_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 */
@@ -58,17 +51,48 @@ static void test_uwrap_seteuid(void **state)
assert_int_equal(u, 42);
}
-static void test_uwrap_setuid(void **state)
+#ifdef HAVE_SETREUID
+static void test_uwrap_setreuid(void **state)
{
int rc;
uid_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 = setreuid(1, 2);
+ assert_int_equal(rc, 0);
+
+ u = getuid();
+ assert_int_equal(u, 1);
+
+ u = geteuid();
+ assert_int_equal(u, 2);
+}
+#endif
+
+#ifdef HAVE_SETRESUID
+static void test_uwrap_setresuid(void **state)
+{
+ int rc;
+ uid_t u;
+
+ (void) state; /* unused */
+
+ rc = setresuid(1, 2, -1);
+ assert_int_equal(rc, 0);
+
+ u = getuid();
+ assert_int_equal(u, 1);
+
+ u = geteuid();
+ assert_int_equal(u, 2);
+}
+#endif
+
+static void test_uwrap_setuid(void **state)
+{
+ int rc;
+ uid_t u;
(void) state; /* unused */
@@ -86,13 +110,6 @@ static void test_uwrap_setegid(void **state)
{
int rc;
uid_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 */
@@ -111,17 +128,48 @@ static void test_uwrap_setegid(void **state)
assert_int_equal(u, 42);
}
+#ifdef HAVE_SETREGID
+static void test_uwrap_setregid(void **state)
+{
+ int rc;
+ uid_t u;
+
+ (void) state; /* unused */
+
+ rc = setregid(1, 2);
+ assert_int_equal(rc, 0);
+
+ u = getgid();
+ assert_int_equal(u, 1);
+
+ u = getegid();
+ assert_int_equal(u, 2);
+}
+#endif
+
+#ifdef HAVE_SETRESGID
+static void test_uwrap_setresgid(void **state)
+{
+ int rc;
+ uid_t u;
+
+ (void) state; /* unused */
+
+ rc = setresgid(1, 2, -1);
+ assert_int_equal(rc, 0);
+
+ u = getgid();
+ assert_int_equal(u, 1);
+
+ u = getegid();
+ assert_int_equal(u, 2);
+}
+#endif
+
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 */
@@ -138,16 +186,9 @@ static void test_uwrap_setgid(void **state)
static void test_uwrap_syscall(void **state)
{
long int rc;
- char *env;
struct timeval tv1, tv2;
struct timezone tz1, tz2;
- env = getenv("UID_WRAPPER");
- if (env == NULL) {
- printf("UID_WRAPPER env not set, uid_wrapper is disabled\n");
- return;
- }
-
(void) state; /* unused */
rc = syscall(SYS_getpid);
@@ -179,13 +220,6 @@ static void test_uwrap_syscall_setreuid(void **state)
{
long int rc;
uid_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 */
@@ -208,13 +242,6 @@ static void test_uwrap_syscall_setregid(void **state)
{
long int rc;
gid_t g;
- char *env;
-
- env = getenv("UID_WRAPPER");
- if (env == NULL) {
- printf("UID_WRAPPER env not set, uid_wrapper is disabled\n");
- return;
- }
(void) state; /* unused */
@@ -262,6 +289,29 @@ static void test_uwrap_setgroups(void **state)
assert_memory_equal(glist, rlist, sizeof(glist));
}
+#if defined(SYS_setgroups) || defined(SYS_setroups32)
+static void test_uwrap_syscall_setgroups(void **state)
+{
+ gid_t glist[] = { 100, 200, 300, 400, 500 };
+ gid_t rlist[16];
+ int rc = -1;
+
+ (void) state; /* unused */
+
+#ifdef SYS_setgroups
+ rc = syscall(SYS_setgroups, ARRAY_SIZE(glist), glist);
+#elif SYS_setgroups32
+ rc = syscall(SYS_setgroups32, ARRAY_SIZE(glist), glist);
+#endif
+ assert_int_equal(rc, 0);
+
+ rc = getgroups(ARRAY_SIZE(rlist), rlist);
+ assert_int_equal(rc, 5);
+
+ assert_memory_equal(glist, rlist, sizeof(glist));
+}
+#endif
+
int main(void) {
int rc;
@@ -270,12 +320,27 @@ int main(void) {
unit_test(test_uwrap_getgroups),
unit_test(test_uwrap_seteuid),
+#ifdef HAVE_SETREUID
+ unit_test(test_uwrap_setreuid),
+#endif
+#ifdef HAVE_SETREUID
+ unit_test(test_uwrap_setresuid),
+#endif
unit_test(test_uwrap_setuid),
unit_test(test_uwrap_setegid),
+#ifdef HAVE_SETREGID
+ unit_test(test_uwrap_setregid),
+#endif
+#ifdef HAVE_SETRESGID
+ unit_test(test_uwrap_setresgid),
+#endif
unit_test(test_uwrap_setgid),
unit_test(test_uwrap_syscall_setreuid),
unit_test(test_uwrap_syscall_setregid),
unit_test(test_uwrap_setgroups),
+#if defined(SYS_setgroups) || defined(SYS_setroups32)
+ unit_test(test_uwrap_syscall_setgroups),
+#endif
};
rc = run_tests(tests);
--
UID Wrapper Repository
More information about the samba-cvs
mailing list