Using -c is consistent with mo-box.
Redirect standard error output to 'file'. The 'file' has to be accessible
inside the sandbox.
Redirect standard error output to 'file'. The 'file' has to be accessible
inside the sandbox.
+*-c, --chdir=*'dir'::
+ Change directory to 'dir' before executing the program. This path must be
+ relative to the root of the sandbox.
+
*-p, --processes*[*=*'max']::
Permit the program to create up to 'max' processes and/or threads. Please
keep in mind that time and memory limit do not work with multiple processes
*-p, --processes*[*=*'max']::
Permit the program to create up to 'max' processes and/or threads. Please
keep in mind that time and memory limit do not work with multiple processes
that this feature needs special system setup described in the REQUIREMENTS
section.
that this feature needs special system setup described in the REQUIREMENTS
section.
Enable use of control groups.
*--cg-mem=*'size'::
Enable use of control groups.
*--cg-mem=*'size'::
static int inode_quota;
static int max_processes = 1;
static char *redir_stdin, *redir_stdout, *redir_stderr;
static int inode_quota;
static int max_processes = 1;
static char *redir_stdin, *redir_stdout, *redir_stderr;
static int cg_enable;
static int cg_memory_limit;
static int cg_enable;
static int cg_memory_limit;
setup_rlimits();
char **env = setup_environment();
setup_rlimits();
char **env = setup_environment();
+ if (set_cwd && chdir(set_cwd))
+ die("chdir: %m");
+
execve(args[0], args, env);
die("execve(\"%s\"): %m", args[0]);
}
execve(args[0], args, env);
die("execve(\"%s\"): %m", args[0]);
}
OPT_RUN,
OPT_CLEANUP,
OPT_VERSION,
OPT_RUN,
OPT_CLEANUP,
OPT_VERSION,
OPT_CG_MEM,
OPT_CG_TIMING,
};
OPT_CG_MEM,
OPT_CG_TIMING,
};
static const struct option long_opts[] = {
{ "box-id", 1, NULL, 'b' },
static const struct option long_opts[] = {
{ "box-id", 1, NULL, 'b' },
- { "cg", 1, NULL, 'c' },
+ { "chdir", 1, NULL, 'c' },
+ { "cg", 0, NULL, OPT_CG },
{ "cg-mem", 1, NULL, OPT_CG_MEM },
{ "cg-timing", 0, NULL, OPT_CG_TIMING },
{ "cleanup", 0, NULL, OPT_CLEANUP },
{ "cg-mem", 1, NULL, OPT_CG_MEM },
{ "cg-timing", 0, NULL, OPT_CG_TIMING },
{ "cleanup", 0, NULL, OPT_CLEANUP },
box_id = atoi(optarg);
break;
case 'c':
box_id = atoi(optarg);
break;
case 'c':
+ set_cwd = optarg;
+ break;
+ case OPT_CG:
cg_enable = 1;
break;
case 'd':
cg_enable = 1;
break;
case 'd':