Skip to content
Open
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
19 changes: 14 additions & 5 deletions codex-rs/core/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ pub(crate) fn is_likely_sandbox_denied(
// 2: misuse of shell builtins
// 126: permission denied
// 127: command not found
const QUICK_REJECT_EXIT_CODES: [i32; 3] = [2, 126, 127];
if QUICK_REJECT_EXIT_CODES.contains(&exec_output.exit_code) {
return false;
}

const SANDBOX_DENIED_KEYWORDS: [&str; 7] = [
"operation not permitted",
"permission denied",
Expand Down Expand Up @@ -437,11 +442,6 @@ pub(crate) fn is_likely_sandbox_denied(
return true;
}

const QUICK_REJECT_EXIT_CODES: [i32; 3] = [2, 126, 127];
if QUICK_REJECT_EXIT_CODES.contains(&exec_output.exit_code) {
return false;
}

#[cfg(unix)]
{
const SIGSYS_CODE: i32 = libc::SIGSYS;
Expand Down Expand Up @@ -827,6 +827,15 @@ mod tests {
));
}

#[test]
fn sandbox_detection_ignores_keywords_for_quick_reject_exit_codes() {
let output = make_exec_output(126, "", "Permission denied", "");
assert!(!is_likely_sandbox_denied(
SandboxType::LinuxSeccomp,
&output
));
}

#[test]
fn sandbox_detection_ignores_non_sandbox_mode() {
let output = make_exec_output(1, "", "Operation not permitted", "");
Expand Down
Loading