convert proc_path to std::string
authorRobert Swiecki <robert@swiecki.net>
Sat, 10 Feb 2018 19:16:17 +0000 (20:16 +0100)
committerRobert Swiecki <robert@swiecki.net>
Sat, 10 Feb 2018 19:16:17 +0000 (20:16 +0100)
cmdline.cc
config.cc
nsjail.h

index b927312bd0589b8d4cc2137561d78a3feedd8490..90923b806b0e3fcb655a76c60ab9377ab65a49e6 100644 (file)
@@ -359,7 +359,6 @@ std::unique_ptr<nsjconf_t> parseArgs(int argc, char* argv[]) {
        nsjconf->skip_setsid = false;
        nsjconf->max_conns_per_ip = 0;
        nsjconf->tmpfs_size = 4 * (1024 * 1024);
-       nsjconf->mount_proc = true;
        nsjconf->proc_path = "/proc";
        nsjconf->is_proc_rw = false;
        nsjconf->cgroup_mem_mount = "/sys/fs/cgroup/memory";
@@ -559,7 +558,7 @@ std::unique_ptr<nsjconf_t> parseArgs(int argc, char* argv[]) {
                            nsjconf->tmpfs_size);
                        break;
                case 0x0603:
-                       nsjconf->mount_proc = false;
+                       nsjconf->proc_path.clear();
                        break;
                case 0x0605:
                        nsjconf->proc_path = optarg;
@@ -748,9 +747,10 @@ std::unique_ptr<nsjconf_t> parseArgs(int argc, char* argv[]) {
                return nullptr;
        }
 
-       if (nsjconf->mount_proc) {
-               if (!mnt::addMountPtTail(nsjconf.get(), /* src= */ NULL, nsjconf->proc_path, "proc",
-                       "", nsjconf->is_proc_rw ? 0 : MS_RDONLY, /* isDir= */ mnt::NS_DIR_YES,
+       if (!nsjconf->proc_path.empty()) {
+               if (!mnt::addMountPtTail(nsjconf.get(), /* src= */ NULL, nsjconf->proc_path.c_str(),
+                       "proc", "", nsjconf->is_proc_rw ? 0 : MS_RDONLY,
+                       /* isDir= */ mnt::NS_DIR_YES,
                        /* mandatory= */ true, NULL, NULL, NULL, 0, /* is_symlink= */ false)) {
                        return nullptr;
                }
index eb7ac7a647c67e5f4fb059c01804d503db78226a..1b565db1d08d776f682bf85ffe90a5a375c2c3c1 100644 (file)
--- a/config.cc
+++ b/config.cc
@@ -200,7 +200,9 @@ static bool configParseInternal(nsjconf_t* nsjconf, const nsjail::NsJailConfig&
                }
        }
 
-       nsjconf->mount_proc = njc.mount_proc();
+       if (!njc.mount_proc()) {
+               nsjconf->proc_path.clear();
+       }
        for (ssize_t i = 0; i < njc.mount_size(); i++) {
                const char* src = (njc.mount(i).has_src()) ? njc.mount(i).src().c_str() : NULL;
                const char* src_env = (njc.mount(i).has_prefix_src_env())
index ebe3359760b98de43ca1e5343a3165bc2dc09274..cc40153ac7f41ceded196da6bd3b1ddf447d0904 100644 (file)
--- a/nsjail.h
+++ b/nsjail.h
@@ -120,8 +120,7 @@ struct nsjconf_t {
        bool skip_setsid;
        unsigned int max_conns_per_ip;
        size_t tmpfs_size;
-       bool mount_proc;
-       const char* proc_path;
+       std::string proc_path;
        bool is_proc_rw;
        bool iface_lo;
        std::string iface_vs;