#include <assert.h>
#include <fcntl.h>
#include <libgen.h>
+#include <signal.h>
#define ENSC_WRAPPERS_PREFIX "chcontext: "
#define ENSC_WRAPPERS_VSERVER 1
{ "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 },
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"
" 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"
{
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 '");
- write(2, err.ptr, err.len);
+ Vwrite(2, err.ptr, err.len);
WRITE_MSG(2, "'\n");
exit(wrapper_exit_code);
}
l = utilvserver_fmt_long(buf,ctx);
WRITE_MSG(1, "New security context is ");
- write(1, buf, l);
+ Vwrite(1, buf, l);
WRITE_MSG(1, "\n");
}
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;
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);
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;