mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
libutil: save cwd fd in restoreMountNamespace
This doesn't work very well (maybe I'm misunderstanding the desired implementation): : ~/w/vc/nix ; doas outputs/out/bin/nix --experimental-features 'nix-command flakes' develop -c pwd pwd: couldn't find directory entry in ‘../../../..’ with matching i-node
This commit is contained in:
parent
f89b0f7846
commit
10b9c1b2b2
1 changed files with 4 additions and 6 deletions
|
@ -1690,7 +1690,6 @@ void setStackSize(size_t stackSize)
|
|||
|
||||
#if __linux__
|
||||
static AutoCloseFD fdSavedMountNamespace;
|
||||
static AutoCloseFD fdSavedCwd;
|
||||
#endif
|
||||
|
||||
void saveMountNamespace()
|
||||
|
@ -1702,11 +1701,6 @@ void saveMountNamespace()
|
|||
if (!fd)
|
||||
throw SysError("saving parent mount namespace");
|
||||
fdSavedMountNamespace = std::move(fd);
|
||||
|
||||
fd = open("/proc/self/cwd", O_RDONLY);
|
||||
if (!fd)
|
||||
throw SysError("saving cwd");
|
||||
fdSavedCwd = std::move(fd);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
@ -1715,6 +1709,10 @@ void restoreMountNamespace()
|
|||
{
|
||||
#if __linux__
|
||||
try {
|
||||
AutoCloseFD fdSavedCwd = open("/proc/self/cwd", O_RDONLY);
|
||||
if (!fdSavedCwd) {
|
||||
throw SysError("saving cwd");
|
||||
}
|
||||
if (fdSavedMountNamespace && setns(fdSavedMountNamespace.get(), CLONE_NEWNS) == -1)
|
||||
throw SysError("restoring parent mount namespace");
|
||||
if (fdSavedCwd && fchdir(fdSavedCwd.get()) == -1) {
|
||||
|
|
Loading…
Reference in a new issue