Skip to content

fix: sudo not preseving passed in environment variables - #1691

Merged
Stromweld merged 1 commit into
chef:mainfrom
Sn0wCrack:bugfix/sudo-not-preserving-env
Jul 20, 2026
Merged

fix: sudo not preseving passed in environment variables#1691
Stromweld merged 1 commit into
chef:mainfrom
Sn0wCrack:bugfix/sudo-not-preserving-env

Conversation

@Sn0wCrack

@Sn0wCrack Sn0wCrack commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

This mainly effects Ubuntu 26.04, but could affect any distribution that decides to disable -E on sudo in a similar manner.

Passing the environment variables through after the sudo guarantees they will be preserved in any executed script.

Description

Ubuntu 26.04 currently fails on several scripts that use the PACKER_ environment variables, or any other environment variable passed in via the shell provision's environment variables option.

Related Issue

See: #1689 (comment)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

This mainly effects Ubuntu 26.04, but could affect any distribution that decides to disable `-E` on sudo in a similar manner.

Passing the environment variables through after the sudo guarantees they will be preserved in any executed script.

Signed-off-by: Sn0wCrack <442287+Sn0wCrack@users.noreply.github.com>
@Sn0wCrack
Sn0wCrack requested review from a team and Stromweld as code owners July 18, 2026 23:13
@Stromweld
Stromweld merged commit 251c9d1 into chef:main Jul 20, 2026
2 checks passed
SamuelMarks pushed a commit to SamuelMarks/bento that referenced this pull request Aug 21, 2026
This mainly effects Ubuntu 26.04, but could affect any distribution that decides to disable `-E` on sudo in a similar manner.

Passing the environment variables through after the sudo guarantees they will be preserved in any executed script.

Signed-off-by: Sn0wCrack <442287+Sn0wCrack@users.noreply.github.com>
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.

2 participants