[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
88/118: Move some options out of globals
From: |
Ludovic Courtès |
Subject: |
88/118: Move some options out of globals |
Date: |
Tue, 19 May 2015 14:45:53 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit e9070bf4226b225a0b42798b20ea3947abf58a6f
Author: Eelco Dolstra <address@hidden>
Date: Mon Aug 4 18:13:14 2014 +0200
Move some options out of globals
---
nix/libstore/globals.cc | 20 ++++++++++++++++----
nix/libstore/globals.hh | 4 ++++
nix/nix-daemon/nix-daemon.cc | 3 +++
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc
index 9da14dc..1cbe912 100644
--- a/nix/libstore/globals.cc
+++ b/nix/libstore/globals.cc
@@ -57,8 +57,6 @@ Settings::Settings()
lockCPU = getEnv("NIX_AFFINITY_HACK", "1") == "1";
showTrace = false;
enableImportNative = false;
- trustedUsers = Strings({"root"});
- allowedUsers = Strings({"*"});
}
@@ -116,6 +114,22 @@ void Settings::set(const string & name, const string &
value)
}
+string Settings::get(const string & name, const string & def)
+{
+ auto i = settings.find(name);
+ if (i == settings.end()) return def;
+ return i->second;
+}
+
+
+Strings Settings::get(const string & name, const Strings & def)
+{
+ auto i = settings.find(name);
+ if (i == settings.end()) return def;
+ return tokenizeString<Strings>(i->second);
+}
+
+
void Settings::update()
{
_get(tryFallback, "build-fallback");
@@ -147,8 +161,6 @@ void Settings::update()
_get(logServers, "log-servers");
_get(enableImportNative, "allow-unsafe-native-code-during-evaluation");
_get(useCaseHack, "use-case-hack");
- _get(trustedUsers, "trusted-users");
- _get(allowedUsers, "allowed-users");
string subs = getEnv("NIX_SUBSTITUTERS", "default");
if (subs == "default") {
diff --git a/nix/libstore/globals.hh b/nix/libstore/globals.hh
index df113e2..743d206 100644
--- a/nix/libstore/globals.hh
+++ b/nix/libstore/globals.hh
@@ -21,6 +21,10 @@ struct Settings {
void set(const string & name, const string & value);
+ string get(const string & name, const string & def);
+
+ Strings get(const string & name, const Strings & def);
+
void update();
string pack();
diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index dc41cae..422c7f6 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -882,6 +882,9 @@ static void daemonLoop()
struct group * gr = getgrgid(cred.gid);
string group = gr ? gr->gr_name : int2String(cred.gid);
+ Strings trustedUsers = settings.get("trusted-users",
Strings({"root"}));
+ Strings allowedUsers = settings.get("allowed-users",
Strings({"*"}));
+
if (matchUser(user, group, settings.trustedUsers))
trusted = true;
- 67/118: nix-daemon: Add trusted-users and allowed-users options, (continued)
- 67/118: nix-daemon: Add trusted-users and allowed-users options, Ludovic Courtès, 2015/05/19
- 70/118: Better fix for strcasecmp on Darwin, Ludovic Courtès, 2015/05/19
- 75/118: Merge commit 'fdee1ced43fb495d612a29e955141cdf6b9a95ba' into nix, Ludovic Courtès, 2015/05/19
- 74/118: Merge commit '8e9140cfdef9dbd1eb61e4c75c91d452ab5e4a74' into nix, Ludovic Courtès, 2015/05/19
- 73/118: startProcess: Make writing error messages from the child more robust, Ludovic Courtès, 2015/05/19
- 69/118: Bump, Ludovic Courtès, 2015/05/19
- 86/118: Add option ‘build-extra-chroot-dirs’, Ludovic Courtès, 2015/05/19
- 76/118: nix-daemon: Simplify stderr handling, Ludovic Courtès, 2015/05/19
- 77/118: nix-daemon: Less verbosity, Ludovic Courtès, 2015/05/19
- 90/118: Remove unnecessary call to addTempRoot(), Ludovic Courtès, 2015/05/19
- 88/118: Move some options out of globals,
Ludovic Courtès <=
- 83/118: Call commonChildInit() before doing chroot init, Ludovic Courtès, 2015/05/19
- 84/118: Remove ugly hack for detecting build environment setup errors, Ludovic Courtès, 2015/05/19
- 85/118: Get rid of "killing <pid>" message for unused build hooks, Ludovic Courtès, 2015/05/19
- 93/118: Reduce verbosity, Ludovic Courtès, 2015/05/19
- 92/118: Propagate remote timeouts properly, Ludovic Courtès, 2015/05/19
- 87/118: Refactor, Ludovic Courtès, 2015/05/19
- 79/118: Allow regular files as GC roots, Ludovic Courtès, 2015/05/19
- 89/118: Doh, Ludovic Courtès, 2015/05/19
- 78/118: Remove some dead code, Ludovic Courtès, 2015/05/19
- 82/118: Eliminate redundant copy, Ludovic Courtès, 2015/05/19