Initialize nsjconf structure in the commandline module:
authorRobert Swiecki <swiecki@google.com>
Wed, 17 Jun 2015 14:52:51 +0000 (16:52 +0200)
committerRobert Swiecki <swiecki@google.com>
Wed, 17 Jun 2015 14:52:51 +0000 (16:52 +0200)
cmdline.c
nsjail.c

index 8bfaca71bb3608617ea4ba6bb88792a1fbf6a3de..2905775e45244e4fe511de8c3ef6e3769f03edba 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -141,6 +141,45 @@ rlim_t cmdlineParseRLimit(int res, const char *optarg, unsigned long mul)
 
 bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
 {
+       /*  *INDENT-OFF* */
+       (*nsjconf) = (struct nsjconf_t) {
+               .hostname = "NSJAIL",
+               .chroot = "/chroot",
+               .argv = NULL,
+               .port = 31337,
+               .uid = -1,
+               .gid = -1,
+               .daemonize = false,
+               .tlimit = 0,
+               .apply_sandbox = true,
+               .verbose = false,
+               .keep_caps = false,
+               .rl_as = 512 * (1024 * 1024),
+               .rl_core = 0,
+               .rl_cpu = 600,
+               .rl_fsize = 1 * (1024 * 1024),
+               .rl_nofile = 32,
+               .rl_nproc = cmdlineParseRLimit(RLIMIT_NPROC, "def", 1),
+               .rl_stack = cmdlineParseRLimit(RLIMIT_STACK, "def", 1),
+               .personality = 0,
+               .clone_newnet = true,
+               .clone_newuser = true,
+               .clone_newns = true,
+               .clone_newpid = true,
+               .clone_newipc = true,
+               .clone_newuts = true,
+               .mode = MODE_LISTEN_TCP,
+               .is_root_rw = false,
+               .is_silent = false,
+               .bindmountpts = NULL,
+               .tmpfsmountpts = NULL,
+               .iface = NULL,
+               .initial_uid = getuid(),
+               .initial_gid = getgid(),
+               .max_conns_per_ip = 0,
+       };
+       /*  *INDENT-OFF* */
+
        LIST_INIT(&nsjconf->pids);
        const char *user = "nobody";
        const char *group = "nobody";
index 5a7d1e80c1cc010c8bb184ea19a8782615d9915e..42fb6ce82404e3fcb205f8ca22858d83e00319f1 100644 (file)
--- a/nsjail.c
+++ b/nsjail.c
@@ -156,43 +156,7 @@ static void nsjailStandaloneMode(struct nsjconf_t *nsjconf)
 
 int main(int argc, char *argv[])
 {
-       struct nsjconf_t nsjconf = {
-               .hostname = "NSJAIL",
-               .chroot = "/chroot",
-               .argv = NULL,
-               .port = 31337,
-               .uid = -1,
-               .gid = -1,
-               .daemonize = false,
-               .tlimit = 0,
-               .apply_sandbox = true,
-               .verbose = false,
-               .keep_caps = false,
-               .rl_as = 512 * (1024 * 1024),
-               .rl_core = 0,
-               .rl_cpu = 600,
-               .rl_fsize = 1 * (1024 * 1024),
-               .rl_nofile = 32,
-               .rl_nproc = cmdlineParseRLimit(RLIMIT_NPROC, "def", 1),
-               .rl_stack = cmdlineParseRLimit(RLIMIT_STACK, "def", 1),
-               .personality = 0,
-               .clone_newnet = true,
-               .clone_newuser = true,
-               .clone_newns = true,
-               .clone_newpid = true,
-               .clone_newipc = true,
-               .clone_newuts = true,
-               .mode = MODE_LISTEN_TCP,
-               .is_root_rw = false,
-               .is_silent = false,
-               .bindmountpts = NULL,
-               .tmpfsmountpts = NULL,
-               .iface = NULL,
-               .initial_uid = getuid(),
-               .initial_gid = getgid(),
-               .max_conns_per_ip = 0,
-       };
-
+       struct nsjconf_t nsjconf;
        if (!cmdlineParse(argc, argv, &nsjconf)) {
                exit(1);
        }