about summary refs log tree commit diff
path: root/src/nix-env/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-env/main.cc')
-rw-r--r--src/nix-env/main.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index 3700f44899b9..14aa13b866bc 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -600,6 +600,7 @@ static void opSwitchProfile(Globals & globals,
     Path profile = opArgs.front();
     Path profileLink = getHomeDir() + "/.nix-profile";
 
+    SwitchToOriginalUser sw;
     switchLink(profileLink, profile);
 }
 
@@ -698,6 +699,7 @@ static void opDefaultExpr(Globals & globals,
     Path defNixExpr = absPath(opArgs.front());
     Path defNixExprLink = getDefNixExprPath();
     
+    SwitchToOriginalUser sw;
     switchLink(defNixExprLink, defNixExpr);
 }
 
@@ -772,6 +774,7 @@ void run(Strings args)
     if (!op) throw UsageError("no operation specified");
 
     if (globals.profile == "") {
+        SwitchToOriginalUser sw;
         Path profileLink = getHomeDir() + "/.nix-profile";
         globals.profile = pathExists(profileLink)
             ? absPath(readLink(profileLink), dirOf(profileLink))