about summary refs log tree commit diff
path: root/src/nix-env
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-09-09T21·12+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-09-09T21·12+0000
commit47f87072ad42338a9b6397a250abf2775d051d8e (patch)
tree6b90037f189ae2b2c750c5c4286b55ef866278d1 /src/nix-env
parent5396304c73190c6898981caf653fc1b28be71f70 (diff)
* A very dirty hack to make setuid installations a bit nicer to use.
  Previously there was the problem that all files read by nix-env
  etc. should be reachable and readable by the Nix user.  So for
  instance building a Nix expression in your home directory meant that
  the home directory should have at least g+x or o+x permission so
  that the Nix user could reach the Nix expression.  Now we just
  switch back to the original user just prior to reading sources and
  the like.  The places where this happens are somewhat arbitrary,
  however.  Any scope that has a live SwitchToOriginalUser object in
  it is executed as the original user.

* Back out r1385.  setreuid() sets the saved uid to the new
  real/effective uid, which prevents us from switching back to the
  original uid.  setresuid() doesn't have this problem (although the
  manpage has a bug: specifying -1 for the saved uid doesn't leave it
  unchanged; an explicit value must be specified).

Diffstat (limited to 'src/nix-env')
-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))