Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions crates/openshell-sandbox/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,14 @@ impl ProcessHandle {
}

let child = cmd.spawn().into_diagnostic()?;
let pid = child.id().unwrap_or(0);
let pid = child.id().ok_or_else(|| {
miette::miette!(
"Entrypoint process exited immediately after spawn (exec failed). \
This typically means Landlock denied execute access to the entrypoint binary. \
Check that the sandbox policy grants execute permission on the entrypoint path. \
[program={program}]"
)
})?;
register_managed_child(pid);

debug!(pid, program, "Process spawned");
Expand Down Expand Up @@ -416,7 +423,13 @@ impl ProcessHandle {
}

let child = cmd.spawn().into_diagnostic()?;
let pid = child.id().unwrap_or(0);
let pid = child.id().ok_or_else(|| {
miette::miette!(
"Entrypoint process exited immediately after spawn (exec failed). \
This typically means the sandbox denied execute access to the entrypoint binary. \
[program={program}]"
)
})?;
#[cfg(target_os = "linux")]
register_managed_child(pid);

Expand Down
4 changes: 2 additions & 2 deletions crates/openshell-sandbox/src/sandbox/linux/landlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub fn prepare(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<Option<P

let result: Result<PreparedRuleset> = (|| {
let access_all = AccessFs::from_all(abi);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider a brief comment explaining why Execute is added to read-only paths — a future reader might wonder whether this was intentional broadening or an oversight. Something like:

// Execute needed: entrypoint and SSH sessions must run binaries from these paths
let access_read = AccessFs::from_read(abi) | AccessFs::Execute;

Not blocking — the commit message documents the rationale, but inline context helps too.

let access_read = AccessFs::from_read(abi);
let access_read = AccessFs::from_read(abi) | AccessFs::Execute;

let mut ruleset = Ruleset::default();
ruleset = ruleset
Expand All @@ -189,7 +189,7 @@ pub fn prepare(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<Option<P

for path in &read_only {
if let Some(path_fd) = try_open_path(path, compatibility)? {
debug!(path = %path.display(), "Landlock allow read-only");
debug!(path = %path.display(), "Landlock allow read-only+execute");
ruleset = ruleset
.add_rule(PathBeneath::new(path_fd, access_read))
.into_diagnostic()?;
Expand Down
Loading