sudo: add mitogen_sudo_password_prompt for custom passprompt#1501
Open
jettero wants to merge 1 commit intomitogen-hq:masterfrom
Open
sudo: add mitogen_sudo_password_prompt for custom passprompt#1501jettero wants to merge 1 commit intomitogen-hq:masterfrom
jettero wants to merge 1 commit intomitogen-hq:masterfrom
Conversation
Mitogen's PASSWORD_PROMPT_RE matches "password" in dozens of locales,
covering any default sudo configuration. But if sudoers defines a custom
passprompt (e.g. `[sudo] %u@%h:`) that omits the word "password",
mitogen never recognizes the prompt, never sends the password, and the
sudo bootstrap hangs until connect_timeout.
Ansible's own sudo become plugin sidesteps this by always forcing -p,
but mitogen matches the prompt on the wire instead. This commit adds a
configurable regex pattern via the ansible variable
`mitogen_sudo_password_prompt`. When set, the pattern is compiled and
prepended to SetupProtocol.PARTIAL_PATTERNS, with the built-in patterns
as fallback.
Configuration (group_vars, host_vars, or play vars):
mitogen_sudo_password_prompt: '\[sudo\] \w+@[\w.]+:'
Also adds pyproject.toml so `pip install -e .` works with modern pip.
Member
|
I agree with the goal, created #1503 as an umbrella for similar issues. I wan't to consider the design more - Ansible's method (set a known prompt) makes a lot of sense and is likely to be more robust. Regardless, I can't accept this PR with failing tests and no changelog entry or docs updates. |
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.
@jettero:
I didn't have much to do with this. Just asked claude to fix the problem I was having with mitogen in my ansible setup. The problem turned out to be my custom sudo prompts, which I'm not willing to change, so if I wanna use mitogen, I have to fork... But feel free to reject this if you don't like it. I don't have much skin in the game.
Claude:
Mitogen's PASSWORD_PROMPT_RE matches "password" in dozens of locales, covering any default sudo configuration. But if sudoers defines a custom passprompt (e.g.
[sudo] %u@%h:) that omits the word "password", mitogen never recognizes the prompt, never sends the password, and the sudo bootstrap hangs until connect_timeout.Ansible's own sudo become plugin sidesteps this by always forcing -p, but mitogen matches the prompt on the wire instead. This commit adds a configurable regex pattern via the ansible variable
mitogen_sudo_password_prompt. When set, the pattern is compiled and prepended to SetupProtocol.PARTIAL_PATTERNS, with the built-in patterns as fallback.Configuration (group_vars, host_vars, or play vars):
Also adds pyproject.toml so
pip install -e .works with modern pip.Thanks for creating a PR! Here's a quick checklist to pay attention to:
Please add an entry to docs/changelog.rst as appropriate.
Has some new parameter been added or semantics modified somehow? Please
ensure relevant documentation is updated in docs/ansible.rst and
docs/api.rst.
If it's for new functionality, is there at least a basic test in either
tests/ or tests/ansible/ covering it?
If it's for a new connection method, please try to stub out the
implementation as in tests/data/stubs/, so that construction can be tested
without having a working configuration.