Skip to content

Commit 2048dff

Browse files
committed
Fix review issues
1 parent dc5aed8 commit 2048dff

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

rust/crates/rqd/src/frame/logging.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,17 +570,20 @@ mod tests {
570570
#[cfg(any(target_os = "linux", target_os = "macos"))]
571571
#[test]
572572
fn test_init_into_unwritable_dir_reports_failing_op() {
573-
// root bypasses DAC, so the unwritable-dir scenario can't be reproduced there.
574-
// SAFETY: geteuid is an always-successful syscall with no preconditions.
575-
if unsafe { nix::libc::geteuid() } == 0 {
576-
return;
577-
}
578-
579573
let dir = tempfile::tempdir().unwrap();
580574
let locked = dir.path().join("locked");
581575
fs::create_dir(&locked).unwrap();
582576
fs::set_permissions(&locked, Permissions::from_mode(0o000)).unwrap();
583577

578+
// If this process can still create files in the locked dir (running as root, or
579+
// holding CAP_DAC_OVERRIDE), the unwritable-dir scenario can't be reproduced.
580+
let probe = locked.join(".probe");
581+
if File::create(&probe).is_ok() {
582+
let _ = fs::remove_file(&probe);
583+
let _ = fs::set_permissions(&locked, Permissions::from_mode(0o755));
584+
return;
585+
}
586+
584587
let log_path = locked.join("frame.rqlog");
585588
let result = FrameFileLogger::init(log_path.to_string_lossy().to_string(), false, None);
586589

rust/crates/rqd/src/system/capabilities.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ mod imp {
5454
return Ok(());
5555
}
5656

57-
// root holds the full capability set implicitly, so there is nothing to verify.
58-
// SAFETY: geteuid is an always-successful syscall with no preconditions.
59-
if unsafe { nix::libc::geteuid() } == 0 {
60-
return Ok(());
61-
}
62-
57+
// Validate the effective set even when running as root: in containers and user
58+
// namespaces a uid-0 process can have a reduced CapEff and would otherwise fail
59+
// at frame launch instead of here.
6360
let caps = effective_caps().ok_or_else(|| {
6461
miette!(
6562
"runner.run_as_user is enabled but RQD could not read its effective \

0 commit comments

Comments
 (0)