|
Link Here
|
|
|
1 |
--- lib/ansible/playbook/play_context.py.orig 2016-01-14 22:33:27 UTC |
| 2 |
+++ lib/ansible/playbook/play_context.py |
| 3 |
@@ -446,8 +446,10 @@ class PlayContext(Base): |
| 4 |
|
| 5 |
if self.become_method == 'sudo': |
| 6 |
# If we have a password, we run sudo with a randomly-generated |
| 7 |
- # prompt set using -p. Otherwise we run it with -n, which makes |
| 8 |
+ # prompt set using -p. Otherwise we run it with default -n, which makes |
| 9 |
# it fail if it would have prompted for a password. |
| 10 |
+ # Cannot rely on -n as it can be removed from defaults, which should be |
| 11 |
+ # done for older versions of sudo that do not support the option. |
| 12 |
# |
| 13 |
# Passing a quoted compound command to sudo (or sudo -s) |
| 14 |
# directly doesn't work, so we shellquote it with pipes.quote() |
| 15 |
@@ -463,12 +465,14 @@ class PlayContext(Base): |
| 16 |
|
| 17 |
elif self.become_method == 'su': |
| 18 |
|
| 19 |
+ # passing code ref to examine prompt as simple string comparisson isn't good enough with su |
| 20 |
def detect_su_prompt(data): |
| 21 |
SU_PROMPT_LOCALIZATIONS_RE = re.compile("|".join(['(\w+\'s )?' + x + ' ?: ?' for x in SU_PROMPT_LOCALIZATIONS]), flags=re.IGNORECASE) |
| 22 |
return bool(SU_PROMPT_LOCALIZATIONS_RE.match(data)) |
| 23 |
- |
| 24 |
prompt = detect_su_prompt |
| 25 |
- becomecmd = '%s %s %s -c "%s -c %s"' % (exe, flags, self.become_user, executable, success_cmd) |
| 26 |
+ |
| 27 |
+ su_success_cmd = '%s -c %s' % (executable, success_cmd) # this is here cause su too succeptible to overquoting |
| 28 |
+ becomecmd = '%s %s %s -c %s' % (exe, flags, self.become_user, su_success_cmd) #works with sh |
| 29 |
|
| 30 |
elif self.become_method == 'pbrun': |
| 31 |
|