From 6cdaa858d03b9c24f54f8157026cebaa02d9ac8a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 21 Nov 2017 18:50:56 +0100 Subject: Propagate flags like --sandbox to the daemon properly --- src/libstore/globals.cc | 6 +++--- src/libutil/config.cc | 6 +++--- src/libutil/config.hh | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 4fa02f920..d3c96ddd6 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -116,17 +116,17 @@ template<> void BaseSetting::convertToArg(Args & args, const std::s args.mkFlag() .longName(name) .description("Enable sandboxing.") - .handler([=](std::vector ss) { value = smEnabled; }) + .handler([=](std::vector ss) { override(smEnabled); }) .category(category); args.mkFlag() .longName("no-" + name) .description("Disable sandboxing.") - .handler([=](std::vector ss) { value = smDisabled; }) + .handler([=](std::vector ss) { override(smDisabled); }) .category(category); args.mkFlag() .longName("relaxed-" + name) .description("Enable sandboxing, but allow builds to disable it.") - .handler([=](std::vector ss) { value = smRelaxed; }) + .handler([=](std::vector ss) { override(smRelaxed); }) .category(category); } diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 14c4cca03..d46ca65a3 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -152,7 +152,7 @@ void BaseSetting::convertToArg(Args & args, const std::string & category) .longName(name) .description(description) .arity(1) - .handler([=](std::vector ss) { set(ss[0]); }) + .handler([=](std::vector ss) { overriden = true; set(ss[0]); }) .category(category); } @@ -201,12 +201,12 @@ template<> void BaseSetting::convertToArg(Args & args, const std::string & args.mkFlag() .longName(name) .description(description) - .handler([=](std::vector ss) { value = true; }) + .handler([=](std::vector ss) { override(true); }) .category(category); args.mkFlag() .longName("no-" + name) .description(description) - .handler([=](std::vector ss) { value = false; }) + .handler([=](std::vector ss) { override(false); }) .category(category); } diff --git a/src/libutil/config.hh b/src/libutil/config.hh index 99850c1cd..9a32af528 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; -- cgit v1.2.3