Honor per-environment login shell policy (#36811)

## What changed

- Store the effective `allow_login_shell` setting on each turn environment, including inherited environments whose child thread has a different policy.
- Expose the `login` argument for shell tools when any selected environment permits login shells.
- Validate each command against the policy of its selected environment instead of the turn-wide configuration.

## Testing

- Cover tool schema generation for single and multiple environments.
- Cover login-shell rejection by both the command handler and the unified exec integration.

GitOrigin-RevId: 5a93149a5c86f4087f2b92d663ebc33feff8a57c
This commit is contained in:
sayan-oai authored and copyberry committed 2026-08-03 23:33:05 +00:00
1 parent 61dc1d97f6
commit b258c028fe
18 files changed
+291 -28

No files matched your search

@@ -1,4 +1,5 @@
use super::*;
use crate::session::turn_context::EnvironmentConfig;
use crate::tools::sandboxing::SandboxAttempt;
use codex_protocol::config_types::WindowsSandboxLevel;
use codex_protocol::models::AdditionalPermissionProfile;
@@ -21,6 +22,9 @@ fn test_turn_environment(environment_id: &str) -> crate::session::turn_context::
PathUri::from_abs_path(&std::env::temp_dir().abs()),
Vec::new(),
/*shell*/ None,
EnvironmentConfig {
allow_login_shell: true,
},
)
}
@@ -1,4 +1,5 @@
use super::*;
use crate::session::turn_context::EnvironmentConfig;
use codex_exec_server::Environment;
use codex_utils_path_uri::PathUri;
use pretty_assertions::assert_eq;
@@ -16,6 +17,9 @@ async fn approval_key_uses_path_uri_and_includes_environment_id() {
PathUri::from_abs_path(&cwd),
Vec::new(),
/*shell*/ None,
EnvironmentConfig {
allow_login_shell: true,
},
),
shell_type: None,
hook_command: "echo hello".to_string(),
@@ -549,6 +549,7 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecProcess> for UnifiedExecRunt
mod tests {
use super::*;
use crate::exec::DEFAULT_EXEC_COMMAND_TIMEOUT_MS;
use crate::session::turn_context::EnvironmentConfig;
use crate::tools::sandboxing::ToolRuntime;
use codex_exec_server::Environment;
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
@@ -566,6 +567,9 @@ mod tests {
cwd,
Vec::new(),
/*shell*/ None,
EnvironmentConfig {
allow_login_shell: true,
},
)
}