Consume shared sandbox destinations at runtime boundaries

This commit is contained in:
ms2k 2026-07-19 05:25:32 +09:00
commit 897578e7cb
6 changed files with 23 additions and 12 deletions

2
Cargo.lock generated
View file

@ -1702,6 +1702,7 @@ dependencies = [
"getrandom 0.4.3", "getrandom 0.4.3",
"lazaret-core", "lazaret-core",
"lazaret-linux", "lazaret-linux",
"lazaret-sandbox-contract",
"nix 0.31.3", "nix 0.31.3",
"rustix", "rustix",
"serde", "serde",
@ -1722,6 +1723,7 @@ dependencies = [
"lazaret-linux", "lazaret-linux",
"lazaret-prepared-lower", "lazaret-prepared-lower",
"lazaret-runtime-supervisor", "lazaret-runtime-supervisor",
"lazaret-sandbox-contract",
"lazaret-state-anchor", "lazaret-state-anchor",
"lazaret-storage-catalog", "lazaret-storage-catalog",
"rcgen", "rcgen",

View file

@ -14,6 +14,7 @@ ed25519-dalek.workspace = true
getrandom.workspace = true getrandom.workspace = true
lazaret-core = { version = "=0.0.0", path = "../lazaret-core" } lazaret-core = { version = "=0.0.0", path = "../lazaret-core" }
lazaret-linux = { version = "=0.0.0", path = "../lazaret-linux" } lazaret-linux = { version = "=0.0.0", path = "../lazaret-linux" }
lazaret-sandbox-contract = { version = "=0.0.0", path = "../lazaret-sandbox-contract" }
nix.workspace = true nix.workspace = true
rustix.workspace = true rustix.workspace = true
serde.workspace = true serde.workspace = true

View file

@ -14,6 +14,9 @@ use lazaret_core::records::{
}; };
use lazaret_escalation_client::{ClientEvent, EscalationClient}; use lazaret_escalation_client::{ClientEvent, EscalationClient};
use lazaret_linux::filesystem::RegularFileMailbox; use lazaret_linux::filesystem::RegularFileMailbox;
use lazaret_sandbox_contract::{
CREDENTIALS_DESTINATION, MAILBOX_REQUESTS_DESTINATION, MAILBOX_RESULTS_DESTINATION,
};
use nix::sys::signal::{SigSet, SigmaskHow, Signal}; use nix::sys::signal::{SigSet, SigmaskHow, Signal};
use nix::sys::signalfd::{SfdFlags, SignalFd}; use nix::sys::signalfd::{SfdFlags, SignalFd};
@ -248,9 +251,9 @@ fn parse_arguments_with_session(
{ {
return Err(io::Error::other("LAZARET_SESSION_ID is invalid")); return Err(io::Error::other("LAZARET_SESSION_ID is invalid"));
} }
let credentials = PathBuf::from("/run/lazaret/credentials"); let credentials = PathBuf::from(CREDENTIALS_DESTINATION);
inbox.get_or_insert_with(|| PathBuf::from("/run/lazaret/mailbox/requests")); inbox.get_or_insert_with(|| PathBuf::from(MAILBOX_REQUESTS_DESTINATION));
outbox.get_or_insert_with(|| PathBuf::from("/run/lazaret/mailbox/results")); outbox.get_or_insert_with(|| PathBuf::from(MAILBOX_RESULTS_DESTINATION));
publication.get_or_insert_with(|| credentials.join("publication.postcard")); publication.get_or_insert_with(|| credentials.join("publication.postcard"));
sandbox_credentials.get_or_insert_with(|| credentials.join("sandbox-credentials.postcard")); sandbox_credentials.get_or_insert_with(|| credentials.join("sandbox-credentials.postcard"));
registration.get_or_insert_with(|| { registration.get_or_insert_with(|| {
@ -277,6 +280,9 @@ fn parse_arguments_with_session(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::parse_arguments_with_session; use super::parse_arguments_with_session;
use lazaret_sandbox_contract::{
CREDENTIALS_DESTINATION, MAILBOX_REQUESTS_DESTINATION, MAILBOX_RESULTS_DESTINATION,
};
use std::ffi::OsString; use std::ffi::OsString;
fn valid_arguments() -> Vec<OsString> { fn valid_arguments() -> Vec<OsString> {
@ -344,17 +350,18 @@ mod tests {
parse_arguments_with_session(arguments, Some(OsString::from(&session))).unwrap(); parse_arguments_with_session(arguments, Some(OsString::from(&session))).unwrap();
assert_eq!( assert_eq!(
parsed.inbox, parsed.inbox,
std::path::Path::new("/run/lazaret/mailbox/requests") std::path::Path::new(MAILBOX_REQUESTS_DESTINATION)
); );
assert_eq!( assert_eq!(
parsed.outbox, parsed.outbox,
std::path::Path::new("/run/lazaret/mailbox/results") std::path::Path::new(MAILBOX_RESULTS_DESTINATION)
); );
assert_eq!( assert_eq!(
parsed.registration, parsed.registration,
std::path::Path::new(&format!( std::path::Path::new(
"/run/lazaret/credentials/session-{session}-registration.postcard" &std::path::Path::new(CREDENTIALS_DESTINATION)
)) .join(format!("session-{session}-registration.postcard"))
)
); );
let arguments = ["--justification", "needed", "--", "/usr/bin/tool"] let arguments = ["--justification", "needed", "--", "/usr/bin/tool"]

View file

@ -29,6 +29,7 @@ lazaret-ignored-workspace = { version = "=0.0.0", path = "../lazaret-ignored-wor
lazaret-linux = { version = "=0.0.0", path = "../lazaret-linux" } lazaret-linux = { version = "=0.0.0", path = "../lazaret-linux" }
lazaret-prepared-lower = { version = "=0.0.0", path = "../lazaret-prepared-lower" } lazaret-prepared-lower = { version = "=0.0.0", path = "../lazaret-prepared-lower" }
lazaret-runtime-supervisor = { version = "=0.0.0", path = "../lazaret-runtime-supervisor" } lazaret-runtime-supervisor = { version = "=0.0.0", path = "../lazaret-runtime-supervisor" }
lazaret-sandbox-contract = { version = "=0.0.0", path = "../lazaret-sandbox-contract" }
lazaret-state-anchor = { version = "=0.0.0", path = "../lazaret-state-anchor" } lazaret-state-anchor = { version = "=0.0.0", path = "../lazaret-state-anchor" }
lazaret-storage-catalog = { version = "=0.0.0", path = "../lazaret-storage-catalog" } lazaret-storage-catalog = { version = "=0.0.0", path = "../lazaret-storage-catalog" }
rcgen.workspace = true rcgen.workspace = true

View file

@ -25,6 +25,7 @@ use lazaret_linux::process::{
ChildStandardIo, ProcessExit, ProcessOwnershipContext, RetainedProcess, TargetCommand, ChildStandardIo, ProcessExit, ProcessOwnershipContext, RetainedProcess, TargetCommand,
child_broker, current_process_identity, child_broker, current_process_identity,
}; };
use lazaret_sandbox_contract::SANDBOX_INIT_DESTINATION;
use rustix::fs::{OFlags, fcntl_getfl, fcntl_setfl, fstat}; use rustix::fs::{OFlags, fcntl_getfl, fcntl_setfl, fstat};
use rustix::pty::{OpenptFlags, grantpt, ioctl_tiocgptpeer, openpt, unlockpt}; use rustix::pty::{OpenptFlags, grantpt, ioctl_tiocgptpeer, openpt, unlockpt};
use rustix::termios::{Winsize, tcsetwinsize}; use rustix::termios::{Winsize, tcsetwinsize};
@ -42,7 +43,6 @@ const POLL_INTERVAL: Duration = Duration::from_millis(5);
const IDENTITY_DEADLINE: Duration = Duration::from_secs(5); const IDENTITY_DEADLINE: Duration = Duration::from_secs(5);
const SIGNAL_GRACE: Duration = Duration::from_millis(250); const SIGNAL_GRACE: Duration = Duration::from_millis(250);
const DRAIN_DEADLINE: Duration = Duration::from_millis(250); const DRAIN_DEADLINE: Duration = Duration::from_millis(250);
const SANDBOX_INIT_PATH: &str = "/run/lazaret/bin/lazaret-sandbox-init";
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TerminalRoute { pub enum TerminalRoute {

View file

@ -4,7 +4,7 @@ use super::{
HostCoordinatorTerminalRecorder, IDENTITY_DEADLINE, InodeId, Instant, Mutex, OFlags, HostCoordinatorTerminalRecorder, IDENTITY_DEADLINE, InodeId, Instant, Mutex, OFlags,
OpenptFlags, OsString, POLL_INTERVAL, PRIVATE_SESSION_EXEC_ROLE, PRIVATE_SESSION_IDENTITY_ROLE, OpenptFlags, OsString, POLL_INTERVAL, PRIVATE_SESSION_EXEC_ROLE, PRIVATE_SESSION_IDENTITY_ROLE,
PersistedHostProcessOwnership, PidfsProcessIdentityV1, ProcessExit, ProcessOwnershipCommitAck, PersistedHostProcessOwnership, PidfsProcessIdentityV1, ProcessExit, ProcessOwnershipCommitAck,
ProcessOwnershipContext, PtyIdentity, RetainedProcess, SANDBOX_INIT_PATH, SessionId, ProcessOwnershipContext, PtyIdentity, RetainedProcess, SANDBOX_INIT_DESTINATION, SessionId,
SessionTerminal, SessionTerminalFactory, SessionTerminalFields, SessionTerminalProcess, SessionTerminal, SessionTerminalFactory, SessionTerminalFields, SessionTerminalProcess,
SessionTerminalState, StagedProcessOwnership, TargetCommand, TerminalAcquisition, SessionTerminalState, StagedProcessOwnership, TargetCommand, TerminalAcquisition,
TerminalError, TerminalResize, Winsize, child_broker, current_process_identity, fcntl_getfl, TerminalError, TerminalResize, Winsize, child_broker, current_process_identity, fcntl_getfl,
@ -57,7 +57,7 @@ impl SessionTerminalFactory for RunscSessionTerminalFactory {
hex_lower(request.session_id.as_bytes()) hex_lower(request.session_id.as_bytes())
)) ))
.argument(hex_lower(request.container_id.as_bytes())) .argument(hex_lower(request.container_id.as_bytes()))
.argument(SANDBOX_INIT_PATH) .argument(SANDBOX_INIT_DESTINATION)
.argument(PRIVATE_SESSION_EXEC_ROLE) .argument(PRIVATE_SESSION_EXEC_ROLE)
.argument("--"); .argument("--");
for argument in &request.argv { for argument in &request.argv {
@ -540,7 +540,7 @@ fn run_guest_identity_query(
target = target target = target
.argument("exec") .argument("exec")
.argument(hex_lower(request.container_id.as_bytes())) .argument(hex_lower(request.container_id.as_bytes()))
.argument(SANDBOX_INIT_PATH) .argument(SANDBOX_INIT_DESTINATION)
.argument(PRIVATE_SESSION_IDENTITY_ROLE); .argument(PRIVATE_SESSION_IDENTITY_ROLE);
for argument in arguments { for argument in arguments {
target = target.argument(argument.clone()); target = target.argument(argument.clone());