nix/daemon: remove settings copy from parent

the parent daemon does not change any settings before starting a child,
so there's nothing we may want to change that is not already set by the
config file. this also doesn't prevent changes of the config file being
applied to daemons where we do not expect it since it'll only restore a
setting to the parents' value if the child also has an override for it.

Change-Id: Ic5a9ef13458c103ec9979cb187ba8d3ce5e1e719
This commit is contained in:
eldritch horrors
2025-12-07 18:49:34 +00:00
parent 400b55a410
commit 1e8f7c7c76
+1 -33
View File
@@ -55,7 +55,6 @@
#endif
static constexpr int SUBDAEMON_CONNECTION_FD = 0;
static constexpr int SUBDAEMON_SETTINGS_FD = 3;
namespace nix {
@@ -346,9 +345,6 @@ try {
peer.pidKnown ? fmt("pid %1%", peer.pid) : "unknown peer"
);
Pipe settings;
settings.create();
// Fork a child to handle the connection. make sure it's called with
// argv0 `nix-daemon` so we don't try to run `nix --for` when called
// from more modern scripts that assume nix-command being available.
@@ -363,11 +359,7 @@ try {
fmt("%1%", int(verbosity)),
},
.dieWithParent = false,
.redirections =
{
{.dup = SUBDAEMON_CONNECTION_FD, .from = remote.get()},
{.dup = SUBDAEMON_SETTINGS_FD, .from = settings.readSide.get()},
}
.redirections = {{.dup = SUBDAEMON_CONNECTION_FD, .from = remote.get()}}
};
if (forceTrustClientOpt) {
options.args.push_back(
@@ -375,15 +367,6 @@ try {
);
}
runProgram2(options).release();
FdSink sink(settings.writeSide.get());
std::map<std::string, Config::SettingInfo> overriddenSettings;
globalConfig.getSettings(overriddenSettings, true);
for (auto & setting : overriddenSettings) {
sink << 1 << setting.first << setting.second.value;
}
sink << 0;
sink.flush();
} catch (Error & error) {
auto ei = error.info();
// FIXME: add to trace?
@@ -417,21 +400,6 @@ static void daemonInstance(AsyncIoRoot & aio, std::optional<TrustedFlag> forceTr
forceTrustClientOpt ? " by override" : ""
);
{
FdSource source(SUBDAEMON_SETTINGS_FD);
/* Read the parent's settings. */
while (readNum<unsigned>(source)) {
auto name = readString(source);
auto value = readString(source);
settings.set(name, value);
}
if (close(SUBDAEMON_SETTINGS_FD) < 0) {
throw SysError("preparing subdaemon connection");
}
}
// Background the daemon.
if (setsid() == -1) {
throw SysError("creating a new session");