Skip to content

Commit

Permalink
Merge pull request #10758 from obsidiansystems/fix-10747
Browse files Browse the repository at this point in the history
Fix #10747
  • Loading branch information
Ericson2314 authored May 22, 2024
2 parents bd7a074 + dc7615d commit 859e55d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/libstore/filetransfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,12 @@ struct curlFileTransfer : public FileTransfer
#endif

#if __linux__
unshareFilesystem();
try {
tryUnshareFilesystem();
} catch (nix::Error & e) {
e.addTrace({}, "in download thread");
throw;
}
#endif

std::map<CURL *, std::shared_ptr<TransferItem>> items;
Expand Down
6 changes: 3 additions & 3 deletions src/libutil/linux/namespaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ void restoreMountNamespace()
}
}

void unshareFilesystem()
void tryUnshareFilesystem()
{
if (unshare(CLONE_FS) != 0 && errno != EPERM)
throw SysError("unsharing filesystem state in download thread");
if (unshare(CLONE_FS) != 0 && errno != EPERM && errno != ENOSYS)
throw SysError("unsharing filesystem state");
}

}
6 changes: 4 additions & 2 deletions src/libutil/linux/namespaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ void saveMountNamespace();
void restoreMountNamespace();

/**
* Cause this thread to not share any FS attributes with the main
* Cause this thread to try to not share any FS attributes with the main
* thread, because this causes setns() in restoreMountNamespace() to
* fail.
*
* This is best effort -- EPERM and ENOSYS failures are just ignored.
*/
void unshareFilesystem();
void tryUnshareFilesystem();

bool userNamespacesSupported();

Expand Down

0 comments on commit 859e55d

Please sign in to comment.