cmdline: implement --really_quiet option
authorRobert Swiecki <robert@swiecki.net>
Sat, 7 Oct 2017 00:03:51 +0000 (02:03 +0200)
committerRobert Swiecki <robert@swiecki.net>
Sat, 7 Oct 2017 00:03:51 +0000 (02:03 +0200)
cmdline.c
config.cc

index b1498cd8ca3e8ea28d3e70cd90069c7e0f760218..fde5e7f3fae9feb87b8c0d04924cdb9f352deef1 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -79,7 +79,8 @@ struct custom_option custom_opts[] = {
     { { "max_cpus", required_argument, NULL, 0x508 }, "Maximum number of CPUs a single jailed process can use (default: 0 'no limit')" },
     { { "daemon", no_argument, NULL, 'd' }, "Daemonize after start" },
     { { "verbose", no_argument, NULL, 'v' }, "Verbose output" },
-    { { "quiet", no_argument, NULL, 'q' }, "Only output warning and more important messages" },
+    { { "quiet", no_argument, NULL, 'q' }, "Log warning and more important messages only" },
+    { { "really_quiet", no_argument, NULL, 'Q' }, "Log fatal messages only" },
     { { "keep_env", no_argument, NULL, 'e' }, "Should all environment variables be passed to the child?" },
     { { "env", required_argument, NULL, 'E' }, "Additional environment variable (can be used multiple times)" },
     { { "keep_caps", no_argument, NULL, 0x0501 }, "Don't drop capabilities" },
@@ -398,7 +399,7 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
        int opt_index = 0;
        for (;;) {
                int c = getopt_long(argc, argv,
-                                   "x:H:D:C:c:p:i:u:g:l:L:t:M:Ndvqeh?E:R:B:T:P:I:U:G:", opts,
+                                   "x:H:D:C:c:p:i:u:g:l:L:t:M:NdvqQeh?E:R:B:T:P:I:U:G:", opts,
                                    &opt_index);
                if (c == -1) {
                        break;
@@ -458,6 +459,12 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
                                return false;
                        }
                        break;
+               case 'Q':
+                       nsjconf->loglevel = FATAL;
+                       if (logInitLogFile(nsjconf) == false) {
+                               return false;
+                       }
+                       break;
                case 'e':
                        nsjconf->keep_env = true;
                        break;
index 78f57488c55c2cfa99cbbb553d3254a77cbe7489..ab600b98c27b63f06274fb4e4f948554784970b3 100644 (file)
--- a/config.cc
+++ b/config.cc
@@ -307,10 +307,10 @@ extern "C" bool configParse(struct nsjconf_t* nsjconf, const char* file)
     google::protobuf::io::FileInputStream input(fd);
     input.SetCloseOnDelete(true);
 
+    /* Use static so we can get c_str() pointers, and copy them into the nsjconf struct */
     static nsjail::NsJailConfig nsc;
 
     auto parser = google::protobuf::TextFormat::Parser();
-
     if (!parser.Parse(&input, &nsc)) {
         LOG_W("Couldn't parse file '%s' from Text into ProtoBuf", file);
         return false;