"\tr: Immediately launch a single process on the console, keep doing it "
"forever [MODE_STANDALONE_RERUN]"},
{{"config", required_argument, NULL, 'C'}, "Configuration file in the config.proto ProtoBuf format"},
+ {{"exec_file", required_argument, NULL, 'x'}, "File to exec (default: argv[0])"},
{{"chroot", required_argument, NULL, 'c'}, "Directory containing / of the jail (default: none)"},
{{"rw", no_argument, NULL, 0x601}, "Mount / and /proc as RW (default: RO)"},
{{"user", required_argument, NULL, 'u'}, "Username/uid of processess inside the jail (default: your current uid). You can also use inside_ns_uid:outside_ns_uid:count convention here. Can be specified multiple times"},
{
/* *INDENT-OFF* */
(*nsjconf) = (const struct nsjconf_t){
+ .exec_file = NULL,
.hostname = "NSJAIL",
.cwd = "/",
.chroot = NULL,
int opt_index = 0;
for (;;) {
int c = getopt_long(argc, argv,
- "H:D:C:c:p:i:u:g:l:t:M:Ndvqeh?E:R:B:T:P:I:U:G:", opts,
+ "x:H:D:C:c:p:i:u:g:l:t:M:Ndvqeh?E:R:B:T:P:I:U:G:", opts,
&opt_index);
if (c == -1) {
break;
}
switch (c) {
+ case 'x':
+ nsjconf->exec_file = optarg;
+ break;
case 'H':
nsjconf->hostname = optarg;
break;
cmdlineUsage(argv[0]);
return false;
}
+ if (nsjconf->exec_file == NULL) {
+ nsjconf->exec_file = nsjconf->argv[0];
+ }
return true;
}
char cs_addr[64];
netConnToText(fd_in, true /* remote */ , cs_addr, sizeof(cs_addr), NULL);
- LOG_I("Executing '%s' for '%s'", nsjconf->argv[0], cs_addr);
+ LOG_I("Executing '%s' for '%s'", nsjconf->exec_file, cs_addr);
for (size_t i = 0; nsjconf->argv[i]; i++) {
LOG_D(" Arg[%zu]: '%s'", i, nsjconf->argv[i]);
if (sandboxApply(nsjconf) == false) {
exit(1);
}
- execv(nsjconf->argv[0], &nsjconf->argv[0]);
+ execv(nsjconf->exec_file, &nsjconf->argv[0]);
- PLOG_E("execve('%s') failed", nsjconf->argv[0]);
+ PLOG_E("execve('%s') failed", nsjconf->exec_file);
_exit(1);
}