diff options
Diffstat (limited to 'source/lib/util_sec.c')
-rw-r--r-- | source/lib/util_sec.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/source/lib/util_sec.c b/source/lib/util_sec.c index 5b8bdb44c1b..c559647bf45 100644 --- a/source/lib/util_sec.c +++ b/source/lib/util_sec.c @@ -21,7 +21,6 @@ #ifndef AUTOCONF_TEST #include "includes.h" -extern int DEBUGLEVEL; #else /* we are running this code in autoconf test mode to see which type of setuid function works */ @@ -48,6 +47,7 @@ extern int DEBUGLEVEL; /* are we running as non-root? This is used by the regresison test code, and potentially also for sites that want non-root smbd */ static uid_t initial_uid; +static gid_t initial_gid; /**************************************************************************** remember what uid we got started as - this allows us to run correctly @@ -56,6 +56,23 @@ as non-root while catching trapdoor systems void sec_init(void) { initial_uid = geteuid(); + initial_gid = getegid(); +} + +/**************************************************************************** +some code (eg. winbindd) needs to know what uid we started as +****************************************************************************/ +uid_t sec_initial_uid(void) +{ + return initial_uid; +} + +/**************************************************************************** +some code (eg. winbindd, profiling shm) needs to know what gid we started as +****************************************************************************/ +gid_t sec_initial_gid(void) +{ + return initial_gid; } /**************************************************************************** @@ -396,3 +413,11 @@ main() exit(0); } #endif + +/**************************************************************************** +Check if we are setuid root. Used in libsmb and smbpasswd parinoia checks. +****************************************************************************/ +BOOL is_setuid_root(void) +{ + return (geteuid() == (uid_t)0) && (getuid() != (uid_t)0); +} |