Skip to content

[PR #12090/9bb7aee8 backport][stable-13] composer: warn when running as root - #12722

Merged
felixfontein merged 1 commit into
stable-13from
patchback/backports/stable-13/9bb7aee82639bf5f569d8cde375f87223c52ac72/pr-12090
Sep 13, 2026
Merged

[PR #12090/9bb7aee8 backport][stable-13] composer: warn when running as root#12722
felixfontein merged 1 commit into
stable-13from
patchback/backports/stable-13/9bb7aee82639bf5f569d8cde375f87223c52ac72/pr-12090

Conversation

@patchback

@patchback patchback Bot commented Sep 13, 2026

Copy link
Copy Markdown

This is a backport of PR #12090 as merged into main (9bb7aee).

SUMMARY

When the community.general.composer module runs as root, composer itself emits a security warning that is currently silently swallowed. This PR adds a module.warn() call when the effective UID is 0, so operators are made aware of the issue. The COMPOSER_ALLOW_SUPERUSER environment variable is documented in the module notes as the upstream escape hatch.

Fixes #2388

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

composer

ADDITIONAL INFORMATION

N/A


* feat(composer): warn when running as root

Fixes #2388

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(changelog): add fragment for PR 12090

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(test_composer): update expected working-dir command format

The composer_as_root test case still expected the pre-rebase command
format (working-dir as a separate trailing option) instead of the
current --working-dir=<path> token placed before the subcommand.

* reformat

* fix(composer): relay composer's own root/super-user warning instead of reimplementing it

Per review feedback, stop independently deciding when running as root
is unsafe (which is wrong in cases like official containers) and
instead surface composer's own warning as an Ansible warning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(test_composer): make root-warning assertion resilient across ansible-core versions

CI on ansible-core 2.18 failed: module.warn() serializes warnings as
plain strings there, but as structured WarningSummary/Event dicts on
2.19+. Assert via substring match instead of exact equality so the
test passes on both.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 9bb7aee)
@ansibullbot

Copy link
Copy Markdown
Collaborator

cc @dmtrs
click here for bot help

@ansibullbot ansibullbot added backport feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit labels Sep 13, 2026
@felixfontein
felixfontein merged commit fb1c236 into stable-13 Sep 13, 2026
126 checks passed
@felixfontein
felixfontein deleted the patchback/backports/stable-13/9bb7aee82639bf5f569d8cde375f87223c52ac72/pr-12090 branch September 13, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type) tests tests unit tests/unit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants