svn commit: samba r18546 - in branches/SAMBA_3_0_23/source/lib: .
jra at samba.org
jra at samba.org
Fri Sep 15 09:05:28 GMT 2006
Author: jra
Date: 2006-09-15 09:05:24 +0000 (Fri, 15 Sep 2006)
New Revision: 18546
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18546
Log:
Fix the build - ensure we have become_root_uid_only
available.
Jeremy.
Modified:
branches/SAMBA_3_0_23/source/lib/util_sec.c
Changeset:
Modified: branches/SAMBA_3_0_23/source/lib/util_sec.c
===================================================================
--- branches/SAMBA_3_0_23/source/lib/util_sec.c 2006-09-15 08:10:49 UTC (rev 18545)
+++ branches/SAMBA_3_0_23/source/lib/util_sec.c 2006-09-15 09:05:24 UTC (rev 18546)
@@ -52,10 +52,16 @@
remember what uid we got started as - this allows us to run correctly
as non-root while catching trapdoor systems
****************************************************************************/
+
void sec_init(void)
{
- initial_uid = geteuid();
- initial_gid = getegid();
+ static int initialized;
+
+ if (!initialized) {
+ initial_uid = geteuid();
+ initial_gid = getegid();
+ initialized = 1;
+ }
}
/****************************************************************************
@@ -252,10 +258,9 @@
/****************************************************************************
and restore them!
****************************************************************************/
-void restore_re_uid(void)
+
+static void restore_re_uid_fromroot(void)
{
- set_effective_uid(0);
-
#if USE_SETRESUID
setresuid(saved_ruid, saved_euid, -1);
#elif USE_SETREUID
@@ -274,8 +279,35 @@
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
getgroups code
****************************************************************************/
More information about the samba-cvs
mailing list