Wrap all remote commands in sh

pull/1668/head
Daniel Hokka Zakrisson 12 years ago
parent 8e515c0c94
commit ddef608c94

@ -125,10 +125,11 @@ class Connection(object):
prompt = '[sudo via ansible, key=%s] password: ' % randbits
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)
shcmd = '/bin/sh -c ' + pipes.quote(sudocmd)
vvv("EXEC %s" % shcmd, host=self.host)
sudo_output = ''
try:
chan.exec_command(sudocmd)
chan.exec_command(shcmd)
if self.runner.sudo_pass:
while not sudo_output.endswith(prompt):
chunk = chan.recv(bufsize)

@ -93,10 +93,8 @@ class Connection(object):
prompt = '[sudo via ansible, key=%s] password: ' % randbits
sudocmd = 'sudo -k && sudo -p "%s" -u %s /bin/sh -c %s' % (
prompt, sudo_user, pipes.quote(cmd))
sudo_output = ''
ssh_cmd.append(sudocmd)
else:
ssh_cmd.append(cmd)
cmd = sudocmd
ssh_cmd.append('/bin/sh -c ' + pipes.quote(cmd))
vvv("EXEC %s" % ssh_cmd, host=self.host)
p = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE,
@ -107,6 +105,7 @@ class Connection(object):
if self.runner.sudo and sudoable and self.runner.sudo_pass:
fcntl.fcntl(p.stdout, fcntl.F_SETFL,
fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
sudo_output = ''
while not sudo_output.endswith(prompt):
rfd, wfd, efd = select.select([p.stdout], [],
[p.stdout], self.runner.timeout)

Loading…
Cancel
Save