Author: jra
Date: 2007-06-08 19:52:18 +0000 (Fri, 08 Jun 2007)
New Revision: 23390

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23390

Log:
First part of the patch to make Apple's life easier.
Doing this in two stages to make it very easy to
review. Context switching must look like :

gain_root();
sys_setgroups(ngroups, groups);
become_id(uid, gid);

Re-arrange order so these three calls are always
seen together.

Next will be to turn these into a function.

Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/sec_ctx.c
   branches/SAMBA_3_0_26/source/smbd/sec_ctx.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/sec_ctx.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/sec_ctx.c    2007-06-08 14:37:29 UTC (rev 
23389)
+++ branches/SAMBA_3_0/source/smbd/sec_ctx.c    2007-06-08 19:52:18 UTC (rev 
23390)
@@ -243,11 +243,13 @@
        debug_nt_user_token(DBGC_CLASS, 5, token);
        debug_unix_user_token(DBGC_CLASS, 5, uid, gid, ngroups, groups);
 
+       /* Start context switch */
        gain_root();
-
 #ifdef HAVE_SETGROUPS
        sys_setgroups(ngroups, groups);
 #endif
+       become_id(uid, gid);
+       /* end context switch */
 
        ctx_p->ut.ngroups = ngroups;
 
@@ -277,8 +279,6 @@
                ctx_p->token = NULL;
        }
 
-       become_id(uid, gid);
-
        ctx_p->ut.uid = uid;
        ctx_p->ut.gid = gid;
 
@@ -334,15 +334,15 @@
 
        sec_ctx_stack_ndx--;
 
-       gain_root();
-
        prev_ctx_p = &sec_ctx_stack[sec_ctx_stack_ndx];
 
+       /* Start context switch */
+       gain_root();
 #ifdef HAVE_SETGROUPS
        sys_setgroups(prev_ctx_p->ut.ngroups, prev_ctx_p->ut.groups);
 #endif
-
        become_id(prev_ctx_p->ut.uid, prev_ctx_p->ut.gid);
+       /* end context switch */
 
        /* Update current_user stuff */
 

Modified: branches/SAMBA_3_0_26/source/smbd/sec_ctx.c
===================================================================
--- branches/SAMBA_3_0_26/source/smbd/sec_ctx.c 2007-06-08 14:37:29 UTC (rev 
23389)
+++ branches/SAMBA_3_0_26/source/smbd/sec_ctx.c 2007-06-08 19:52:18 UTC (rev 
23390)
@@ -243,11 +243,13 @@
        debug_nt_user_token(DBGC_CLASS, 5, token);
        debug_unix_user_token(DBGC_CLASS, 5, uid, gid, ngroups, groups);
 
+       /* Start context switch */
        gain_root();
-
 #ifdef HAVE_SETGROUPS
        sys_setgroups(ngroups, groups);
 #endif
+       become_id(uid, gid);
+       /* end context switch */
 
        ctx_p->ut.ngroups = ngroups;
 
@@ -277,8 +279,6 @@
                ctx_p->token = NULL;
        }
 
-       become_id(uid, gid);
-
        ctx_p->ut.uid = uid;
        ctx_p->ut.gid = gid;
 
@@ -334,15 +334,15 @@
 
        sec_ctx_stack_ndx--;
 
-       gain_root();
-
        prev_ctx_p = &sec_ctx_stack[sec_ctx_stack_ndx];
 
+       /* Start context switch */
+       gain_root();
 #ifdef HAVE_SETGROUPS
        sys_setgroups(prev_ctx_p->ut.ngroups, prev_ctx_p->ut.groups);
 #endif
-
        become_id(prev_ctx_p->ut.uid, prev_ctx_p->ut.gid);
+       /* end context switch */
 
        /* Update current_user stuff */
 

Reply via email to