From e1943b9fb48354fca955eb0bbc24a27c4f7ce537 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 30 Jan 2020 13:03:21 -0700 Subject: [PATCH] Strip sudo use if running as root on Linux/macOS * Allows running under live macOS --- scripts/wk/exe.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/wk/exe.py b/scripts/wk/exe.py index 17f49249..e49b51d6 100644 --- a/scripts/wk/exe.py +++ b/scripts/wk/exe.py @@ -3,6 +3,7 @@ import json import logging +import os import re import subprocess @@ -77,6 +78,10 @@ def build_cmd_kwargs(cmd, minimized=False, pipe=True, shell=False, **kwargs): 'shell': shell, } + # Strip sudo if appropriate + if cmd[0] == 'sudo' and os.name == 'posix' and os.geteuid() == 0: + cmd.pop(0) + # Add additional kwargs if applicable for key in 'check cwd encoding errors stderr stdin stdout'.split(): if key in kwargs: