Commit 9caef884 by Michael Vogt Committed by Michael DeHaan

fail early on the wrong sudo password instead of waiting until the timeout happens

parent 0bd89358
......@@ -173,6 +173,12 @@ class Connection(object):
stderr = ''
while True:
rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout, p.stderr], 1)
# fail early if the sudo password is wrong
if (self.runner.sudo and sudoable and self.runner.sudo_pass and
stdout.endswith("Sorry, try again.\r\n%s" % prompt)):
raise errors.AnsibleError('Incorrect sudo password')
if p.stdout in rfd:
dat = os.read(p.stdout.fileno(), 9000)
stdout += dat
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment