Restore the profiling data shmem parinoia. This whole area needs to be
authorAndrew Bartlett <abartlet@samba.org>
Sat, 15 Sep 2001 02:10:22 +0000 (02:10 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 15 Sep 2001 02:10:22 +0000 (02:10 +0000)
fixed - an mmaped file or the like would be a good idea.
(This used to be commit bc1385fc5e55eeed626615fad92877296064a27e)

source3/lib/util_sec.c
source3/profile/profile.c

index 985b07f421d909fa21f52a065611f27cd722d70d..231f0b178da664dda219ac5b13907fd0c08a4632 100644 (file)
@@ -48,6 +48,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 +57,7 @@ as non-root while catching trapdoor systems
 void sec_init(void)
 {
        initial_uid = geteuid();
+       initial_gid = getegid();
 }
 
 /****************************************************************************
@@ -66,6 +68,14 @@ 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;
+}
+
 /****************************************************************************
 are we running in non-root mode?
 ****************************************************************************/
index 430732c6f86c09d178aeec7de5bfe50aa0b281a4..5ddc72c490c788e06e5f56fe01f9508e58348437 100644 (file)
@@ -130,12 +130,10 @@ BOOL profile_setup(BOOL rdonly)
                return False;
        }
 
-#if 0
-       if (shm_ds.shm_perm.cuid != 0 || shm_ds.shm_perm.cgid != 0) {
-               DEBUG(0,("ERROR: root did not create the shmem\n"));
+       if (shm_ds.shm_perm.cuid != sec_initial_uid() || shm_ds.shm_perm.cgid != sec_initial_gid()) {
+               DEBUG(0,("ERROR: we did not create the shmem (owned by another user)\n"));
                return False;
        }
-#endif
 
        if (shm_ds.shm_segsz != sizeof(*profile_h)) {
                DEBUG(0,("WARNING: profile size is %d (expected %d). Deleting\n",