Move some options out of globals
This commit is contained in:
parent
3190951563
commit
e9070bf422
|
@ -57,8 +57,6 @@ Settings::Settings()
|
||||||
lockCPU = getEnv("NIX_AFFINITY_HACK", "1") == "1";
|
lockCPU = getEnv("NIX_AFFINITY_HACK", "1") == "1";
|
||||||
showTrace = false;
|
showTrace = false;
|
||||||
enableImportNative = 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()
|
void Settings::update()
|
||||||
{
|
{
|
||||||
_get(tryFallback, "build-fallback");
|
_get(tryFallback, "build-fallback");
|
||||||
|
@ -147,8 +161,6 @@ void Settings::update()
|
||||||
_get(logServers, "log-servers");
|
_get(logServers, "log-servers");
|
||||||
_get(enableImportNative, "allow-unsafe-native-code-during-evaluation");
|
_get(enableImportNative, "allow-unsafe-native-code-during-evaluation");
|
||||||
_get(useCaseHack, "use-case-hack");
|
_get(useCaseHack, "use-case-hack");
|
||||||
_get(trustedUsers, "trusted-users");
|
|
||||||
_get(allowedUsers, "allowed-users");
|
|
||||||
|
|
||||||
string subs = getEnv("NIX_SUBSTITUTERS", "default");
|
string subs = getEnv("NIX_SUBSTITUTERS", "default");
|
||||||
if (subs == "default") {
|
if (subs == "default") {
|
||||||
|
|
|
@ -21,6 +21,10 @@ struct Settings {
|
||||||
|
|
||||||
void set(const string & name, const string & value);
|
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();
|
void update();
|
||||||
|
|
||||||
string pack();
|
string pack();
|
||||||
|
|
|
@ -882,6 +882,9 @@ static void daemonLoop()
|
||||||
struct group * gr = getgrgid(cred.gid);
|
struct group * gr = getgrgid(cred.gid);
|
||||||
string group = gr ? gr->gr_name : int2String(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))
|
if (matchUser(user, group, settings.trustedUsers))
|
||||||
trusted = true;
|
trusted = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue