Support garbage collection in external daemon#15143
Conversation
e764a10 to
5fe89d4
Compare
888a478 to
b3efe29
Compare
b3efe29 to
ab555f2
Compare
53e8836 to
44ad62e
Compare
44ad62e to
494128c
Compare
5dfc791 to
f3ac1b3
Compare
f3ac1b3 to
8df59e4
Compare
|
|
||
| std::filesystem::path LocalStoreConfig::getRootsSocketPath() const | ||
| { | ||
| return std::filesystem::path(stateDir.get()) / "gc-roots-socket" / "socket"; |
There was a problem hiding this comment.
I changed it to match daemon-socket/socket for the original daemon, but frankly, it's a weird path and I don't know if we rather do something else instead.
There was a problem hiding this comment.
Yes, I agree it's a weird path and would not be against changing it. I'm not sure what 's good though.
8df59e4 to
c2bef2d
Compare
e570237 to
c44f623
Compare
c44f623 to
d47ef14
Compare
xokdvium
left a comment
There was a problem hiding this comment.
Should probably document the "protocol" somewhere. Not sure it's a blocker though.
d47ef14 to
f7aee9a
Compare
f7aee9a to
77fafa8
Compare
db84efb to
6c02f9d
Compare
xokdvium
left a comment
There was a problem hiding this comment.
SGTM, modulo the release note.
6c02f9d to
0249c0b
Compare
This comes in two parts: a `nix store roots-daemon` command that can run as root and list runtime roots, and client logic to find runtime roots for a `LocalStore` by connecting to that daemon. This may be useful with an unprivileged nix daemon, as it would otherwise be unable to find runtime roots from process open files and maps.
0249c0b to
96fef69
Compare
|
The actual integration test for this, in the |
xokdvium
left a comment
There was a problem hiding this comment.
Thanks, threading solution seems much better to me.
Motivation
Some users may want to run the nix daemon as an unprivileged user, reducing the risk of compromise to their system if the nix daemon is exploited. While there are workarounds for many of the issues faced while running an unprivileged nix daemon, programs need root (or the equivalent
CAP_SYS_PTRACE) to find the list of runtime garbage collector roots.With this PR, users can run the minimal garbage-collector roots daemon as root, then the rest of the nix daemon as an unprivileged user, in order to not sacrifice functionality.
Note from @Ericson2314: The key result from this PR is that fewer GC functional tets are failing within the
hydraJobs.tests.functional_unprivileged-daemonNixOS VM test than before.Context
This replaces the more invasive #15026. The protocol and implementation in this PR were made as simple and non-invasive as possible: roots are sent from the daemon on connection, separated by null bytes. Existing code was reused wherever possible.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.