From 00689b0bd4370f046407558c6e3e784b20edbe2b Mon Sep 17 00:00:00 2001 From: wagesj45 Date: Fri, 25 Jul 2025 15:34:41 -0500 Subject: [PATCH] Update setup.sh --- setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 3875c74..dce6e45 100644 --- a/setup.sh +++ b/setup.sh @@ -14,13 +14,13 @@ DEFAULT_SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoxUu/nC1C03LvxIhCMzyMu7C # Early root escalation ############################################################################### if [[ $EUID -ne 0 ]]; then - # If script is a file and whiptail exists, prompt via whiptail and re-run file under su - if [[ -f "$0" ]] && command -v whiptail &>/dev/null; then + # Prompt for root password via whiptail if available + if command -v whiptail &>/dev/null; then PW=$(whiptail --passwordbox "Root privileges required. Enter root password:" 10 60 3>&1 1>&2 2>&3) || exit 1 - exec su root -c "$0 $*" <<<"$PW" + # Re-exec under su using stdin for piped or file-based scripts + exec su root -c "bash -s -- \"$@\"" <<<"$PW" else - # Fall back for piped-in scripts echo "Root privileges required; re-running under su..." exec su -c "bash -s -- \"$@\"" root fi