Strip sudo use if running as root on Linux/macOS
* Allows running under live macOS
This commit is contained in:
parent
41130a38ed
commit
e1943b9fb4
1 changed files with 5 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue