From 37b56574e20755e4c58370bb18a3d373d4ae7cfc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 23 Jan 2013 11:51:58 +0100 Subject: [PATCH] stage-1: Clear environment before calling stage-2 In particular, stage-1's LD_LIBRARY_PATH should not infect stage-2. Reported by viric. --- modules/system/boot/stage-1-init.sh | 2 +- modules/system/boot/systemd.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/system/boot/stage-1-init.sh b/modules/system/boot/stage-1-init.sh index 9bcbe291aad5..3f34a1ae6a54 100644 --- a/modules/system/boot/stage-1-init.sh +++ b/modules/system/boot/stage-1-init.sh @@ -365,6 +365,6 @@ mount --move /sys $targetRoot/sys mount --move /dev $targetRoot/dev mount --move /run $targetRoot/run -exec switch_root "$targetRoot" "$stage2Init" +exec env -i $(type -P switch_root) "$targetRoot" "$stage2Init" fail # should never be reached diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index d33409880922..4024838555de 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -224,6 +224,7 @@ let [Service] Environment=PATH=${def.path} + Environment=LD_LIBRARY_PATH= ${let env = cfg.globalEnvironment // def.environment; in concatMapStrings (n: "Environment=${n}=${getAttr n env}\n") (attrNames env)} ${optionalString (!def.restartIfChanged) "X-RestartIfChanged=false"}