[SCM] UID Wrapper Repository - branch master updated
Andreas Schneider
asn at samba.org
Tue Jan 7 05:32:30 MST 2014
The branch, master has been updated
via efc5f66 uwrap: Rename the variable to get myuid from geteuid().
via 553b3dc uwrap: Make uwrap_enabled public so we can use it.
from c1a96dc tests: Fix some memory leaks.
http://gitweb.samba.org/?p=uid_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit efc5f660a10fe6b978837609983ce7a080998a75
Author: Andreas Schneider <asn at cryptomilk.org>
Date: Tue Jan 7 13:31:58 2014 +0100
uwrap: Rename the variable to get myuid from geteuid().
commit 553b3dc15e5e16c81e7375084eafd95c7ad42d20
Author: Andreas Schneider <asn at cryptomilk.org>
Date: Tue Jan 7 13:30:06 2014 +0100
uwrap: Make uwrap_enabled public so we can use it.
-----------------------------------------------------------------------
Summary of changes:
README | 2 +-
src/uid_wrapper.c | 7 ++++---
tests/CMakeLists.txt | 8 ++++++++
tests/test_uwrap_enabled.c | 30 ++++++++++++++++++++++++++++++
tests/uwrap_enabled.c | 6 ++++++
5 files changed, 49 insertions(+), 4 deletions(-)
create mode 100644 tests/test_uwrap_enabled.c
create mode 100644 tests/uwrap_enabled.c
Changeset truncated at 500 lines:
diff --git a/README b/README
index 9aa508b..aac2285 100644
--- a/README
+++ b/README
@@ -16,5 +16,5 @@ loaded. If you need the application to think it is root at startup you can set:
UID_WRAPPER_ROOT=1
-If you set the environment variable to UID_WRAPPER_ROOT=2 before you call
+If you set the environment variable to UID_WRAPPER_MYUID=1 before you call
geteuid() then it will return the real uid.
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 077bef7..d2cb618 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -175,6 +175,7 @@ static pthread_mutex_t uwrap_id_mutex = PTHREAD_MUTEX_INITIALIZER;
* UWRAP PROTOTYPES
*********************************************************/
+int uwrap_enabled(void);
void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
/*********************************************************
@@ -547,7 +548,7 @@ static void uwrap_init(void)
pthread_mutex_unlock(&uwrap_id_mutex);
}
-static int uwrap_enabled(void)
+int uwrap_enabled(void)
{
uwrap_init();
@@ -696,7 +697,7 @@ uid_t getuid(void)
*/
static uid_t uwrap_geteuid(void)
{
- const char *env = getenv("UID_WRAPPER_ROOT");
+ const char *env = getenv("UID_WRAPPER_MYUID");
struct uwrap_thread *id = uwrap_tls_id;
uid_t uid;
@@ -705,7 +706,7 @@ static uid_t uwrap_geteuid(void)
pthread_mutex_unlock(&uwrap_id_mutex);
/* Disable root and return myuid */
- if (env != NULL && env[0] == '2') {
+ if (env != NULL && env[0] == '1') {
uid = uwrap.myuid;
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 76fdb6b..3c6ab2b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -19,6 +19,14 @@ set_property(
PROPERTY
ENVIRONMENT ${TEST_ENVIRONMENT})
+add_library(uwrap_enabled SHARED uwrap_enabled.c)
+add_cmocka_test(test_uwrap_enabled test_uwrap_enabled.c ${CMOCKA_LIBRARY} uwrap_enabled)
+set_property(
+ TEST
+ test_uwrap_enabled
+ PROPERTY
+ ENVIRONMENT ${TEST_ENVIRONMENT})
+
if (LINUX)
add_cmocka_test(test_glibc_thread_support test_glibc_thread_support.c ${CMOCKA_LIBRARY})
target_link_libraries(test_glibc_thread_support ${CMAKE_THREAD_LIBS_INIT})
diff --git a/tests/test_uwrap_enabled.c b/tests/test_uwrap_enabled.c
new file mode 100644
index 0000000..1ff5531
--- /dev/null
+++ b/tests/test_uwrap_enabled.c
@@ -0,0 +1,30 @@
+#include "config.h"
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+int uwrap_enabled(void);
+
+static void test_uwrap_enabled(void **state)
+{
+ int rc;
+
+ (void)state; /* unused */
+
+ rc = uwrap_enabled();
+ assert_int_equal(rc, 1);
+}
+
+int main(void) {
+ int rc;
+
+ const UnitTest tests[] = {
+ unit_test(test_uwrap_enabled),
+ };
+
+ rc = run_tests(tests);
+
+ return rc;
+}
diff --git a/tests/uwrap_enabled.c b/tests/uwrap_enabled.c
new file mode 100644
index 0000000..c1bcf3a
--- /dev/null
+++ b/tests/uwrap_enabled.c
@@ -0,0 +1,6 @@
+int uwrap_enabled(void);
+
+int uwrap_enabled(void)
+{
+ return 0;
+}
--
UID Wrapper Repository
More information about the samba-cvs
mailing list