use std::time::{Duration, Instant};
use super::fixtures::{spawn_std_blocker, Blocker};
use crate::child::shared::SharedChild;
use crate::identity::{ppid_fault, uniq_fault, uniq_info, ReadErr, ReadPurpose, UniqInfo, UniqRead, LAUNCHD};
use crate::test_groups::{setuid, Group};
use crate::wait::backend::test_hooks::{self, ForcedOnce};
use crate::wait::exit_only::seams::{self as exit_seams, ForcedReap, HolderStep};
use crate::wait::exit_only::{self, Foreign, Peek, Target};
fn far() -> Instant {
Instant::now() + Duration::from_secs(3600)
}
fn is_echild(e: &std::io::Error) -> bool {
e.raw_os_error() == Some(libc::ECHILD)
}
fn found(unique_id: u64) -> UniqRead {
UniqRead::Found(UniqInfo { unique_id })
}
fn unique_of(pid: u32) -> u64 {
match uniq_info(pid, ReadPurpose::Adopt) {
UniqRead::Found(info) => info.unique_id,
other => panic!("the unique id of {pid}: {other:?}"),
}
}
#[skuld::test]
fn a_reap_that_finds_none_after_reapable_takes_the_echild_path() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
let none = exit_seams::force_reap_once(ForcedReap::None);
let err = b.shared.wait().expect_err("the forced empty reap");
drop(none);
assert!(is_echild(&err), "{err}");
assert!(format!("{:?}", b.shared).contains("N"), "{:?}", b.shared);
b.shared.wait().expect("the zombie is still there");
}
#[skuld::test]
fn an_identity_read_gone_takes_the_echild_path() {
let (child, stdin) = spawn_std_blocker();
let unique = unique_of(child.id());
drop(stdin);
let mut child = child;
let target = Target::pid(child.id(), Some(unique));
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Peek, UniqRead::Gone);
let peeked = loop {
match exit_only::peek(&target).expect("peek") {
Peek::Running => confirm_exit_of(&child),
other => break other,
}
};
drop(forced);
assert_eq!(peeked, Peek::Foreign(Foreign::Gone));
child.wait().expect("reap");
}
fn confirm_exit_of(child: &std::process::Child) {
let mut info: libc::siginfo_t = unsafe { std::mem::zeroed() };
let r = unsafe {
libc::waitid(
libc::P_PID,
child.id() as libc::id_t,
&mut info,
libc::WEXITED | libc::WNOWAIT,
)
};
assert_eq!(r, 0, "waitid(WNOWAIT): {}", std::io::Error::last_os_error());
}
fn second_reap_with_unique(read: UniqRead) -> std::process::Child {
let (mut child, stdin) = spawn_std_blocker();
drop(stdin);
confirm_exit_of(&child);
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::SecondPeek, read);
crate::wait::exit_only::second_reap(child.id(), Some(7));
drop(forced);
let _ = &mut child;
child
}
#[skuld::test]
fn a_second_reap_with_an_id_mismatch_is_skipped() {
let mut child = second_reap_with_unique(found(99));
let status = child
.wait()
.expect("the zombie must still be there: the mismatch skipped the consume");
assert!(status.success());
}
#[skuld::test]
fn a_second_reap_with_a_matching_id_consumes_the_leftover() {
let child = second_reap_with_unique(found(7));
let mut status = 0;
let r = unsafe { libc::waitpid(child.id() as i32, &mut status, libc::WNOHANG) };
assert_eq!(r, -1, "the matching second reap must have consumed the zombie");
assert_eq!(std::io::Error::last_os_error().raw_os_error(), Some(libc::ECHILD));
std::mem::forget(child);
}
#[skuld::test]
fn a_second_reap_that_meets_echild_is_skipped() {
crate::log_capture::install();
let (mut child, stdin) = spawn_std_blocker();
drop(stdin);
confirm_exit_of(&child);
let marker = format!("second reap of pid {}", child.id());
let mark = crate::log_capture::mark();
let forced = exit_seams::force_peek_once(Err(std::io::Error::from_raw_os_error(libc::ECHILD)));
crate::wait::exit_only::second_reap(child.id(), None);
drop(forced);
let levels = crate::log_capture::levels_since(mark, &marker);
assert!(
!levels.contains(&log::Level::Warn),
"an ECHILD must not warn: {levels:?}"
);
child.wait().expect("the zombie was never consumed");
}
#[skuld::test]
fn a_second_reap_without_an_id_is_skipped_with_a_warning() {
crate::log_capture::install();
let (mut child, stdin) = spawn_std_blocker();
drop(stdin);
confirm_exit_of(&child);
let marker = format!("second reap of pid {}", child.id());
let mark = crate::log_capture::mark();
crate::wait::exit_only::second_reap(child.id(), None);
let levels = crate::log_capture::levels_since(mark, &marker);
assert_eq!(levels, [log::Level::Warn], "{levels:?}");
child.wait().expect("the zombie was never consumed");
}
#[skuld::test]
fn a_second_reap_that_finds_nothing_is_skipped() {
crate::log_capture::install();
let (mut child, stdin) = spawn_std_blocker();
drop(stdin);
confirm_exit_of(&child);
let marker = format!("second reap of pid {}", child.id());
let mark = crate::log_capture::mark();
let same = uniq_fault::force_uniq_read_once(ReadPurpose::SecondPeek, found(7));
let none = exit_seams::force_reap_once(ForcedReap::None);
crate::wait::exit_only::second_reap(child.id(), Some(7));
drop(none);
drop(same);
let levels = crate::log_capture::levels_since(mark, &marker);
assert!(
!levels.contains(&log::Level::Warn),
"finding nothing must not warn: {levels:?}"
);
child.wait().expect("the zombie was never consumed");
}
#[skuld::test]
fn a_second_peek_runs_after_every_first_reap() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
exit_seams::holder_steps();
b.shared.wait().expect("wait");
assert_eq!(exit_seams::holder_steps(), [HolderStep::Reap, HolderStep::SecondPeek]);
}
#[skuld::test]
fn force_uniq_read_once_hits_only_its_purpose() {
let pid = std::process::id();
let real = uniq_info(pid, ReadPurpose::Peek);
assert!(matches!(real, UniqRead::Found(_)), "{real:?}");
let all = [ReadPurpose::Peek, ReadPurpose::PreReap, ReadPurpose::SecondPeek];
for armed in all {
let forced = uniq_fault::force_uniq_read_once(armed, UniqRead::Refused(libc::EPERM));
for other in all.into_iter().filter(|p| *p != armed) {
assert_eq!(uniq_info(pid, other), real, "{other:?} read while {armed:?} was armed");
}
assert_eq!(uniq_info(pid, armed), UniqRead::Refused(libc::EPERM));
assert_eq!(uniq_info(pid, armed), real, "the force is taken once");
drop(forced);
}
}
const MARKER: &str = "COSCA_TEST_SHARED_SIGIGN";
const CASE_ENV: &str = "COSCA_TEST_SHARED_SIGIGN_CASE";
fn run_case(path: &str, case: &str) {
crate::test_child::run_fixture_case(path, MARKER, CASE_ENV, case);
}
fn ignoring_sigchld_with_a_sibling() -> (SharedChild, std::process::Child, std::process::ChildStdin, ForcedOnce) {
crate::test_child::set_sigchld_ignored(true);
let (sibling, sibling_stdin) = spawn_std_blocker();
let (root, root_stdin) = spawn_std_blocker();
let id = super::fixtures::identity_of(&root);
let shared = SharedChild::adopt(root, id).unwrap_or_else(|(e, _)| panic!("adopt: {e}"));
let mut root_stdin = Some(root_stdin);
let end = test_hooks::on_kevent_round(0, move || drop(root_stdin.take()));
(shared, sibling, sibling_stdin, end)
}
#[skuld::test]
fn the_holder_waits_on_the_kqueue_not_in_waitid() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
let _hooks = test_hooks::HookGuard::install(|_, _| {});
b.shared.wait().expect("wait");
assert!(
!test_hooks::await_requested_timeouts().is_empty(),
"the holder never asked the kqueue"
);
}
#[skuld::test]
fn a_wait_on_a_child_the_kernel_reaped_returns_while_a_sibling_lives() {
if !crate::test_child::is_marked_fixture_reexec(MARKER) {
return run_case(
crate::test_child::fixture_path!(a_wait_on_a_child_the_kernel_reaped_returns_while_a_sibling_lives),
"",
);
}
let (shared, _sibling, _stdin, _end) = ignoring_sigchld_with_a_sibling();
let err = shared.wait().expect_err("the kernel reaped the root");
assert!(is_echild(&err), "{err}");
}
#[skuld::test]
fn a_wait_timeout_far_past_the_bound_returns_echild() {
if !crate::test_child::is_marked_fixture_reexec(MARKER) {
return run_case(
crate::test_child::fixture_path!(a_wait_timeout_far_past_the_bound_returns_echild),
"",
);
}
let (shared, _sibling, _stdin, _end) = ignoring_sigchld_with_a_sibling();
let err = shared.wait_deadline(far()).expect_err("the kernel reaped the root");
assert!(is_echild(&err), "{err}");
}
#[skuld::test]
fn a_sync_drop_of_a_child_the_kernel_reaped_returns() {
if !crate::test_child::is_marked_fixture_reexec(MARKER) {
return run_case(
crate::test_child::fixture_path!(a_sync_drop_of_a_child_the_kernel_reaped_returns),
"",
);
}
crate::test_child::set_sigchld_ignored(true);
let (_sibling, _sibling_stdin) = spawn_std_blocker();
let mut cmd = crate::Command::new();
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(crate::test_child::leaked_writer_stdin()).expect("stdin");
cmd.stdout(crate::Stdio::null()).expect("stdout");
let child = cmd.spawn().expect("spawn");
drop(child);
}
#[skuld::test]
fn the_shared_childs_target_carries_its_unique_id() {
let b = Blocker::spawn();
let target = b.shared.target().expect("a target");
let Target::Pid { pid, unique, .. } = target;
assert_eq!(pid, b.shared.id());
assert_eq!(unique, Some(unique_of(pid)));
}
#[skuld::test]
fn try_wait_on_a_pid_with_another_unique_id_is_echild_and_consumes_nothing() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
let other = unique_of(b.shared.id()) ^ 1;
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Peek, found(other));
let err = b.shared.try_wait().expect_err("another process holds the pid");
drop(forced);
assert!(is_echild(&err), "{err}");
b.shared.wait().expect("our zombie was never consumed");
}
#[skuld::test]
fn a_wait_on_a_pid_with_another_unique_id_never_reaches_the_reap() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
exit_seams::holder_steps();
let other = unique_of(b.shared.id()) ^ 1;
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Peek, found(other));
let err = b.shared.wait().expect_err("another process holds the pid");
drop(forced);
assert!(is_echild(&err), "{err}");
assert!(
!exit_seams::holder_steps().contains(&HolderStep::Reap),
"the wait reached the reap for a pid that is not ours"
);
b.shared.wait().expect("our zombie was never consumed");
}
#[skuld::test]
fn kill_sends_nothing_to_a_pid_with_another_unique_id() {
let mut b = Blocker::spawn();
let log = crate::send_log::Capture::start();
let other = b.shared.identity.expect("a live child's identity") ^ 1;
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Kill, found(other));
b.shared.kill().expect("a pid that is not ours is gone, not an error");
drop(forced);
assert_eq!(log.entries(), []);
b.end_child();
let status = b.shared.wait().expect("wait");
assert!(status.success(), "the child was signalled: {status:?}");
}
#[skuld::test]
fn kill_signals_a_live_child_by_its_verified_pid() {
let b = Blocker::spawn();
let log = crate::send_log::Capture::start();
b.shared.kill().expect("kill");
assert_eq!(
log.entries(),
[(b.shared.id(), crate::signal::Sig::Kill, crate::send_log::Via::Pid)]
);
let status = b.shared.wait().expect("wait");
assert_eq!(super::fixtures::signal_of(status), Some(libc::SIGKILL));
}
fn echild_yet_resolvable() -> (u32, u64) {
let pid = std::process::id();
(pid, unique_of(pid))
}
fn held_by_a_tracer() -> ppid_fault::Forced {
ppid_fault::force_ppid_once(Ok(4242))
}
fn orphaned_to_launchd() -> ppid_fault::Forced {
ppid_fault::force_ppid_once(Ok(LAUNCHD))
}
#[skuld::test]
fn an_echild_for_a_pid_held_by_a_tracer_is_running() {
let (pid, unique) = echild_yet_resolvable();
let target = Target::pid(pid, Some(unique));
let forced = held_by_a_tracer();
assert_eq!(exit_only::peek(&target).expect("peek"), Peek::Running);
drop(forced);
let _forced = held_by_a_tracer();
assert_eq!(
exit_only::try_reap(&target).expect("try_reap"),
exit_only::Reap::Running
);
}
#[skuld::test]
fn an_echild_for_another_users_process_that_launchd_does_not_own_is_running() {
let target = Target::pid(1, Some(unique_of(1)));
assert_eq!(exit_only::peek(&target).expect("peek"), Peek::Running);
assert_eq!(
exit_only::try_reap(&target).expect("try_reap"),
exit_only::Reap::Running
);
}
#[skuld::test]
fn an_echild_for_a_pid_orphaned_to_launchd_is_orphaned() {
let (pid, unique) = echild_yet_resolvable();
let target = Target::pid(pid, Some(unique));
let forced = orphaned_to_launchd();
assert_eq!(
exit_only::peek(&target).expect("peek"),
Peek::Foreign(Foreign::Orphaned)
);
drop(forced);
let _forced = orphaned_to_launchd();
assert_eq!(
exit_only::try_reap(&target).expect("try_reap"),
exit_only::Reap::Foreign(Foreign::Orphaned)
);
}
#[skuld::test]
fn an_echild_whose_parent_read_fails_is_foreign() {
let (pid, unique) = echild_yet_resolvable();
let target = Target::pid(pid, Some(unique));
let forced = ppid_fault::force_ppid_once(Err(ReadErr::Refused(libc::EPERM)));
assert_eq!(exit_only::peek(&target).expect("peek"), Peek::Foreign(Foreign::Gone));
drop(forced);
let forced = ppid_fault::force_ppid_once(Err(ReadErr::Gone));
let outcome = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| exit_only::peek(&target)));
drop(forced);
if cfg!(debug_assertions) {
assert!(outcome.is_err(), "a debug build asserts the contract");
} else {
assert_eq!(
outcome.expect("release returns").expect("peek"),
Peek::Foreign(Foreign::Gone)
);
}
}
#[skuld::test]
fn an_echild_for_a_pid_that_no_longer_names_the_child_is_foreign() {
let (pid, unique) = echild_yet_resolvable();
let target = Target::pid(pid, Some(unique));
let other = found(unique ^ 1);
for (reads, want) in [
(vec![other], Foreign::Other),
(vec![found(unique), other], Foreign::Other),
(vec![UniqRead::Refused(libc::EPERM)], Foreign::Gone),
(vec![UniqRead::Gone], Foreign::Gone),
(vec![found(unique), UniqRead::Gone], Foreign::Gone),
] {
let forced: Vec<_> = reads
.iter()
.map(|read| uniq_fault::force_uniq_read_once(ReadPurpose::Echild, *read))
.collect();
assert_eq!(
exit_only::peek(&target).expect("peek"),
Peek::Foreign(want),
"{reads:?}"
);
drop(forced);
}
}
#[skuld::test]
fn a_running_peek_of_a_pid_with_another_unique_id_is_foreign() {
let mut b = Blocker::spawn();
let unique = unique_of(b.shared.id());
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Running, found(unique ^ 1));
let err = b.shared.try_wait().expect_err("another process holds the pid");
drop(forced);
assert!(is_echild(&err), "{err}");
for read in [UniqRead::Refused(libc::EPERM), found(unique)] {
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Running, read);
assert_eq!(b.shared.try_wait().expect("try_wait"), None, "{read:?}");
drop(forced);
}
b.end_child();
b.shared.wait().expect("wait");
}
#[skuld::test]
fn an_echild_with_no_id_stays_foreign() {
let (pid, _) = echild_yet_resolvable();
assert_eq!(
exit_only::peek(&Target::pid(pid, None)).expect("peek"),
Peek::Foreign(Foreign::Gone)
);
}
#[skuld::test]
fn the_kqueue_wait_keeps_waiting_for_a_child_that_answers_echild_yet_resolves() {
use crate::wait::backend::{await_reapable, Waited};
let (pid, unique) = echild_yet_resolvable();
let _forced = (held_by_a_tracer(), held_by_a_tracer());
let waited = await_reapable(pid, Some(unique), Some(Instant::now())).expect("wait");
assert_eq!(waited, Waited::DeadlinePassed);
}
#[skuld::test]
fn the_kqueue_wait_reports_gone_for_a_pid_with_another_unique_id() {
use crate::wait::backend::{await_reapable, Waited};
let (pid, unique) = echild_yet_resolvable();
let waited = await_reapable(pid, Some(unique ^ 1), Some(Instant::now())).expect("wait");
assert_eq!(waited, Waited::Gone);
}
#[skuld::test]
fn a_wait_on_a_zombie_launchd_holds_warns_it_is_not_ours_to_reap() {
crate::log_capture::install();
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
let pid = b.shared.id();
let mark = crate::log_capture::mark();
let _orphaned = exit_seams::force_peek_once(Ok(Peek::Foreign(Foreign::Orphaned)));
_ = b.shared.wait();
let records = crate::log_capture::records_since_on_current_thread(mark, &format!("pid {pid}"));
assert!(
records
.iter()
.any(|(level, text)| *level == log::Level::Warn && text.contains("not ours to reap")),
"{records:?}"
);
crate::child::spawn::identity_macos_tests::reap_by_pid(pid);
}
#[skuld::test]
fn a_reap_that_finds_no_exit_record_after_reapable_waits_again() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
let slot = std::rc::Rc::new(std::cell::RefCell::new(None));
let _hook = exit_seams::on_holder_step(HolderStep::Reap, {
let slot = std::rc::Rc::clone(&slot);
move || *slot.borrow_mut() = Some(exit_seams::force_peek_once(Ok(Peek::Running)))
});
let status = b.shared.wait().expect("the holder waited again and got the exit");
assert!(status.success(), "{status:?}");
assert!(
exit_seams::take_forced_peek().is_none(),
"the reap must have consumed the forced peek"
);
}
fn spawn_root_child() -> (std::process::Child, std::process::ChildStdin) {
use std::io::Read as _;
let helper = crate::test_privilege::setuid::setuid_helper();
let mut cmd = std::process::Command::new(helper);
cmd.args(["setuid-stdin-block", "root"])
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::null());
let mut child = crate::test_spawn::spawn(&mut cmd).expect("spawn the setuid helper");
let stdin = child.stdin.take().expect("piped stdin");
let mut ready = [0u8; 1];
child
.stdout
.take()
.expect("piped stdout")
.read_exact(&mut ready)
.expect("the helper reports ready");
assert_eq!(ready, *b"+");
(child, stdin)
}
#[skuld::test]
fn setuid_kill_of_a_root_child_is_permission_denied(#[fixture(setuid)] _group: &Group) {
let (child, stdin) = spawn_root_child();
let id = super::fixtures::identity_of(&child);
let shared = SharedChild::adopt(child, id).unwrap_or_else(|(e, _)| panic!("adopt: {e}"));
assert!(
shared.identity.is_some(),
"the identity of another user's process is readable: {:?}",
shared.identity
);
let err = shared.kill().expect_err("this caller may not signal a root process");
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
drop(stdin);
let status = shared.wait().expect("the helper exits on EOF");
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn setuid_child_kill_is_permission_denied(#[fixture(setuid)] _group: &Group) {
let helper = crate::test_privilege::setuid::setuid_helper();
let mut cmd = crate::Command::new();
cmd.executable(&helper)
.args(["cosca_testbin", "setuid-stdin-block", "root"]);
cmd.stdin(crate::Stdio::pipe()).expect("stdin pipe");
cmd.stdout(crate::Stdio::pipe()).expect("stdout pipe");
cmd.stderr(crate::Stdio::null()).expect("stderr null");
let mut child = cmd.spawn().expect("spawn the setuid helper");
let stdin = child.stdin().expect("piped stdin");
let mut ready = [0u8; 1];
std::io::Read::read_exact(&mut child.stdout().expect("piped stdout"), &mut ready).expect("ready");
assert_eq!(ready, *b"+");
let err = child.kill().expect_err("this caller may not signal a root process");
assert!(
matches!(&err, crate::error::Error::Io(e) if e.kind() == std::io::ErrorKind::PermissionDenied),
"{err:?}"
);
drop(stdin);
let status = child.wait().expect("the helper exits on EOF");
assert!(status.success(), "{status:?}");
}
fn adopt_exited_child_reading(read: UniqRead) -> Result<SharedChild, (crate::error::Error, std::process::Child)> {
let (child, stdin) = spawn_std_blocker();
let id = super::fixtures::identity_of(&child);
drop(stdin);
confirm_exit_of(&child);
let _forced = uniq_fault::force_uniq_read_once(ReadPurpose::Adopt, read);
SharedChild::adopt(child, id)
}
#[skuld::test]
fn a_child_gone_at_adoption_never_consumes_by_bare_pid() {
let shared = adopt_exited_child_reading(UniqRead::Gone).unwrap_or_else(|(e, _)| panic!("adopt: {e}"));
assert!(is_echild(&shared.try_wait().expect_err("try_wait")));
assert!(is_echild(&shared.wait().expect_err("wait")));
assert!(is_echild(&shared.wait_deadline(far()).expect_err("wait_deadline")));
let mut status = 0;
let r = unsafe { libc::waitpid(shared.id() as i32, &mut status, libc::WNOHANG) };
assert_eq!(
r,
shared.id() as i32,
"the zombie must still be there for its own handle"
);
shared
.kill()
.expect("a child gone at adoption is already dead: success");
}
#[skuld::test]
fn a_child_whose_identity_is_unreadable_at_adoption_is_not_adopted() {
let (error, mut child) = match adopt_exited_child_reading(UniqRead::Refused(libc::EPERM)) {
Ok(_) => panic!("adopted with no identity"),
Err(refused) => refused,
};
assert!(matches!(error, crate::error::Error::Unassessable { .. }), "{error:?}");
child.wait().expect("the child is handed back unreaped");
}
#[skuld::test]
fn a_refused_id_read_at_the_exit_check_consumes_nothing() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Peek, UniqRead::Refused(libc::EPERM));
let err = b.shared.try_wait().expect_err("an unverifiable exit is not consumed");
drop(forced);
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
let forced = uniq_fault::force_uniq_read_once(ReadPurpose::Peek, UniqRead::Refused(libc::EACCES));
let err = b.shared.wait().expect_err("nor by a wait");
drop(forced);
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
let status = b.shared.wait().expect("the zombie was never consumed");
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn a_refused_echild_read_is_an_error_to_a_verified_peek() {
let (pid, unique) = echild_yet_resolvable();
let target = Target::pid(pid, Some(unique));
let _forced = uniq_fault::force_uniq_read_once(ReadPurpose::Echild, UniqRead::Refused(libc::EPERM));
let err = exit_only::peek_verified(&target).expect_err("a denied read cannot show a reap");
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
}