[PATCH 2/2] utils: Optionally run utilities as root
Samuel Mendoza-Jonas
sam at mendozajonas.com
Thu May 30 15:25:25 AEST 2019
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 at mendozajonas.com>
---
utils/pb-exec | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/utils/pb-exec b/utils/pb-exec
index bfe13f6b..f1d22e6c 100755
--- a/utils/pb-exec
+++ b/utils/pb-exec
@@ -1,7 +1,17 @@
#!/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
+fi
+
# Run a program specified by Petitboot.
-$@
+$PREFIX $@
echo "$0 ran '$@'"
# Wait for the user to exit back to Petitboot.
--
2.21.0
More information about the Petitboot
mailing list