Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions crates/openshell-sandbox/src/sandbox/linux/landlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use landlock::{
};
use miette::{IntoDiagnostic, Result};
use std::path::PathBuf;
use tracing::debug;
use tracing::{debug, info, warn};

pub fn apply(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<()> {
let read_only = policy.filesystem.read_only.clone();
Expand All @@ -29,8 +29,16 @@ pub fn apply(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<()> {
return Ok(());
}

let abi = ABI::V2;
info!(
abi = ?abi,
compatibility = ?policy.landlock.compatibility,
read_only_paths = read_only.len(),
read_write_paths = read_write.len(),
"Applying Landlock filesystem sandbox"
);

let result: Result<()> = (|| {
let abi = ABI::V2;
let access_all = AccessFs::from_all(abi);
let access_read = AccessFs::from_read(abi);

Expand Down Expand Up @@ -71,7 +79,11 @@ pub fn apply(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<()> {
policy.landlock.compatibility,
LandlockCompatibility::BestEffort
) {
debug!(error = %err, "Landlock unavailable, continuing without filesystem sandbox");
warn!(
error = %err,
"Landlock filesystem sandbox is UNAVAILABLE — running WITHOUT filesystem restrictions. \
Set landlock.compatibility to 'hard_requirement' to make this a fatal error."
);
return Ok(());
}
return Err(err);
Expand Down
Loading