about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-11-21T17·50+0100
committerEelco Dolstra <edolstra@gmail.com>2017-11-21T17·50+0100
commit6cdaa858d03b9c24f54f8157026cebaa02d9ac8a (patch)
treeec968c3d42d81f4154e8dcd2bdbadcdae84f2434
parent7536fe31dd8c162026d517521dc49b5d9286bfb1 (diff)
Propagate flags like --sandbox to the daemon properly
-rw-r--r--src/libstore/globals.cc6
-rw-r--r--src/libutil/config.cc6
-rw-r--r--src/libutil/config.hh6
3 files changed, 12 insertions, 6 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 4fa02f92085a..d3c96ddd6e61 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -116,17 +116,17 @@ template<> void BaseSetting<SandboxMode>::convertToArg(Args & args, const std::s
     args.mkFlag()
         .longName(name)
         .description("Enable sandboxing.")
-        .handler([=](std::vector<std::string> ss) { value = smEnabled; })
+        .handler([=](std::vector<std::string> ss) { override(smEnabled); })
         .category(category);
     args.mkFlag()
         .longName("no-" + name)
         .description("Disable sandboxing.")
-        .handler([=](std::vector<std::string> ss) { value = smDisabled; })
+        .handler([=](std::vector<std::string> ss) { override(smDisabled); })
         .category(category);
     args.mkFlag()
         .longName("relaxed-" + name)
         .description("Enable sandboxing, but allow builds to disable it.")
-        .handler([=](std::vector<std::string> ss) { value = smRelaxed; })
+        .handler([=](std::vector<std::string> ss) { override(smRelaxed); })
         .category(category);
 }
 
diff --git a/src/libutil/config.cc b/src/libutil/config.cc
index 14c4cca031bb..d46ca65a3863 100644
--- a/src/libutil/config.cc
+++ b/src/libutil/config.cc
@@ -152,7 +152,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
         .longName(name)
         .description(description)
         .arity(1)
-        .handler([=](std::vector<std::string> ss) { set(ss[0]); })
+        .handler([=](std::vector<std::string> ss) { overriden = true; set(ss[0]); })
         .category(category);
 }
 
@@ -201,12 +201,12 @@ template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string &
     args.mkFlag()
         .longName(name)
         .description(description)
-        .handler([=](std::vector<std::string> ss) { value = true; })
+        .handler([=](std::vector<std::string> ss) { override(true); })
         .category(category);
     args.mkFlag()
         .longName("no-" + name)
         .description(description)
-        .handler([=](std::vector<std::string> ss) { value = false; })
+        .handler([=](std::vector<std::string> ss) { override(false); })
         .category(category);
 }
 
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index 99850c1cdfd5..9a32af528ec7 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -142,6 +142,12 @@ public:
 
     void set(const std::string & str) override;
 
+    virtual void override(const T & v)
+    {
+        overriden = true;
+        value = v;
+    }
+
     std::string to_string() override;
 
     void convertToArg(Args & args, const std::string & category) override;