Skip to content

Commit

Permalink
Move from sudo to runuser
Browse files Browse the repository at this point in the history
This patch migrates usage of sudo to runuser. In containers
sudo is not installed by default. Whereas, `runuser` is part of
'util-linux' pacakge, whcih is installed by default

Fixes: https://pagure.io/dogtagpki/issue/3171

Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>
  • Loading branch information
SilleBille committed Jul 23, 2020
1 parent 6e10833 commit 8eba918
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/required-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
run: tar -xzf pki-build-${{ matrix.os }}/pki-rpms.tar.gz

- name: Install required packages
run: docker exec -i ${CONTAINER} dnf install -y findutils dnf-plugins-core sudo wget 389-ds-base
run: docker exec -i ${CONTAINER} dnf install -y findutils dnf-plugins-core wget 389-ds-base

- name: Enable PKI COPR repo
run: docker exec -i ${CONTAINER} dnf copr enable -y ${COPR_REPO}
Expand Down
2 changes: 1 addition & 1 deletion base/server/python/pki/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def execute(

# switch to systemd user if different from current user
if current_user != self.user:
prefix.extend(['sudo', '-u', self.user])
prefix.extend(['runuser', '-u', self.user])

java_path = os.getenv('PKI_JAVA_PATH')
java_home = self.config.get('JAVA_HOME')
Expand Down
2 changes: 1 addition & 1 deletion base/server/python/pki/server/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def execute(

# switch to systemd user if different from current user
if current_user != self.user:
prefix.extend(['sudo', '-u', self.user])
prefix.extend(['runuser', '-u', self.user])

cmd = prefix + ['/usr/sbin/pki-server', 'upgrade']

Expand Down
2 changes: 1 addition & 1 deletion base/server/python/pki/server/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ def run(self, args, as_current_user=False):
# switch to systemd user if different from current user
username = pwd.getpwuid(os.getuid()).pw_name
if username != self.instance.user:
cmd.extend(['sudo', '-u', self.instance.user])
cmd.extend(['runuser', '-u', self.instance.user])

if os.path.exists(java_path):
cmd.extend([java_path])
Expand Down

0 comments on commit 8eba918

Please sign in to comment.