Implement supervised rootless network readiness

This commit is contained in:
ms2k 2026-07-15 23:26:37 +09:00
commit ba6a075839

View file

@ -44,6 +44,7 @@ fn exit(result: std::io::Result<()>) -> ExitCode {
fn run_all() -> std::io::Result<()> {
successful_acquisition()?;
acknowledged_transition_precedes_exact_wrapper_release()?;
lifetime_pipe_descriptor_contract()?;
failed_stages_and_acknowledgments()?;
production_wrapper_refuses_former_harness_path()?;
@ -53,6 +54,47 @@ fn run_all() -> std::io::Result<()> {
concurrent_acquisitions_serialize()
}
#[allow(clippy::disallowed_methods, clippy::disallowed_types)]
fn acknowledged_transition_precedes_exact_wrapper_release() -> std::io::Result<()> {
let target_marker = marker("transition-target");
let parent = current_process_identity()?;
let staged = std::cell::Cell::new(None);
let acknowledged = std::cell::Cell::new(false);
let target = TargetCommand::new("/usr/bin/touch").argument(&target_marker);
let process = child_broker().acquire_with_stdio_after_ack(
parent,
context(),
&target,
ChildStandardIo::inherit(),
|ownership| {
staged.set(Some(ownership));
Ok(())
},
|ownership| {
if staged.get() != Some(ownership) {
return Err(std::io::Error::other("transition staged ownership changed"));
}
acknowledged.set(true);
Ok(ProcessOwnershipCommitAck::v1(ownership))
},
|| {
if !acknowledged.get() || target_marker.exists() {
return Err(std::io::Error::other(
"wrapper was released outside the acknowledged transition boundary",
));
}
Ok(())
},
)?;
child_broker().reap(process)?;
if !target_marker.is_file() {
return Err(std::io::Error::other(
"acknowledged transition did not release the exact wrapper",
));
}
std::fs::remove_file(target_marker)
}
#[allow(clippy::disallowed_methods, clippy::disallowed_types)]
fn lifetime_pipe_descriptor_contract() -> std::io::Result<()> {
let held_pipe_marker = marker("lifetime-pipe");