From 5e2c2564bc1602ace123291de39cd4b29246b8d0 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 25 Oct 2012 23:00:07 -0400 Subject: [PATCH] Explicitly execute /bin/sh versus $SHELL because some folks have very incompatible/weird shells. We do not execute modules through the shell, this is only for basic ops, so should be sufficient. --- lib/ansible/runner/connection_plugins/paramiko_ssh.py | 4 ++-- lib/ansible/runner/connection_plugins/ssh.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/connection_plugins/paramiko_ssh.py b/lib/ansible/runner/connection_plugins/paramiko_ssh.py index e03ef52d91e..c375f3c4cff 100644 --- a/lib/ansible/runner/connection_plugins/paramiko_ssh.py +++ b/lib/ansible/runner/connection_plugins/paramiko_ssh.py @@ -109,7 +109,7 @@ class Connection(object): chan.get_pty() if not self.runner.sudo or not sudoable: - quoted_command = '"$SHELL" -c ' + pipes.quote(cmd) + quoted_command = '/bin/sh -c ' + pipes.quote(cmd) vvv("EXEC %s" % quoted_command, host=self.host) chan.exec_command(quoted_command) else: @@ -122,7 +122,7 @@ class Connection(object): # the -p option. randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32)) prompt = '[sudo via ansible, key=%s] password: ' % randbits - sudocmd = 'sudo -k && sudo -p "%s" -u %s "$SHELL" -c %s' % ( + sudocmd = 'sudo -k && sudo -p "%s" -u %s /bin/sh -c %s' % ( prompt, sudo_user, pipes.quote(cmd)) vvv("EXEC %s" % sudocmd, host=self.host) sudo_output = '' diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index fa8fde4ecb4..97b8e26d2dd 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -71,7 +71,7 @@ class Connection(object): # the -p option. randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32)) prompt = '[sudo via ansible, key=%s] password: ' % randbits - sudocmd = 'sudo -k && sudo -p "%s" -u %s "$SHELL" -c %s' % ( + sudocmd = 'sudo -k && sudo -p "%s" -u %s /bin/sh -c %s' % ( prompt, sudo_user, pipes.quote(cmd)) sudo_output = '' ssh_cmd.append(sudocmd)