mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
fail early on the wrong sudo password instead of waiting until the timeout happens
This commit is contained in:
parent
0bd8935899
commit
9caef884e1
1 changed files with 6 additions and 0 deletions
|
@ -173,6 +173,12 @@ class Connection(object):
|
||||||
stderr = ''
|
stderr = ''
|
||||||
while True:
|
while True:
|
||||||
rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout, p.stderr], 1)
|
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:
|
if p.stdout in rfd:
|
||||||
dat = os.read(p.stdout.fileno(), 9000)
|
dat = os.read(p.stdout.fileno(), 9000)
|
||||||
stdout += dat
|
stdout += dat
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue