summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-10-06 16:25:32 +0200
committerAndreas Schneider <asn@samba.org>2011-10-07 10:24:03 +0200
commitc2b9e9b0eab3b10e36a56835602e7c931c406b12 (patch)
treeda382c464432948e6883289a24e08a6e769049f0
parent556ef6ac906ef6155c21714aaa6f3cf3ee52a9ac (diff)
downloadsamba-c2b9e9b0eab3b10e36a56835602e7c931c406b12.tar.gz
uid_wrapper: Add uwrap_setreuid().
-rw-r--r--lib/uid_wrapper/uid_wrapper.c11
-rw-r--r--lib/uid_wrapper/uid_wrapper.h6
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c
index 05d226b034c..091678f27ba 100644
--- a/lib/uid_wrapper/uid_wrapper.c
+++ b/lib/uid_wrapper/uid_wrapper.c
@@ -73,6 +73,17 @@ _PUBLIC_ int uwrap_seteuid(uid_t euid)
return 0;
}
+_PUBLIC_ int uwrap_setreuid(uid_t ruid, uid_t euid)
+{
+ uwrap_init();
+ if (!uwrap.enabled) {
+ return setreuid(ruid, euid);
+ }
+ /* assume for now that the ruid stays as root */
+ uwrap.euid = euid;
+ return 0;
+}
+
_PUBLIC_ uid_t uwrap_geteuid(void)
{
uwrap_init();
diff --git a/lib/uid_wrapper/uid_wrapper.h b/lib/uid_wrapper/uid_wrapper.h
index b3b11d954ae..c0aebcfafcd 100644
--- a/lib/uid_wrapper/uid_wrapper.h
+++ b/lib/uid_wrapper/uid_wrapper.h
@@ -21,6 +21,7 @@
int uwrap_enabled(void);
int uwrap_seteuid(uid_t euid);
+int uwrap_setreuid(uid_t reuid, uid_t euid);
uid_t uwrap_geteuid(void);
int uwrap_setegid(gid_t egid);
uid_t uwrap_getegid(void);
@@ -34,6 +35,11 @@ gid_t uwrap_getgid(void);
#endif
#define seteuid uwrap_seteuid
+#ifdef setreuid
+#undef setreuid
+#endif
+#define setreuid uwrap_setreuid
+
#ifdef setegid
#undef setegid
#endif