summaryrefslogtreecommitdiff
path: root/source3/lib/util_sec.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_sec.c')
-rw-r--r--source3/lib/util_sec.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/source3/lib/util_sec.c b/source3/lib/util_sec.c
index c13b20ec92..3f8cb690cd 100644
--- a/source3/lib/util_sec.c
+++ b/source3/lib/util_sec.c
@@ -258,10 +258,9 @@ void save_re_uid(void)
/****************************************************************************
and restore them!
****************************************************************************/
-void restore_re_uid(void)
-{
- set_effective_uid(0);
+static void restore_re_uid_fromroot(void)
+{
#if USE_SETRESUID
setresuid(saved_ruid, saved_euid, -1);
#elif USE_SETREUID
@@ -280,6 +279,33 @@ void restore_re_uid(void)
assert_uid(saved_ruid, saved_euid);
}
+void restore_re_uid(void)
+{
+ set_effective_uid(0);
+ restore_re_uid_fromroot();
+}
+
+/****************************************************************************
+ Lightweight become root - no group change.
+****************************************************************************/
+
+void become_root_uid_only(void)
+{
+ save_re_uid();
+ set_effective_uid(0);
+}
+
+/****************************************************************************
+ Lightweight unbecome root - no group change. Expects we are root already,
+ saves errno across call boundary.
+****************************************************************************/
+
+void unbecome_root_uid_only(void)
+{
+ int saved_errno = errno;
+ restore_re_uid_fromroot();
+ errno = saved_errno;
+}
/****************************************************************************
save the real and effective gid for later restoration. Used by the