mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-21 08:11:12 +00:00
[PR #11850/f8869af6 backport][stable-12] homebrew_cask: fix sudo_password failing with special characters (#11867)
homebrew_cask: fix sudo_password failing with special characters (#11850)
* homebrew_cask: fix sudo_password with special characters in password
The SUDO_ASKPASS script embedded the password inside single quotes, which
breaks shell parsing whenever the password contains a single quote. Use a
quoted heredoc (cat <<'SUDO_PASS') instead, which treats the content
completely literally regardless of special characters.
Also replace .file.close() with .flush() (correct semantics — flushes
the write buffer without leaving the NamedTemporaryFile in a half-closed
state) and remove the redundant add_cleanup_file() call (the context
manager already deletes the file on exit).
Fixes #4957
* homebrew_cask: add changelog fragment for #11850
* homebrew_cask: fix sudo_password example and clarify ansible_become_password
* homebrew_cask: use shlex.quote() for sudo_password instead of heredoc
shlex.quote() is the standard Python approach for shell-safe quoting
and handles all special characters without the edge cases of heredocs.
---------
(cherry picked from commit f8869af65f)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
bugfixes:
|
||||
- homebrew_cask - fix ``sudo_password`` failing when the password contains single quotes or
|
||||
other special shell characters
|
||||
(https://github.com/ansible-collections/community.general/issues/4957,
|
||||
https://github.com/ansible-collections/community.general/pull/11850).
|
||||
Reference in New Issue
Block a user