Skip to content

Commit

Permalink
tryUnshareFilesystem: Ignore ENOSYS too
Browse files Browse the repository at this point in the history
Fixes #10747
  • Loading branch information
Ericson2314 committed May 22, 2024
1 parent d5fdfdc commit dc7615d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libstore/filetransfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ struct curlFileTransfer : public FileTransfer

#if __linux__
try {
unshareFilesystem();
tryUnshareFilesystem();
} catch (nix::Error & e) {
e.addTrace({}, "in download thread");
throw;
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/linux/namespaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ void restoreMountNamespace()
}
}

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

Expand Down
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 dc7615d

Please sign in to comment.