[rqd] Improve logging on fs and caps errors#2402
Conversation
Whenever starts without its required capabilities, it now fails right away, instead of waiting for a frame to fail trying to execute unauthorized ops. Besides that, ensire fs errors are properly logged.
📝 WalkthroughWalkthroughAdds a Linux capability preflight invoked during startup when run_as_user is enabled, enriches FrameFileLogger startup errors with best-effort path and filesystem diagnostics, and wires the preflight into main to surface privilege issues early. ChangesStartup Robustness Improvements
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rust/crates/rqd/src/frame/logging.rs`:
- Around line 572-588: The test test_init_into_unwritable_dir_reports_failing_op
currently only gates on unsafe { geteuid() } != 0 which is insufficient when
capabilities like CAP_DAC_OVERRIDE are present; instead, before calling
FrameFileLogger::init, attempt a real write/create probe inside the locked dir
(e.g., try creating/opening a temporary file for writing in locked) and if that
probe succeeds, skip the test — only proceed to call FrameFileLogger::init and
assert failure when the probe confirms the directory is actually unwritable;
ensure you still restore permissions for cleanup afterward.
In `@rust/crates/rqd/src/system/capabilities.rs`:
- Around line 57-85: Remove the early-return that skips capability validation
when geteuid() == 0 and instead always run the capability checks via
effective_caps() so root users with reduced CapEff (e.g., in containers or user
namespaces) fail fast; specifically, delete or disable the branch that returns
Ok() on the unsafe nix::libc::geteuid() == 0 check and allow the existing logic
that computes caps = effective_caps(), compares REQUIRED_CAPS, builds missing,
and returns the miette! error to execute for root as well.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4cb73bbe-24ea-4077-b288-009a76c57b7a
📒 Files selected for processing (4)
rust/crates/rqd/src/frame/logging.rsrust/crates/rqd/src/main.rsrust/crates/rqd/src/system/capabilities.rsrust/crates/rqd/src/system/mod.rs
2b4a304
into
AcademySoftwareFoundation:master
Whenever rqd starts without its required capabilities, it now fails right away, instead of waiting for a frame to fail trying to execute unauthorized ops. Besides that, endure fs errors are properly logged.
Summary by CodeRabbit