Skip to content

Commit

Permalink
utils: Optionally run utilities as root
Browse files Browse the repository at this point in the history
In particular this fixes running pb-plugin executables from the UI since
the wrapper requires root to set up the environment.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
  • Loading branch information
sammj committed Jun 7, 2019
1 parent aa596b2 commit 3cf30cf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion utils/pb-exec
@@ -1,7 +1,18 @@
#!/bin/sh

PREFIX=""

# Check if root required
if [[ "$(id -u)" != "0" ]]; then
read -n 1 -r -p "Running as user $(id -un), run as root? (y/N)" key
if [ "$key" == "y" ]; then
PREFIX="sudo"
fi
printf "\n"
fi

# Run a program specified by Petitboot.
$@
$PREFIX $@
echo "$0 ran '$@'"

# Wait for the user to exit back to Petitboot.
Expand Down

0 comments on commit 3cf30cf

Please sign in to comment.