From 188ae18b1c3e324a433aa84977cebdbc2ef55615 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 24 Oct 2016 14:33:47 -0700 Subject: [PATCH] Add a new potential su prompt Two parts to this change: * Add a new string that requests password * Add a new glyph that can be used to separate the prompt from the user's input as it seems it can use fullwidth colon rather than colon. Fixes #17867 --- lib/ansible/playbook/play_context.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index d778aa63c5..f5b9434200 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -117,6 +117,7 @@ b_SU_PROMPT_LOCALIZATIONS = [ to_bytes('හස්පදය'), to_bytes('密码'), to_bytes('密碼'), + to_bytes('口令'), ] TASK_ATTRIBUTE_OVERRIDES = ( @@ -510,7 +511,10 @@ class PlayContext(Base): # passing code ref to examine prompt as simple string comparisson isn't good enough with su def detect_su_prompt(b_data): - b_SU_PROMPT_LOCALIZATIONS_RE = re.compile(b"|".join([b'(\w+\'s )?' + x + b' ?: ?' for x in b_SU_PROMPT_LOCALIZATIONS]), flags=re.IGNORECASE) + b_password_string = b"|".join([b'(\w+\'s )?' + x for x in b_SU_PROMPT_LOCALIZATIONS]) + # Colon or unicode fullwidth colon + b_password_string = b_password_string + to_bytes(u' ?(:|:) ?') + b_SU_PROMPT_LOCALIZATIONS_RE = re.compile(b_password_string, flags=re.IGNORECASE) return bool(b_SU_PROMPT_LOCALIZATIONS_RE.match(b_data)) prompt = detect_su_prompt