Repository navigation
systemd: sandbox the user unit - #3
Conversation
02e041f to
5b1b57c
Compare
|
Thanks, this is a good hardening set and it passes fmt, clippy (Linux, Windows, macOS targets) and tests locally. Two things before merge:
Also, please sign off the commit ( |
5b1b57c to
38518fc
Compare
|
Thanks for the review. Both points addressed in 38518fc (force-pushed, signed off):
Also rebased on current |
|
Thanks for the update. RemoveIPC is gone, the commit is signed off, and CI is green on all three OSes. Two things still block it, and there is a branch change.
Smaller: the userns check reads two sysctls and misses AppArmor's Branch: we moved to release branches (see CONTRIBUTING, "How changes reach a release"). 0.4.0 is closed and waiting on final approval, so this goes into 0.5.0. Please rebase onto |
|
0.4.0 is released and this PR's base is now |
38518fc to
b53b209
Compare
|
Both blockers fixed, rebased onto
On the smaller points:
Still only exercised on a headless Linux box — the Hyprland test is yours to do, and the drop-in is the first thing to loosen if something is blocked. |
|
Thanks, the namespace split and the X11 bind are right, and CI is green. Before this goes into 0.5.0: Please fix
Please also update the PR description: it still mentions Tests to add. Please apply the patch below. It adds two tests:
They pass on your current head. A test for the quoting fix in point 3 would be welcome too. tests.patch (apply with
|
b53b209 to
e66001f
Compare
Signed-off-by: mrigbozurike <drbillionbook@gmail.com>
|
All four fixed, rebased onto
Tests: your two applied as given, plus |
Why
The generated
systemd --userunit granted the daemon everything the account has. rdc needs very little beyond the session it drives: its config, its state directory, the session runtime directory, the tailscaled socket, and one listener.What
The directives are split across two files, because in a
--userservice they are not equally available:dev.rdc.daemon.servicealways carries the pure seccomp/prctl settings:NoNewPrivileges,RestrictSUIDSGID,SystemCallFilter=@system-serviceminus@privileged @resources,SystemCallArchitectures=native,RestrictAddressFamilies,RestrictNamespaces,RestrictRealtime,LockPersonality,UMask=0077. It isType=exec.dev.rdc.daemon.service.d/10-sandbox.confcarries everything that needs user namespaces —PrivateUsers=yes, an emptyCapabilityBoundingSet/AmbientCapabilities, theProtect*family,ProtectSystem=strict,ProtectHome=read-only,PrivateTmp, withBindReadOnlyPaths="-/tmp/.X11-unix"so X11 sessions keep their socket, andReadWritePathsfor%t, the state directory and the audit directory.Install asks systemd whether the second set will work (
systemd-run --user --wait -p PrivateUsers=yes -p ProtectSystem=strict -p PrivateTmp=yes /bin/true) and writes the drop-in only if it starts, says so when it skips it, and removes a stale drop-in if an upgrade takes namespaces away. Paths are quoted and%escaped; a path containing a quote, backslash or newline is refused at install time. Installing restarts a running daemon, then waits pastRestartSecand checksNRestartsis still 0.RemoveIPCis deliberately not set: in a--userunit it would delete the desktop user's SysV/POSIX IPC on stop and can take Xwayland and PipeWire with it.Testing
cargo fmt,cargo clippy --all-targets -- -D warnings,cargo teston Linux and Windows. Ten unit tests cover the split, the X11 bind, the writable set, quoting, refused paths, reinstall idempotence, the no-namespace path and uninstall. Not yet run on a live Wayland desktop.