backported from HEAD:
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Wed, 7 Jan 2004 16:24:01 +0000 (16:24 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Wed, 7 Jan 2004 16:24:01 +0000 (16:24 +0000)
* removed obsolete and unused 'fakeinit' variable
* fixed ctx-creation with fakeinit and static ctx-id's; fakeinit
  requires a second call for ctx -2 to take effect

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/branches/SYSCALL_SWITCH@557 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/src/chcontext.c

index 5e4fc1b..13b044d 100644 (file)
@@ -117,7 +117,6 @@ int main (int argc, char *argv[])
        int nbctx = 0;
        int ctxs[16];
        int disconnect = 0;
-       int fakeinit = 0;
        int silent = 0;
        int flags = 0;
        unsigned remove_cap = 0;
@@ -164,7 +163,6 @@ int main (int argc, char *argv[])
                        }else if (strcmp(opt,"private")==0){
                                flags |= 8;
                        }else if (strcmp(opt,"fakeinit")==0){
-                               fakeinit = 1;
                                flags |= 16;
                        }else if (strcmp(opt,"hideinfo")==0){
                                flags |= 32;
@@ -257,8 +255,10 @@ int main (int argc, char *argv[])
                */
                if (disconnect == 0 || fork()==0){
                        int newctx;
+                       int xflags = flags & 16;
+
                        if (nbctx == 0) ctxs[nbctx++] = -1;
-                       newctx = vc_new_s_context(ctxs[0],0,flags);
+                       newctx = vc_new_s_context(ctxs[0],0,flags&~16);
                        if (newctx != -1){
                                if (hostname != NULL){
                                        if (sethostname (hostname,strlen(hostname))==-1){
@@ -275,7 +275,8 @@ int main (int argc, char *argv[])
                                        }
                                }
                                remove_cap &= (~add_cap);
-                               if (remove_cap != 0) vc_new_s_context (-2,remove_cap,0);
+                               if (remove_cap!=0 || xflags!=0)
+                                       vc_new_s_context (-2,remove_cap,xflags);
                                if (!silent){
                                        printf ("New security context is %d\n"
                                                ,ctxs[0] == -1 ? newctx : ctxs[0]);