Preserve Azure CLI user environment on POSIX - #7317
Open
Akın Soysal (akeensoysal) wants to merge 2 commits into
Open
Preserve Azure CLI user environment on POSIX#7317Akın Soysal (akeensoysal) wants to merge 2 commits into
Akın Soysal (akeensoysal) wants to merge 2 commits into
Conversation
Forward the allowlisted home, cache, and Azure CLI config paths to spawned CLI processes so authentication does not create relative telemetry paths or ignore custom config directories.\n\nFixes Azure#7316
Akın Soysal (akeensoysal)
requested review from
a team,
Larry Osterman (LarryOsterman),
Rick Winter (RickWinter),
Anton Kolesnyk (antkmsft) and
Jeff Fisher (xirzec)
as code owners
August 12, 2026 09:12
|
Thank you for your contribution Akın Soysal (@akeensoysal)! We will review the pull request and get back to you soon. |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 7 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates AzureCliCredential on POSIX to preserve a small allowlist of user-environment variables (HOME, XDG_CACHE_HOME, AZURE_CONFIG_DIR) when spawning the restricted child process, preventing Azure CLI from writing telemetry/cache files into the caller’s working directory and ensuring custom Azure CLI config locations remain usable.
Changes:
- Propagate
HOME,XDG_CACHE_HOME, andAZURE_CONFIG_DIRinto the POSIXposix_spawnenvironment allowlist (while still not inheriting the full parent environment). - Add a focused unit test validating the allowlisted variables are visible inside the POSIX child process.
- Add a changelog entry describing the bug fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/identity/azure-identity/src/azure_cli_credential.cpp | Extends the restricted POSIX child environment to include HOME, XDG_CACHE_HOME, and AZURE_CONFIG_DIR. |
| sdk/identity/azure-identity/test/ut/azure_cli_credential_test.cpp | Adds a POSIX-only unit test ensuring the allowlisted environment variables are propagated to the child process. |
| sdk/identity/azure-identity/CHANGELOG.md | Documents the fix under the unreleased version’s “Bugs Fixed” section. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Remove the incorrect statement that envp begins with a program path. POSIX envp contains only key-value entries followed by a null pointer.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HOME,XDG_CACHE_HOME, andAZURE_CONFIG_DIRin the restricted POSIX child environment used byAzureCliCredential../None/.cache/...under the caller's working directory and preserve custom Azure CLI config locations.Fixes #7316
Validation
AzureCliCredential.PosixChildEnvironmentfailed withenvironment variables not propagated.ctest --test-dir build --output-on-failure -R 'azure-identity\.AzureCliCredential': 31/31 passed.ctest --test-dir build --output-on-failure -E 'LIVEONLY_' -j1: 192/192 passed; two tests skipped by their own runtime conditions.AzureCliCredentialstorage-token probe: token acquired; no relativeNonedirectory created.clang-format-11 --dry-run --Werroron both changed C++ files.git diff --check.Pull Request Checklist