added Vector_zeroEnd() function
[util-vserver.git] / util-vserver / src / chcontext.c
index 69dde7f..4da51d9 100644 (file)
@@ -40,6 +40,7 @@
 #include <assert.h>
 #include <fcntl.h>
 #include <libgen.h>
+#include <signal.h>
 
 #define ENSC_WRAPPERS_PREFIX   "chcontext: "
 #define ENSC_WRAPPERS_VSERVER  1
@@ -66,6 +67,7 @@ CMDLINE_OPTIONS[] = {
   { "version",  no_argument,  0, CMD_VERSION },
   { "cap",        required_argument,  0, CMD_CAP },
   { "ctx",        required_argument,  0, CMD_CTX },
+  { "xid",        required_argument,  0, CMD_CTX },
   { "disconnect", no_argument,        0, CMD_DISCONNECT },
   { "domainname", required_argument,  0, CMD_DOMAINNAME },
   { "flag",       required_argument,  0, CMD_FLAG },
@@ -97,7 +99,7 @@ showHelp(int fd, char const *cmd, int res)
   WRITE_MSG(fd, "Usage: ");
   WRITE_STR(fd, cmd);
   WRITE_MSG(fd,
-           " [--cap [!]<cap_name>] [--secure] [--ctx <num>] [--disconnect]\n"
+           " [--cap [!]<cap_name>] [--secure] [--xid <num>] [--disconnect]\n"
            "       [--domainname <name>] [--hostname <name>] [--flag <flags>+]\n"
            "       [--silent] [--] command arguments ...\n"
            "\n"
@@ -119,12 +121,12 @@ showHelp(int fd, char const *cmd, int res)
            "    repeated several time.\n"
            "    See /usr/include/linux/capability.h\n"
            "\n"
-           "--ctx num\n"
+           "--xid num\n"
            "    Select the context. On root in context 0 is allowed to\n"
            "    select a specific context.\n"
            "    Context number 1 is special. It can see all processes\n"
            "    in any contexts, but can't kill them though.\n"
-           "    Option --ctx may be repeated several times to specify up to 16 contexts.\n"
+           "    Option --xid may be repeated several times to specify up to 16 contexts.\n"
 
            "--disconnect\n"
            "    Start the command in background and make the process\n"
@@ -205,7 +207,7 @@ setFlags(char const *str, uint32_t *flags)
 {
   struct vc_err_listparser     err;
   
-  *flags = vc_list2flag_compat(str, 0, &err);
+  *flags = vc_list2cflag_compat(str, 0, &err);
 
   if (err.ptr!=0) {
     WRITE_MSG(2, "Unknown flag '");
@@ -282,7 +284,8 @@ int main (int argc, char *argv[])
   pid_t                pid;
   
   global_args = &args;
-  
+  signal(SIGCHLD, SIG_DFL);
+
   while (1) {
     int                c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
     if (c==-1) break;
@@ -299,7 +302,7 @@ int main (int argc, char *argv[])
        setCap(optarg, &args.add_caps, &args.remove_caps);
        break;
       case CMD_SECURE          :
-       args.remove_caps |= vc_get_securecaps();
+       args.remove_caps |= vc_get_insecurebcaps();
        break;
       case CMD_FLAG            :
        setFlags(optarg, &args.flags);
@@ -311,7 +314,7 @@ int main (int argc, char *argv[])
          WRITE_MSG(2, "Too many contexts given\n");
          exit(255);
        }
-       args.ctxs[args.nbctx++] = atoi(optarg);
+       args.ctxs[args.nbctx++] = Evc_xidopt2xid(optarg, true);
        break;