Don't use 'sudo' when running as root

This cancels the need to install and configure `sudo` or `doas` on
single-user installations (e.g.: a VM dedicated to running pmbootstrap).

Fixes: https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2224
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230529203922.22161-1-hugo@whynothugo.nl%3E
This commit is contained in:
Hugo Osvaldo Barrera 2023-05-29 22:39:23 +02:00 committed by Oliver Smith
parent 27618d5ffd
commit d31313f7dc
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 30 additions and 10 deletions

View file

@ -72,7 +72,7 @@ def root(args, cmd, working_dir=None, output="log", output_return=False,
"""
if env:
cmd = ["sh", "-c", flat_cmd(cmd, env=env)]
cmd = [pmb.config.sudo] + cmd
cmd = pmb.config.sudo(cmd)
return user(args, cmd, working_dir, output, output_return, check, env,
True)