mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
become_method: make dzdo more like sudo (#47946)
dzdo is basically a drop-in replacement for sudo and supports the same command line options. There is no become_flags set for dzdo like there is for sudo, so users will have to set that separately to have exactly the same functionality.
This commit is contained in:
parent
d06cd869b8
commit
2bd6b1415b
2 changed files with 6 additions and 2 deletions
|
@ -76,7 +76,7 @@ BECOME_ERROR_STRINGS = {
|
|||
'pbrun': '',
|
||||
'pfexec': '',
|
||||
'doas': 'Permission denied',
|
||||
'dzdo': '',
|
||||
'dzdo': 'Sorry, try again.',
|
||||
'ksu': 'Password incorrect',
|
||||
'pmrun': 'You are not permitted to run this command',
|
||||
'enable': '',
|
||||
|
|
|
@ -539,11 +539,15 @@ class PlayContext(Base):
|
|||
becomecmd = '%s %s %s -c %s' % (exe, flags, executable, success_cmd)
|
||||
|
||||
elif self.become_method == 'dzdo':
|
||||
# If we have a password, we run dzdo with a randomly-generated
|
||||
# prompt set using -p. Otherwise we run it with -n, if
|
||||
# requested, which makes it fail if it would have prompted for a
|
||||
# password.
|
||||
|
||||
exe = self.become_exe or 'dzdo'
|
||||
if self.become_pass:
|
||||
prompt = '[dzdo via ansible, key=%s] password: ' % randbits
|
||||
becomecmd = '%s %s -p %s -u %s %s' % (exe, flags, shlex_quote(prompt), self.become_user, command)
|
||||
becomecmd = '%s %s -p %s -u %s %s' % (exe, flags.replace('-n', ''), shlex_quote(prompt), self.become_user, command)
|
||||
else:
|
||||
becomecmd = '%s %s -u %s %s' % (exe, flags, self.become_user, command)
|
||||
|
||||
|
|
Loading…
Reference in a new issue