mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
Preserve Windows environment variables for remote MCP servers (#50129)
## Why When Codex runs on Unix and launches a stdio MCP server on a Windows executor, explicit remote environment variables activate an allowlist based on Unix defaults. This can filter out Windows runtime and temporary-directory variables. ## What changed Include `SYSTEMROOT`, `TEMP`, and `TMP` in the remote environment allowlist whenever explicit remote variables are requested. ## Testing Extend the environment-filtering test to verify that `SystemRoot`, `TEMP`, and `TMP` survive alongside requested variables while unrequested secrets remain excluded. GitOrigin-RevId: 059c9e23833be66aaf5b65ba5f95013f94f0f792
This commit is contained in:
@@ -687,8 +687,12 @@ impl ExecutorStdioServerLauncher {
|
||||
// environment, not copied from Codex. Start from `All` only so the
|
||||
// named remote variable is available to the filter below; the
|
||||
// effective child env is still limited by `include_only`.
|
||||
// The orchestrator may be Unix while the executor is Windows.
|
||||
// Preserve Windows runtime initialization and temporary-directory
|
||||
// inputs even when explicit remote vars activate this allowlist.
|
||||
crate::utils::DEFAULT_ENV_VARS
|
||||
.iter()
|
||||
.chain(["SYSTEMROOT", "TEMP", "TMP"].iter())
|
||||
.map(|name| (*name).to_string())
|
||||
.chain(remote_env_vars.iter().cloned())
|
||||
.collect()
|
||||
@@ -763,6 +767,15 @@ mod tests {
|
||||
let env = shell_environment::create_env_from_vars(
|
||||
[
|
||||
("PATH".to_string(), "/remote/bin".to_string()),
|
||||
("SystemRoot".to_string(), r"C:\Windows".to_string()),
|
||||
(
|
||||
"TEMP".to_string(),
|
||||
r"C:\Users\test\AppData\Local\Temp".to_string(),
|
||||
),
|
||||
(
|
||||
"TMP".to_string(),
|
||||
r"C:\Users\test\AppData\Local\Temp".to_string(),
|
||||
),
|
||||
("REMOTE_TOKEN".to_string(), "remote-secret".to_string()),
|
||||
(
|
||||
"UNREQUESTED_SECRET".to_string(),
|
||||
@@ -774,6 +787,16 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_eq!(env.get("PATH").map(String::as_str), Some("/remote/bin"));
|
||||
assert_eq!(
|
||||
env.get("SystemRoot").map(String::as_str),
|
||||
Some(r"C:\Windows")
|
||||
);
|
||||
for name in ["TEMP", "TMP"] {
|
||||
assert_eq!(
|
||||
env.get(name).map(String::as_str),
|
||||
Some(r"C:\Users\test\AppData\Local\Temp")
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
env.get("REMOTE_TOKEN").map(String::as_str),
|
||||
Some("remote-secret")
|
||||
|
||||
Reference in New Issue
Block a user