about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/parser.y2
-rw-r--r--src/libstore/gc.cc5
-rw-r--r--src/libstore/local-store.cc5
-rw-r--r--src/libstore/store-api.cc14
-rw-r--r--src/libutil/util.cc31
-rw-r--r--src/libutil/util.hh6
-rw-r--r--src/nix-env/main.cc3
-rw-r--r--src/nix-store/main.cc1
8 files changed, 4 insertions, 63 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index cc403d437471..8ac3345c1f2e 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -358,8 +358,6 @@ static Expr parse(EvalState & state,
 
 Expr parseExprFromFile(EvalState & state, Path path)
 {
-    SwitchToOriginalUser sw;
-
     assert(path[0] == '/');
 
 #if 0
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 05966ad4b076..3e4150d89811 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -92,10 +92,7 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
         Path realRoot = canonPath((format("%1%/%2%/auto/%3%")
             % nixStateDir % gcRootsDir % hash).str());
         
-        {
-            SwitchToOriginalUser sw;
-            createSymlink(gcRoot, storePath, true);
-        }
+        createSymlink(gcRoot, storePath, true);
         createSymlink(realRoot, gcRoot, false);
     }
 
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 2f2a1b436635..0b8900f2501b 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -207,10 +207,7 @@ void copyPath(const Path & src, const Path & dst)
        files. */ 
 
     CopySink sink;
-    {
-        SwitchToOriginalUser sw;
-        dumpPath(src, sink);
-    }
+    dumpPath(src, sink);
 
     CopySource source(sink.s);
     restorePath(dst, source);
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index a560b3f55b8f..fb86fc6abbb7 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -96,25 +96,15 @@ Path makeFixedOutputPath(bool recursive,
 std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
     bool fixed, bool recursive, string hashAlgo)
 {
-    Hash h(htSHA256);
-    {
-        SwitchToOriginalUser sw;
-        h = hashPath(htSHA256, srcPath);
-    }
+    Hash h = hashPath(htSHA256, srcPath);
 
     string baseName = baseNameOf(srcPath);
 
     Path dstPath;
     
     if (fixed) {
-
         HashType ht(parseHashType(hashAlgo));
-        Hash h2(ht);
-        {
-            SwitchToOriginalUser sw;
-            h2 = recursive ? hashPath(ht, srcPath) : hashFile(ht, srcPath);
-        }
-        
+        Hash h2 = recursive ? hashPath(ht, srcPath) : hashFile(ht, srcPath);
         dstPath = makeFixedOutputPath(recursive, hashAlgo, h2, baseName);
     }
         
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 9727a3173f1a..375e0e1df892 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -909,37 +909,6 @@ static gid_t savedGid, nixGid;
 #endif
 
 
-SwitchToOriginalUser::SwitchToOriginalUser()
-{
-#if HAVE_SETRESUID
-    /* Temporarily switch the effective uid/gid back to the saved
-       uid/gid (which is the uid/gid of the user that executed the Nix
-       program; it's *not* the real uid/gid, since we changed that to
-       the Nix user in switchToNixUser()). */
-    if (haveSwitched) {
-        if (setuid(savedUid) == -1)
-            throw SysError(format("temporarily restoring uid to `%1%'") % savedUid); 
-        if (setgid(savedGid) == -1)
-            throw SysError(format("temporarily restoring gid to `%1%'") % savedGid); 
-    }
-#endif
-}
-
-
-SwitchToOriginalUser::~SwitchToOriginalUser()
-{
-#if HAVE_SETRESUID
-    /* Switch the effective uid/gid back to the Nix user. */
-    if (haveSwitched) {
-        if (setuid(nixUid) == -1)
-            throw SysError(format("restoring uid to `%1%'") % nixUid); 
-        if (setgid(nixGid) == -1)
-            throw SysError(format("restoring gid to `%1%'") % nixGid); 
-    }
-#endif
-}
-
-
 void switchToNixUser()
 {
 #if 0
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 7f3d41e76ef3..d1fb5b6e24f8 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -250,12 +250,6 @@ bool string2Int(const string & s, int & n);
 
 
 /* Setuid support. */
-struct SwitchToOriginalUser
-{
-    SwitchToOriginalUser();
-    ~SwitchToOriginalUser();
-};
-
 void switchToNixUser();
 
  
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index a9f34387079b..4f0b5eca9024 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -943,7 +943,6 @@ static void opSwitchProfile(Globals & globals,
     Path profile = opArgs.front();
     Path profileLink = getHomeDir() + "/.nix-profile";
 
-    SwitchToOriginalUser sw;
     switchLink(profileLink, profile);
 }
 
@@ -1092,7 +1091,6 @@ static void opDefaultExpr(Globals & globals,
     Path defNixExpr = absPath(opArgs.front());
     Path defNixExprLink = getDefNixExprPath();
     
-    SwitchToOriginalUser sw;
     switchLink(defNixExprLink, defNixExpr);
 }
 
@@ -1196,7 +1194,6 @@ 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))
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index ad346c91fc59..eb037bda1913 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -34,7 +34,6 @@ static bool indirectRoot = false;
 
 static Path fixPath(Path path)
 {
-    SwitchToOriginalUser sw;
     path = absPath(path);
     while (!isInStore(path)) {
         if (!isLink(path)) break;