Revert "sudo become plugin: add sudo-rs prompt support (#86175) (#86904)"

This reverts commit dfc1f8d6f5.
This commit is contained in:
Matt Davis
2026-05-11 11:28:03 -07:00
parent 219ca0c6d8
commit 50d53b8cfd
2 changed files with 3 additions and 16 deletions
-2
View File
@@ -1,2 +0,0 @@
bugfixes:
- sudo become plugin is now compatible with sudo-rs (rust implementation).
+3 -14
View File
@@ -101,17 +101,6 @@ class BecomeModule(BecomeBase):
fail = ('Sorry, try again.',)
missing = ('Sorry, a password is required to run sudo', 'sudo: a password is required')
def check_password_prompt(self, b_output):
matched = super().check_password_prompt(b_output)
if not matched:
# might be using sudo-rs, which is not backwards compatible
prompt = self.prompt
self.prompt = f"[sudo: {prompt}] Password:" # handle extra text from sudo-rs
matched = super().check_password_prompt(b_output)
self.prompt = prompt
return matched
def build_become_command(self, cmd, shell):
super(BecomeModule, self).build_become_command(cmd, shell)
@@ -123,7 +112,7 @@ class BecomeModule(BecomeBase):
flags = self.get_option('become_flags') or ''
prompt = ''
if self.get_option('become_pass'):
self.prompt = f'[sudo via ansible, key={self._id}] password:'
self.prompt = '[sudo via ansible, key=%s] password:' % self._id
if flags: # this could be simplified, but kept as is for now for backwards string matching
reflag = []
for flag in shlex.split(flags):
@@ -135,11 +124,11 @@ class BecomeModule(BecomeBase):
reflag.append(flag)
flags = shlex.join(reflag)
prompt = f'-p "{self.prompt}"'
prompt = '-p "%s"' % (self.prompt)
user = self.get_option('become_user') or ''
if user:
user = f'-u {user}'
user = '-u %s' % (user)
if chdir := self.get_option('sudo_chdir'):
try: