diff --git a/avocado/utils/process.py b/avocado/utils/process.py index 7f8537feb928930fe8419b2b1da8af86648b0fcd..022fecd01ee9aaf653d3b9cbf99602487b7d027c 100644 --- a/avocado/utils/process.py +++ b/avocado/utils/process.py @@ -111,11 +111,14 @@ def can_sudo(cmd=None): except path.CmdNotFoundError: return False - if cmd: # Am I able to run the cmd or plain sudo id? - return not system(cmd, ignore_status=True, sudo=True) - elif system_output("id -u", ignore_status=True, sudo=True).strip() == "0": - return True - else: + try: + if cmd: # Am I able to run the cmd or plain sudo id? + return not system(cmd, ignore_status=True, sudo=True) + elif system_output("id -u", ignore_status=True, sudo=True).strip() == "0": + return True + else: + return False + except OSError: # Broken sudo binary return False