microsoft / microsoft/mxc

inheritDefaultEnv is not honored on IsolationSession or WSLc

Open
#1,165 0 comments 0 reactions 1 assignee Claimed by @adpa-ms View on GitHub
Issue-Bug OS-Windows
Dominant language
Rust
Stars
1.3k
Forks
79
Avg merge
2d 7h
Merged PRs (30d)
117

Description

### Relevant area(s)

Windows

### Brief description of your issue

#1153 gave LXC, Bubblewrap, and Seatbelt the schema-0.9 `process.inheritDefaultEnv` contract that #1120 shipped for the Windows ProcessContainer tiers. IsolationSession and WSLc were left out and still flatten the four states into two.

The contract the other backends now honor:

| `process.env` | `inheritDefaultEnv` | Result |
| --- | --- | --- |
| omitted | — | the backend default |
| `[]` | — | empty |
| `["FOO=bar"]` | `false` (default) | verbatim |
| `["FOO=bar"]` | `true` | layered over the default; a caller entry wins |

**IsolationSession** (`src/backends/isolation_session/common/src/process_options.rs:179-187`) fetches `proc_options.Environment()` and *inserts* into it, so it behaves as permanently `inheritDefaultEnv: true`. A caller who asks for a verbatim environment — which is the default — silently gets the session''s full default environment merged in. `IMap::Clear()` is available for the replace case.

**WSLc** (`src/backends/wslc/common/src/wsl_container_runner.rs:1490`, `src/backends/wslc/common/src/container_steps.rs:404`) guards the SDK call with `if !effective_env.is_empty()`, flattening omitted and `[]` together. Whether `WslcSetProcessSettingsEnvVariables` replaces or augments the image environment is undocumented — `wslcsdk.h:343` has no comment — so that needs to be established first. If it augments, `Explicit` may not be honorable and should be rejected rather than silently downgraded.

Both backends currently use `ExecutionRequest::env_entries()`, whose doc comment now names them as the remaining callers.

### Steps to reproduce

1. Build with `--features isolation_session`.
2. Run a `0.9.0-alpha` config against `containment: "isolationsession"` with `process.env` set to `["FOO=bar"]` and no `inheritDefaultEnv`.
3. Have the command print its full environment.

### Expected behavior

Only `FOO` is present — the environment is used verbatim, as it is on every other backend at 0.9.

### Actual behavior

`FOO` is present alongside the isolation session''s entire default environment.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.