Skip to content

AppcontainerRunner: pass explicit env block to CreateProcess#386

Merged
jsidewhite merged 1 commit into
mainfrom
jsidewhite/env_from_sdk_to_cpis_ACR_PR
May 22, 2026
Merged

AppcontainerRunner: pass explicit env block to CreateProcess#386
jsidewhite merged 1 commit into
mainfrom
jsidewhite/env_from_sdk_to_cpis_ACR_PR

Conversation

@jsidewhite

@jsidewhite jsidewhite commented May 22, 2026

Copy link
Copy Markdown
Member

When process.env is specified in the config, encode it as a UTF-16 environment block and pass it to CreateProcess with CREATE_UNICODE_ENVIRONMENT. When empty, pass NULL (OS default).

#346

Microsoft Reviewers: Open in CodeFlow

When process.env is specified in the config, encode it as a UTF-16 environment block and pass it to CreateProcess with CREATE_UNICODE_ENVIRONMENT. When empty, pass NULL (OS default).
Copilot AI review requested due to automatic review settings May 22, 2026 05:10
@kanismohammed kanismohammed requested a review from a team May 22, 2026 05:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the Windows AppContainer runner to optionally pass an explicit UTF-16 environment block to CreateProcessW (with CREATE_UNICODE_ENVIRONMENT) when process.env is provided in the config, including proxy env-var injection without mutating global process state.

Changes:

  • Refactors env handling into encode_env_block() (UTF-16 env block serialization) and build_explicit_entries() (parse KEY=VALUE, inject/override proxy vars).
  • Wires the encoded env block into the CreateProcessW call when applicable; otherwise passes NULL to inherit the default environment.
Show a summary per file
File Description
src/wxc_common/src/appcontainer_runner.rs Adds explicit env-block encoding/parsing and uses it when spawning the AppContainer child process.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 3

Comment on lines 53 to 62
@@ -81,6 +61,36 @@ fn build_proxy_env_block(address: &crate::models::ProxyAddress) -> Vec<u16> {
block
}
Comment on lines +404 to +417
let env_block: Option<Vec<u16>> = if !request.env.is_empty() {
let entries = build_explicit_entries(&request.env, self.proxy_address.as_ref());
Some(encode_env_block(&entries))
} else if let Some(addr) = self.proxy_address.as_ref() {
// No explicit env but proxy is active -- inject only proxy vars.
let proxy_url = addr.to_url();
let entries = vec![
("HTTP_PROXY".to_string(), proxy_url.clone()),
("HTTPS_PROXY".to_string(), proxy_url),
];
Some(encode_env_block(&entries))
} else {
None
};
Comment on lines +400 to +403
// Environment block for the sandboxed child.
// If explicit env vars were provided, use only those (+ proxy injection).
// If only proxy is active (no explicit env), build a block with just proxy vars.
// Otherwise, pass NULL to inherit the default environment.
Comment on lines +400 to +417
// Environment block for the sandboxed child.
// If explicit env vars were provided, use only those (+ proxy injection).
// If only proxy is active (no explicit env), build a block with just proxy vars.
// Otherwise, pass NULL to inherit the default environment.
let env_block: Option<Vec<u16>> = if !request.env.is_empty() {
let entries = build_explicit_entries(&request.env, self.proxy_address.as_ref());
Some(encode_env_block(&entries))
} else if let Some(addr) = self.proxy_address.as_ref() {
// No explicit env but proxy is active -- inject only proxy vars.
let proxy_url = addr.to_url();
let entries = vec![
("HTTP_PROXY".to_string(), proxy_url.clone()),
("HTTPS_PROXY".to_string(), proxy_url),
];
Some(encode_env_block(&entries))
} else {
None
};

@bbonaby bbonaby May 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thought: we should probably do the same thing for base container. Adding the proxy env variables I mean, if they give it to us. If you can we can add it to #385 before we check it in

@jsidewhite jsidewhite merged commit a2c2538 into main May 22, 2026
19 checks passed
@jsidewhite jsidewhite deleted the jsidewhite/env_from_sdk_to_cpis_ACR_PR branch May 22, 2026 17:05
@jsidewhite

Copy link
Copy Markdown
Member Author

Closes: #346

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants