Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[LXC] Honor process.cwd and process.env in the LXC backend#494

Open
SohamDas2021 wants to merge 3 commits into
mainmicrosoft/mxc:mainfrom
fix/lxc-cwd-envmicrosoft/mxc:fix/lxc-cwd-envCopy head branch name to clipboard
Open

[LXC] Honor process.cwd and process.env in the LXC backend#494
SohamDas2021 wants to merge 3 commits into
mainmicrosoft/mxc:mainfrom
fix/lxc-cwd-envmicrosoft/mxc:fix/lxc-cwd-envCopy head branch name to clipboard

Conversation

@SohamDas2021
Copy link
Copy Markdown
Contributor

@SohamDas2021 SohamDas2021 commented Jun 4, 2026

📖 Description

Fixes two silent-contract violations in the LXC backend: process.cwd and process.env from the config were both ignored, so every container ran from / with no user-supplied environment regardless of what the JSON requested.

🔗 References

🔍 Validation

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task

Microsoft reviewers: PR builds don't auto-run (ADO policy). Comment /azp run
to start MXC-PR-Build. See docs/pull-requests.md.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings June 4, 2026 17:30
@SohamDas2021 SohamDas2021 requested a review from a team as a code owner June 4, 2026 17:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two contract violations in the Linux LXC backend by ensuring process.cwd and process.env from the config are actually applied when executing inside the container, and adds targeted tests to prevent regressions.

Changes:

  • Pass ExecutionRequest.env through the LXC runner into the lxc-attach invocation.
  • Honor process.cwd by wrapping the inner command with a cd prelude that avoids additional shell-escaping needs.
  • Add a new LXC env+cowd regression test (config + runner script) and include it in the LXC test suite.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/scripts/run_lxc_env_cwd_test.sh Adds a regression script that exercises process.cwd and process.env end-to-end via lxc-exec.
tests/scripts/run_lxc_all_tests.sh Wires the new env+cwd test into the overall LXC test runner.
tests/configs/lxc_env_cwd_test.json Adds a config that self-validates cwd and env propagation inside the container via distinct exit codes.
src/backends/lxc/common/src/lxc_runner.rs Ensures the LXC backend passes request env/cwd into container execution.
src/backends/lxc/common/src/lxc_bindings.rs Implements env (--set-var=...) and cwd plumbing for lxc-attach, with unit tests for argv construction.

@SohamDas2021 SohamDas2021 requested review from bbonaby and huzaifa-d June 4, 2026 18:10
@SohamDas2021
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

fn build_attach_args(env: &[String], working_directory: &str, command: &str) -> Vec<String> {
let mut args: Vec<String> = Vec::with_capacity(env.len() + 6);

// Each `KEY=VAL` becomes a separate `--set-var=KEY=VAL`. Skip entries
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: wonder if we should print a warning when we do things like skipping.

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.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.