mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-24 03:50:14 +10:00
utilities.py: Use geteuid() for elevated
This commit is contained in:
@@ -452,7 +452,7 @@ class KernelDebugKitObject:
|
|||||||
if self.passive is True:
|
if self.passive is True:
|
||||||
return
|
return
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.geteuid() != 0:
|
||||||
logging.warning("- Cannot remove KDK, not running as root")
|
logging.warning("- Cannot remove KDK, not running as root")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -567,7 +567,7 @@ class KernelDebugKitUtilities:
|
|||||||
bool: True if successful, False if not
|
bool: True if successful, False if not
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.geteuid() != 0:
|
||||||
logging.warning("- Cannot install KDK, not running as root")
|
logging.warning("- Cannot install KDK, not running as root")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ class KernelDebugKitUtilities:
|
|||||||
bool: True if successful, False if not
|
bool: True if successful, False if not
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.geteuid() != 0:
|
||||||
logging.warning("- Cannot install KDK, not running as root")
|
logging.warning("- Cannot install KDK, not running as root")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -659,7 +659,7 @@ class KernelDebugKitUtilities:
|
|||||||
logging.warning("- Malformed KDK Info.plist provided, cannot create backup")
|
logging.warning("- Malformed KDK Info.plist provided, cannot create backup")
|
||||||
return
|
return
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.geteuid() != 0:
|
||||||
logging.warning("- Cannot create KDK backup, not running as root")
|
logging.warning("- Cannot create KDK backup, not running as root")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ def check_boot_mode():
|
|||||||
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
||||||
# When running through our GUI, we run as root, however we do not get uid 0
|
# When running through our GUI, we run as root, however we do not get uid 0
|
||||||
# Best to assume CLI is running as root
|
# Best to assume CLI is running as root
|
||||||
if os.getuid() == 0 or check_cli_args() is not None:
|
if os.geteuid() == 0 or check_cli_args() is not None:
|
||||||
return subprocess.run(*args, **kwargs)
|
return subprocess.run(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
|
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user