Decouple client contracts and close private role registries
This commit is contained in:
parent
786049534d
commit
22325aa76a
1 changed files with 1041 additions and 321 deletions
|
|
@ -8,19 +8,17 @@ use std::os::unix::fs::MetadataExt;
|
|||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
||||
use lazaret_control_client::{ControlClient, ControlClientError};
|
||||
use lazaret_core::configuration::{
|
||||
ConfigurationLoadRequest, ResolvedDomainConfiguration, load_trusted_configuration,
|
||||
};
|
||||
use lazaret_host_coordinator::client_bootstrap::PRIVATE_CLIENT_BOOTSTRAP_ROLE;
|
||||
use lazaret_host_coordinator::control::{ControlError, PublishedControlFace};
|
||||
use lazaret_host_coordinator::waiter::{
|
||||
BOOTSTRAP_WAITER_SOCKET_NAME, BootstrapWaitOutcome, BootstrapWaitRequest, read_frame,
|
||||
write_frame,
|
||||
use lazaret_core::protocol::{
|
||||
BOOTSTRAP_WAITER_SOCKET_NAME, BootstrapWaitOutcome, BootstrapWaitRequest,
|
||||
PRIVATE_CLIENT_BOOTSTRAP_ROLE, read_waiter_frame, write_waiter_frame,
|
||||
};
|
||||
use lazaret_linux::filesystem::try_exclusive_flock;
|
||||
use lazaret_linux::platform::{PlatformObservation, check_platform};
|
||||
use lazaret_linux::process::{BootstrapChild, TargetCommand, child_broker};
|
||||
use lazaret_runtime_supervisor::sandbox::default_sandbox_layout;
|
||||
use rustix::fs::{Mode, OFlags, openat};
|
||||
use rustix::pipe::{PipeFlags, pipe_with};
|
||||
|
||||
|
|
@ -80,7 +78,7 @@ impl CoordinatorClientBackend {
|
|||
|
||||
fn discover(&self) -> Result<Discovery, CoordinatorClientError> {
|
||||
let configuration = self.configuration()?;
|
||||
match PublishedControlFace::discover_confined(
|
||||
match ControlClient::discover_confined(
|
||||
configuration.runtime_domain_root(),
|
||||
rustix::process::getuid().as_raw(),
|
||||
) {
|
||||
|
|
@ -96,7 +94,7 @@ impl CoordinatorClientBackend {
|
|||
authority,
|
||||
))))
|
||||
}
|
||||
Err(ControlError::Io(error)) if error.kind() == io::ErrorKind::NotFound => {
|
||||
Err(ControlClientError::Io(error)) if error.kind() == io::ErrorKind::NotFound => {
|
||||
Ok(Discovery::Absent)
|
||||
}
|
||||
Ok(_) | Err(_) => Ok(Discovery::Stale),
|
||||
|
|
@ -292,17 +290,17 @@ impl CoordinatorClientBackend {
|
|||
.set_read_timeout(Some(observation_remaining(observer)?))
|
||||
.map_err(failure)
|
||||
.map_err(ClientError::Backend)?;
|
||||
write_frame(&mut stream, request).map_err(|error| {
|
||||
write_waiter_frame(&mut stream, request).map_err(|error| {
|
||||
ClientError::Backend(failure(format!("bootstrap waiter request failed: {error}")))
|
||||
})?;
|
||||
let first: BootstrapWaitOutcome = read_frame(&mut stream).map_err(|error| {
|
||||
let first: BootstrapWaitOutcome = read_waiter_frame(&mut stream).map_err(|error| {
|
||||
ClientError::Backend(failure(format!(
|
||||
"bootstrap waiter admission failed: {error}"
|
||||
)))
|
||||
})?;
|
||||
let mut action = observer.waiter(first, false);
|
||||
if action == WaiterAction::AwaitTerminal {
|
||||
action = match read_frame(&mut stream) {
|
||||
action = match read_waiter_frame(&mut stream) {
|
||||
Ok(outcome) => observer.waiter(outcome, true),
|
||||
Err(_) => WaiterAction::RefuseFailed,
|
||||
};
|
||||
|
|
@ -465,7 +463,7 @@ pub(crate) fn load_configuration(
|
|||
xdg_data_home: optional_environment_path("XDG_DATA_HOME"),
|
||||
xdg_runtime_dir: required_environment_path("XDG_RUNTIME_DIR")?,
|
||||
environment: environment(),
|
||||
sandbox_layout: default_sandbox_layout()?,
|
||||
sandbox_layout: lazaret_core::configuration::SandboxLayoutV1::default_layout()?,
|
||||
})?)
|
||||
}
|
||||
|
||||
|
|
@ -558,7 +556,7 @@ mod tests {
|
|||
fs::create_dir(&runtime_path).unwrap();
|
||||
fs::set_permissions(&runtime_path, fs::Permissions::from_mode(0o700)).unwrap();
|
||||
assert!(
|
||||
PublishedControlFace::discover_confined(
|
||||
ControlClient::discover_confined(
|
||||
runtime_configuration.runtime_domain_root(),
|
||||
rustix::process::getuid().as_raw(),
|
||||
)
|
||||
|
|
@ -615,7 +613,7 @@ mod tests {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let (authority, socket, observed) = PublishedControlFace::discover_confined(
|
||||
let (authority, socket, observed) = ControlClient::discover_confined(
|
||||
configuration.runtime_domain_root(),
|
||||
rustix::process::getuid().as_raw(),
|
||||
)
|
||||
|
|
@ -690,7 +688,7 @@ mod tests {
|
|||
xdg_data_home: None,
|
||||
xdg_runtime_dir: runtime,
|
||||
environment: BTreeMap::new(),
|
||||
sandbox_layout: default_sandbox_layout().unwrap(),
|
||||
sandbox_layout: lazaret_core::configuration::SandboxLayoutV1::default_layout().unwrap(),
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue