diff options
author | Stéphane Cerveau <scerveau@collabora.com> | 2021-09-23 15:24:23 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-11-20 20:50:49 +0000 |
commit | f9c9f48d0ebd61e4a5d818786b1c9ffc7d851243 (patch) | |
tree | d4fde5bf22c78f35d13d3447f98c523233e7fc84 | |
parent | 8baea3c1292531d38ffafb0cf0ecbe1500fa5826 (diff) |
boostrap: remove sudo as root user
If the user is root, no need for sudo
with package manager.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/769>
-rw-r--r-- | cerbero/bootstrap/linux.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cerbero/bootstrap/linux.py b/cerbero/bootstrap/linux.py index a82fad08..0e5aa04e 100644 --- a/cerbero/bootstrap/linux.py +++ b/cerbero/bootstrap/linux.py @@ -20,7 +20,7 @@ from cerbero.bootstrap import BootstrapperBase from cerbero.bootstrap.bootstrapper import register_bootstrapper from cerbero.enums import Platform, Architecture, Distro, DistroVersion from cerbero.errors import ConfigurationError -from cerbero.utils import shell +from cerbero.utils import user_is_root, shell from cerbero.utils import messages as m import shlex @@ -37,6 +37,8 @@ class UnixBootstrapper (BootstrapperBase): def __init__(self, config, offline, assume_yes): BootstrapperBase.__init__(self, config, offline) self.assume_yes = assume_yes + if user_is_root() and 'sudo' in self.tool: # no need for sudo as root user + self.tool.remove('sudo') def start(self, jobs=0): for c in self.checks: @@ -127,6 +129,8 @@ class RedHatBootstrapper (UnixBootstrapper): self.packages.append('glibc.i686') if self.config.distro_version in [DistroVersion.FEDORA_24, DistroVersion.FEDORA_25]: self.packages.append('libncurses-compat-libs.i686') + if user_is_root(): + return # Use sudo to gain root access on everything except RHEL if self.config.distro_version == DistroVersion.REDHAT_6: self.tool = ['su', '-c', shlex.join(self.tool)] |