diff mbox series

[RFC,4/8] utils/pb-exec: Prepend sudo if normal user

Message ID 20181218041953.8960-5-sam@mendozajonas.com
State New
Headers show
Series Introduce pb-plugin 'commands' & Rust PoC | expand

Commit Message

Sam Mendoza-Jonas Dec. 18, 2018, 4:19 a.m. UTC
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 utils/pb-exec | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utils/pb-exec b/utils/pb-exec
index bfe13f6b..c5cc8d10 100755
--- a/utils/pb-exec
+++ b/utils/pb-exec
@@ -1,7 +1,13 @@ 
 #!/bin/sh
 
+if [[ "$(id -u)" != "0" ]]; then
+	PREFIX="sudo"
+else
+	PREFIX=""
+fi
+
 # Run a program specified by Petitboot.
-$@
+$PREFIX $@
 echo "$0 ran '$@'"
 
 # Wait for the user to exit back to Petitboot.