Given user report that EL5 sudo does not support '--', remove it, and things seem to still work fine.

let me know if this breaks any other boxes.
pull/846/head
Michael DeHaan 12 years ago
parent 02ba5a48e0
commit c7888dd642

@ -94,16 +94,15 @@ class ParamikoConnection(object):
chan.exec_command(quoted_command) chan.exec_command(quoted_command)
else: else:
# Rather than detect if sudo wants a password this time, -k makes # Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required. The "--" # sudo always ask for a password if one is required.
# tells sudo that this is the end of sudo options and the command # Passing a quoted compound command to sudo (or sudo -s)
# follows. Passing a quoted compound command to sudo (or sudo -s)
# directly doesn't work, so we shellquote it with pipes.quote() # directly doesn't work, so we shellquote it with pipes.quote()
# and pass the quoted string to the user's shell. We loop reading # and pass the quoted string to the user's shell. We loop reading
# output until we see the randomly-generated sudo prompt set with # output until we see the randomly-generated sudo prompt set with
# the -p option. # the -p option.
randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32)) randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32))
prompt = '[sudo via ansible, key=%s] password: ' % randbits 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 "$SHELL" -c %s' % (
prompt, sudo_user, pipes.quote(cmd)) prompt, sudo_user, pipes.quote(cmd))
vvv("EXEC %s" % sudocmd, host=self.host) vvv("EXEC %s" % sudocmd, host=self.host)
sudo_output = '' sudo_output = ''

@ -60,16 +60,15 @@ class SSHConnection(object):
ssh_cmd = ["ssh", "-tt", "-q"] + self.common_args + [self.host] ssh_cmd = ["ssh", "-tt", "-q"] + self.common_args + [self.host]
if self.runner.sudo and sudoable: if self.runner.sudo and sudoable:
# Rather than detect if sudo wants a password this time, -k makes # Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required. The "--" # sudo always ask for a password if one is required.
# tells sudo that this is the end of sudo options and the command # Passing a quoted compound command to sudo (or sudo -s)
# follows. Passing a quoted compound command to sudo (or sudo -s)
# directly doesn't work, so we shellquote it with pipes.quote() # directly doesn't work, so we shellquote it with pipes.quote()
# and pass the quoted string to the user's shell. We loop reading # and pass the quoted string to the user's shell. We loop reading
# output until we see the randomly-generated sudo prompt set with # output until we see the randomly-generated sudo prompt set with
# the -p option. # the -p option.
randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32)) randbits = ''.join(chr(random.randint(ord('a'), ord('z'))) for x in xrange(32))
prompt = '[sudo via ansible, key=%s] password: ' % randbits 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 "$SHELL" -c %s' % (
prompt, sudo_user, pipes.quote(cmd)) prompt, sudo_user, pipes.quote(cmd))
sudo_output = '' sudo_output = ''
ssh_cmd.append(sudocmd) ssh_cmd.append(sudocmd)

Loading…
Cancel
Save