From b89071e4858e5bf37846b347fab43d95b4785aef Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 15 Jun 2015 01:30:03 -0400 Subject: [PATCH] now detects incorrect password with sudo and su (at least in english) --- lib/ansible/constants.py | 1 + lib/ansible/plugins/connections/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 7417eb73e4..8f9c5bf510 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -151,6 +151,7 @@ DEFAULT_SUDO_FLAGS = get_config(p, DEFAULTS, 'sudo_flags', 'ANSIBLE_SUDO_ DEFAULT_ASK_SUDO_PASS = get_config(p, DEFAULTS, 'ask_sudo_pass', 'ANSIBLE_ASK_SUDO_PASS', False, boolean=True) # Become +BECOME_ERROR_STRINGS = {'sudo': 'Sorry, try again.', 'su': 'Authentication failure', 'pbrun': '', 'pfexec': '', 'runas': ''} #FIXME: deal with i18n BECOME_METHODS = ['sudo','su','pbrun','pfexec','runas'] DEFAULT_BECOME_METHOD = get_config(p, 'privilege_escalation', 'become_method', 'ANSIBLE_BECOME_METHOD','sudo' if DEFAULT_SUDO else 'su' if DEFAULT_SU else 'sudo' ).lower() DEFAULT_BECOME = get_config(p, 'privilege_escalation', 'become', 'ANSIBLE_BECOME',False, boolean=True) diff --git a/lib/ansible/plugins/connections/__init__.py b/lib/ansible/plugins/connections/__init__.py index 45a07a9c30..c38dd3bec4 100644 --- a/lib/ansible/plugins/connections/__init__.py +++ b/lib/ansible/plugins/connections/__init__.py @@ -129,6 +129,6 @@ class ConnectionBase(with_metaclass(ABCMeta, object)): return prompt(output) def check_incorrect_password(self, output, prompt): - incorrect_password = gettext.dgettext(self._connection_info.become_method, "Sorry, try again.") + incorrect_password = gettext.dgettext(self._connection_info.become_method, C.BECOME_ERROR_STRINGS[self._connection_info.become_method]) return output.endswith(incorrect_password)