mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Merge pull request #5787 from edolstra/unshare-fs
Ignore EPERM when unsharing FS state
This commit is contained in:
commit
6e6e998930
3 changed files with 14 additions and 7 deletions
|
@ -544,13 +544,7 @@ struct curlFileTransfer : public FileTransfer
|
||||||
stopWorkerThread();
|
stopWorkerThread();
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifdef __linux__
|
unshareFilesystem();
|
||||||
/* Cause this thread to not share any FS attributes with the main thread,
|
|
||||||
because this causes setns() in restoreMountNamespace() to fail.
|
|
||||||
Ideally, this would happen in the std::thread() constructor. */
|
|
||||||
if (unshare(CLONE_FS) != 0)
|
|
||||||
throw SysError("unsharing filesystem state in download thread");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::map<CURL *, std::shared_ptr<TransferItem>> items;
|
std::map<CURL *, std::shared_ptr<TransferItem>> items;
|
||||||
|
|
||||||
|
|
|
@ -1660,6 +1660,14 @@ void restoreMountNamespace()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unshareFilesystem()
|
||||||
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
if (unshare(CLONE_FS) != 0 && errno != EPERM)
|
||||||
|
throw SysError("unsharing filesystem state in download thread");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void restoreProcessContext(bool restoreMounts)
|
void restoreProcessContext(bool restoreMounts)
|
||||||
{
|
{
|
||||||
restoreSignals();
|
restoreSignals();
|
||||||
|
|
|
@ -311,6 +311,11 @@ void saveMountNamespace();
|
||||||
if saveMountNamespace() was never called. */
|
if saveMountNamespace() was never called. */
|
||||||
void restoreMountNamespace();
|
void restoreMountNamespace();
|
||||||
|
|
||||||
|
/* Cause this thread to not share any FS attributes with the main
|
||||||
|
thread, because this causes setns() in restoreMountNamespace() to
|
||||||
|
fail. */
|
||||||
|
void unshareFilesystem();
|
||||||
|
|
||||||
|
|
||||||
class ExecError : public Error
|
class ExecError : public Error
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue