Repository navigation
serve: drop to [serve].user after bind when started as root - #13
Mrigbozurike wants to merge 1 commit into
Conversation
|
Thanks. The drop itself is done right: initgroups, setgid, setuid in order, each checked,
Small: Honest take on scope: this is +285 lines for a case that only helps on X11, which nobody has tested yet, and #5 already makes root safe everywhere. I would rather merge #5 now and hold this until someone has an X11 setup to test on. If you want to keep it moving, fix 1 to 3 and rebase onto |
|
0.4.0 is released and this PR's base is now |
8c208dd to
e2052d9
Compare
|
All three blockers fixed, plus the smaller ones. Rebased onto
Smaller ones:
On scope: agreed, and no argument if you want to merge #5 and park this. It is still +285 lines for a case only X11 benefits from, and I have no X11 desktop to test on - everything above was verified as root on a headless box. Happy for it to wait for someone who can run it against a real display. |
|
Thanks for the thorough follow-up. I'm holding this one for 0.6.0. #5 goes into 0.5.0 on its own, and this needs an X11 test before it can land. Two fixes first, both about not handing out root:
Tests to add. The patch below adds a regression test for each problem. Both fail on your current head and should pass once fixed. The symlink test only catches the bug when run as root, so please run it under tests.patch (apply with
|
e2052d9 to
76f792e
Compare
|
Both fixed; understood on 0.6.0 and the X11 test. Signed off.
Docs and SECURITY.md updated for both. This still sits on top of #5; once that merges the diff is just the drop. |
Signed-off-by: mrigbozurike <drbillionbook@gmail.com>
76f792e to
29b99f0
Compare
|
Rebased onto Two conflicts came out of the rebase, both in the docs rather than the code:
The invoking root account's state directory is never created. Still parked for 0.6.0 and still untested on a real X11 desktop — everything above is a headless box. Happy for it to wait for someone with a display; retarget whenever |
|
@Mrigbozurike Doing a final review and testing then I'll merge |
Why
Follow-up to #5 (refuse root). For people who must start rdc from a root context (a system unit, provisioning), this lets it bind and then become a named account, so it never serves as root.
What
[serve].user/--user NAME: when started as root, the daemon binds the port,initgroups/setgid/setuidto the account, verifiessetuid(0)now fails, and only then opens the audit log and accepts requests. A failed drop is fatal.set_var("HOME")after the runtime had started worker threads; that is gone. Paths that depend on the account are derived from its passwd entry (Account::state_dir()), so the audit log lands in the target's~/.local/state/rdc(orLibrary/Application Support/rdcon macOS) unless[serve.audit].pathis set. The id change itself is applied to all threads by libc, so doing it after the runtime starts is fine.plan_with) is pure and takes an injected passwd lookup, so every branch is unit-tested without root.Testing
--userit refuses; with--user rdctestthe process shows asrdctestinps, serves/v1/whoami, the audit file is created under/home/rdctestwith mode 0600, and$HOMEof the invoking shell is untouched.cargo clippy --all-targets -- -D warnings,cargo teston Linux and Windows.This PR includes the commit from #5 until that merges; the diff will shrink to just the drop once it does.