forked from lix-project/lix
* Remove SwitchToOriginalUser, we're not going to need it anymore.
This commit is contained in:
parent
626f8ee42f
commit
9c9cdb06d0
|
@ -358,8 +358,6 @@ static Expr parse(EvalState & state,
|
|||
|
||||
Expr parseExprFromFile(EvalState & state, Path path)
|
||||
{
|
||||
SwitchToOriginalUser sw;
|
||||
|
||||
assert(path[0] == '/');
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -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(realRoot, gcRoot, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -207,10 +207,7 @@ void copyPath(const Path & src, const Path & dst)
|
|||
files. */
|
||||
|
||||
CopySink sink;
|
||||
{
|
||||
SwitchToOriginalUser sw;
|
||||
dumpPath(src, sink);
|
||||
}
|
||||
|
||||
CopySource source(sink.s);
|
||||
restorePath(dst, source);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -250,12 +250,6 @@ bool string2Int(const string & s, int & n);
|
|||
|
||||
|
||||
/* Setuid support. */
|
||||
struct SwitchToOriginalUser
|
||||
{
|
||||
SwitchToOriginalUser();
|
||||
~SwitchToOriginalUser();
|
||||
};
|
||||
|
||||
void switchToNixUser();
|
||||
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue