From ff3ce4da6665db0278907570309782295b21f5cc Mon Sep 17 00:00:00 2001 From: Henrique Date: Mon, 12 Sep 2022 12:18:12 -0300 Subject: [PATCH] Fix Issue #1825 (#1826) the modifications verify user privilege and prevent improper script execution. --- INSTALL/CreatePersistentImg.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/INSTALL/CreatePersistentImg.sh b/INSTALL/CreatePersistentImg.sh index 1dc90e6d..21d65c47 100644 --- a/INSTALL/CreatePersistentImg.sh +++ b/INSTALL/CreatePersistentImg.sh @@ -18,6 +18,18 @@ print_usage() { echo '' } +print_err() { + echo "" + echo "$*" + echo "" +} + +uid=$(id -u) +if [ $uid -ne 0 ]; then + print_err "Please use sudo or run the script as root." + exit 1 +fi + while [ -n "$1" ]; do if [ "$1" = "-s" ]; then shift