Refuse orphan state without Domain Store authority
This commit is contained in:
parent
24d7d5b6e0
commit
e97ab6471c
1 changed files with 103 additions and 36 deletions
|
|
@ -425,6 +425,33 @@ pub enum StateAnchorResetScope<'a> {
|
|||
Selected(&'a Path),
|
||||
}
|
||||
|
||||
/// Proves that no physical State Anchor exists under either retained Domain authority.
|
||||
///
|
||||
/// # Errors
|
||||
/// Refuses changed authority, links, inaccessible paths, or any persistent or runtime anchor.
|
||||
pub fn require_state_anchor_absent(
|
||||
configuration: &ResolvedDomainConfiguration,
|
||||
) -> Result<(), StateAnchorError> {
|
||||
for plan in [
|
||||
configuration.persistent_domain_root(),
|
||||
configuration.runtime_domain_root(),
|
||||
] {
|
||||
let root = plan
|
||||
.open_authority()
|
||||
.map_err(|_| StateAnchorError::InvalidLayout("Domain authority changed"))?;
|
||||
match open_directory(&root, Path::new("state-anchor")) {
|
||||
Ok(_) => {
|
||||
return Err(StateAnchorError::InvalidLayout(
|
||||
"State Anchor exists without Domain Store authority",
|
||||
));
|
||||
}
|
||||
Err(StateAnchorError::Io(error)) if error.kind() == io::ErrorKind::NotFound => {}
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Refuses an orphan reset quarantine without opening transient mount paths.
|
||||
///
|
||||
/// # Errors
|
||||
|
|
|
|||
Loading…
Reference in a new issue