Derive prepared runtime files from the sandbox contract
This commit is contained in:
parent
77ba5319ce
commit
91d88336df
1 changed files with 24 additions and 12 deletions
|
|
@ -26,6 +26,7 @@ use lazaret_runtime_supervisor::sandbox::{
|
|||
PROC_DESTINATION, RootProcess, SANDBOX_INIT_DESTINATION, SYS_DESTINATION,
|
||||
TERMINFO_ROOT_DESTINATION, WORKSPACE_DESTINATION,
|
||||
};
|
||||
use lazaret_sandbox_contract::RUNTIME_FILE_DESTINATIONS;
|
||||
use lazaret_storage_catalog::{Catalog, CatalogError};
|
||||
use rustix::fs::{Mode, OFlags, ResolveFlags, openat2};
|
||||
|
||||
|
|
@ -258,14 +259,10 @@ fn prepared_destinations(configuration: &ResolvedDomainConfiguration) -> Vec<Pre
|
|||
kind: PreparedDestinationKind::Directory,
|
||||
})
|
||||
.chain(
|
||||
[
|
||||
"/etc/resolv.conf",
|
||||
"/etc/hosts",
|
||||
"/etc/hostname",
|
||||
ESCALATION_CLIENT_DESTINATION,
|
||||
SANDBOX_INIT_DESTINATION,
|
||||
]
|
||||
.into_iter()
|
||||
RUNTIME_FILE_DESTINATIONS
|
||||
.iter()
|
||||
.map(|(_, destination)| *destination)
|
||||
.chain([ESCALATION_CLIENT_DESTINATION, SANDBOX_INIT_DESTINATION])
|
||||
.map(|path| PreparedDestination {
|
||||
path: path.into(),
|
||||
kind: PreparedDestinationKind::RegularFile,
|
||||
|
|
@ -497,6 +494,21 @@ mod tests {
|
|||
destination.path == Path::new(SANDBOX_INIT_DESTINATION)
|
||||
&& destination.kind == PreparedDestinationKind::RegularFile
|
||||
}));
|
||||
let prepared_runtime_files = destinations
|
||||
.iter()
|
||||
.filter(|destination| {
|
||||
destination.kind == PreparedDestinationKind::RegularFile
|
||||
&& destination.path.starts_with("/etc")
|
||||
})
|
||||
.map(|destination| destination.path.clone())
|
||||
.collect::<BTreeSet<_>>();
|
||||
assert_eq!(
|
||||
prepared_runtime_files,
|
||||
RUNTIME_FILE_DESTINATIONS
|
||||
.iter()
|
||||
.map(|(_, destination)| PathBuf::from(destination))
|
||||
.collect()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue