mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
support i18n on sudo failure
This commit is contained in:
parent
0905683c1f
commit
89bc43cab0
1 changed files with 6 additions and 3 deletions
|
@ -25,6 +25,7 @@ import select
|
||||||
import fcntl
|
import fcntl
|
||||||
import hmac
|
import hmac
|
||||||
import pwd
|
import pwd
|
||||||
|
import gettext
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
import ansible.constants as C
|
import ansible.constants as C
|
||||||
from ansible.callbacks import vvv
|
from ansible.callbacks import vvv
|
||||||
|
@ -191,9 +192,11 @@ class Connection(object):
|
||||||
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
|
# fail early if the sudo password is wrong
|
||||||
if (self.runner.sudo and sudoable and self.runner.sudo_pass and
|
if self.runner.sudo and sudoable and self.runner.sudo_pass:
|
||||||
stdout.endswith("Sorry, try again.\r\n%s" % prompt)):
|
incorrect_password = gettext.dgettext(
|
||||||
raise errors.AnsibleError('Incorrect sudo password')
|
"sudo", "Sorry, try again.")
|
||||||
|
if stdout.endswith("%s\r\n%s" % (incorrect_password, 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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue