Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10747 #10758

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the try/catch be moved inside tryUnshareFilesystem() since it claims to be best-effort?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edolstra This try-catch-rethrow is solely to add some error context. The actual error handling still happens in the caller.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should never throw an exception? Are there any errors that should not be ignored?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but I am generally uncomfortable with ignoring errors without a whitelist.

} 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
Loading