Skip to content

Preserve Azure CLI user environment on POSIX - #7317

Open
Akın Soysal (akeensoysal) wants to merge 2 commits into
Azure:mainfrom
akeensoysal:fix/7316-azure-cli-posix-env
Open

Preserve Azure CLI user environment on POSIX#7317
Akın Soysal (akeensoysal) wants to merge 2 commits into
Azure:mainfrom
akeensoysal:fix/7316-azure-cli-posix-env

Conversation

@akeensoysal

Copy link
Copy Markdown

Summary

  • Preserve HOME, XDG_CACHE_HOME, and AZURE_CONFIG_DIR in the restricted POSIX child environment used by AzureCliCredential.
  • Prevent Azure CLI telemetry from creating ./None/.cache/... under the caller's working directory and preserve custom Azure CLI config locations.
  • Add focused child-environment coverage and an Azure.Identity changelog entry.

Fixes #7316

Validation

  • Regression before implementation: AzureCliCredential.PosixChildEnvironment failed with environment 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.
  • Live AzureCliCredential storage-token probe: token acquired; no relative None directory created.
  • clang-format-11 --dry-run --Werror on both changed C++ files.
  • git diff --check.

Pull Request Checklist

  • C++ Guidelines
  • Doxygen docs (no public API or header changes)
  • Unit tests
  • No unwanted commits/changes
  • Descriptive title/description
    • PR is single purpose
    • Related issue listed
  • Comments in source
  • No typos
  • Update changelog
  • Not work-in-progress
  • External references or docs updated (not applicable)
  • Self review of PR done
  • Any breaking changes? No

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
@github-actions

Copy link
Copy Markdown

Thank you for your contribution Akın Soysal (@akeensoysal)! We will review the pull request and get back to you soon.

@azure-pipelines

Copy link
Copy Markdown
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.

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

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, and AZURE_CONFIG_DIR into the POSIX posix_spawn environment 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.

Comment thread sdk/identity/azure-identity/src/azure_cli_credential.cpp Outdated
Remove the incorrect statement that envp begins with a program path. POSIX envp contains only key-value entries followed by a null pointer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Identity Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

AzureCliCredential drops HOME and creates telemetry files in the current directory

2 participants