Skip to content

Commit

Permalink
feat: sudo prompt check test (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell authored Sep 15, 2024
1 parent 0e26b55 commit f45b123
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions secator/runners/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,12 @@ def _prompt_sudo(self, command):
return None

# Check if sudo can be executed without a password
if subprocess.run(['sudo', '-n', 'true'], capture_output=False).returncode == 0:
return None
try:
if subprocess.run(['sudo', '-n', 'true'], capture_output=False).returncode == 0:
return None
except ValueError:
error = "Could not run sudo check test"
self.errors.append(error)

# Check if we have a tty
if not os.isatty(sys.stdin.fileno()):
Expand Down

0 comments on commit f45b123

Please sign in to comment.