summaryrefslogtreecommitdiff
path: root/source3/lib/util_sec.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-02-17 18:32:59 +0000
committerTim Potter <tpot@samba.org>2002-02-17 18:32:59 +0000
commitd159876d64ad33eccdc56a6eb1afba96f9863a5d (patch)
tree6ce2b6334836258a2cfdeba4281d01d072ec2451 /source3/lib/util_sec.c
parente1a65ecd0d14700f313bb3b97beaff8dc66fdd29 (diff)
downloadsamba-d159876d64ad33eccdc56a6eb1afba96f9863a5d.tar.gz
samba-d159876d64ad33eccdc56a6eb1afba96f9863a5d.tar.bz2
samba-d159876d64ad33eccdc56a6eb1afba96f9863a5d.zip
Do a smb_panic() if sec_initial_[ug]id() or non_root_mode() is called
without before sec_init(). This should avoid the formation of another magic function club. (-: (This used to be commit 1b941e2c637e41049932945607149094342359c5)
Diffstat (limited to 'source3/lib/util_sec.c')
-rw-r--r--source3/lib/util_sec.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source3/lib/util_sec.c b/source3/lib/util_sec.c
index dd9a64d534..ac808b7fef 100644
--- a/source3/lib/util_sec.c
+++ b/source3/lib/util_sec.c
@@ -48,6 +48,8 @@
static uid_t initial_uid;
static gid_t initial_gid;
+static BOOL sec_initialised;
+
/****************************************************************************
remember what uid we got started as - this allows us to run correctly
as non-root while catching trapdoor systems
@@ -56,6 +58,8 @@ void sec_init(void)
{
initial_uid = geteuid();
initial_gid = getegid();
+
+ sec_initialise = True;
}
/****************************************************************************
@@ -63,6 +67,9 @@ some code (eg. winbindd) needs to know what uid we started as
****************************************************************************/
uid_t sec_initial_uid(void)
{
+ if (!sec_initialise)
+ smb_panic("sec_initial_uid() called before sec_init()\n");
+
return initial_uid;
}
@@ -71,6 +78,9 @@ some code (eg. winbindd, profiling shm) needs to know what gid we started as
****************************************************************************/
gid_t sec_initial_gid(void)
{
+ if (!sec_initialise)
+ smb_panic("sec_initial_gid() called before sec_init()\n");
+
return initial_gid;
}
@@ -79,6 +89,9 @@ are we running in non-root mode?
****************************************************************************/
BOOL non_root_mode(void)
{
+ if (!sec_initialise)
+ smb_panic("non_root_mode() called before sec_init()\n");
+
return (initial_uid != (uid_t)0);
}