Compose protected runtime files before sandbox handoff
This commit is contained in:
parent
85f0db08d7
commit
af9b4de85a
2 changed files with 103 additions and 2 deletions
|
|
@ -180,6 +180,10 @@ impl<'a> ColdStart<'a> {
|
|||
.map_err(|error| failure(format!("Git-routing staging: {error}")))?;
|
||||
let expected_network_namespace = namespace_identity(Path::new(NETWORK_NAMESPACE_PATH))
|
||||
.map_err(|error| failure(format!("network namespace: {error}")))?;
|
||||
let network_policy = derive_ipv4_policy(inputs.configuration)
|
||||
.map_err(|error| failure(format!("network policy: {error}")))?;
|
||||
runtime_files::replace_protected_runtime_files(&state_anchor_layout, &network_policy)
|
||||
.map_err(|error| failure(format!("protected runtime files: {error}")))?;
|
||||
let request = SandboxBuildRequest {
|
||||
configuration: inputs.configuration,
|
||||
container_id: inputs.container_id,
|
||||
|
|
@ -198,8 +202,6 @@ impl<'a> ColdStart<'a> {
|
|||
staging
|
||||
.write_bundle(sandbox_bundle.specification_json())
|
||||
.map_err(|error| failure(format!("bundle staging: {error}")))?;
|
||||
let network_policy = derive_ipv4_policy(inputs.configuration)
|
||||
.map_err(|error| failure(format!("network policy: {error}")))?;
|
||||
let ownership = ProcessOwnershipContext {
|
||||
domain_id: inputs.generation.domain_id,
|
||||
generation_id: inputs.generation.generation_id,
|
||||
|
|
@ -414,6 +416,7 @@ fn require_inputs(inputs: &ColdStartInputs<'_>) -> Result<(), ColdStartError> {
|
|||
}
|
||||
|
||||
mod git_routing;
|
||||
mod runtime_files;
|
||||
mod runtime_staging;
|
||||
|
||||
use git_routing::GitRoutingLayout;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
|
||||
use lazaret_core::network::CanonicalDerivedNetworkPolicy;
|
||||
use lazaret_core::records::IpAddress;
|
||||
use lazaret_state_anchor::{ProtectedRuntimeFiles, StateAnchorError, StateAnchorLayout};
|
||||
|
||||
pub(super) fn replace_protected_runtime_files(
|
||||
layout: &StateAnchorLayout<'_>,
|
||||
policy: &CanonicalDerivedNetworkPolicy,
|
||||
) -> Result<(), StateAnchorError> {
|
||||
let resolv_conf = policy
|
||||
.policy()
|
||||
.resolvers
|
||||
.iter()
|
||||
.map(|resolver| match resolver.address {
|
||||
IpAddress::V4(address) => format!("nameserver {}\n", Ipv4Addr::from(address)),
|
||||
IpAddress::V6(address) => format!("nameserver {}\n", Ipv6Addr::from(address)),
|
||||
})
|
||||
.collect::<String>();
|
||||
layout.replace_protected_runtime_files(&ProtectedRuntimeFiles {
|
||||
resolv_conf: resolv_conf.as_bytes(),
|
||||
hosts: b"127.0.0.1 localhost\n",
|
||||
hostname: b"lazaret\n",
|
||||
})
|
||||
}
|
||||
Loading…
Reference in a new issue