From 84590cdcee15b3b03db544cc9e3ed7b2d55ebd61 Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Sat, 18 Jul 2026 04:23:03 -0700 Subject: [PATCH] Refactor sudo password handling in installer script --- NSLPluginInstaller.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/NSLPluginInstaller.sh b/NSLPluginInstaller.sh index 70f2ae3..a23e3d8 100644 --- a/NSLPluginInstaller.sh +++ b/NSLPluginInstaller.sh @@ -4,12 +4,14 @@ logged_in_user=$(logname 2>/dev/null || whoami) logged_in_home=$(eval echo "~${logged_in_user}") -# Function to prompt for sudo using sudo's normal credential handling, instead of -# capturing the password with zenity and piping it into `sudo -S` (which exposes it -# via the environment/argv and process listings). +# Function to prompt for sudo password prompt_for_sudo() { - if ! sudo -v; then - zenity --error --text="Sudo authentication failed. Exiting." + password=$(zenity --password --title="Authentication Required" --text="Please enter your password to proceed with installation/update.") + + # Validate password + echo "$password" | sudo -S -v >/dev/null 2>&1 + if [ $? -ne 0 ]; then + zenity --error --text="Incorrect password or sudo failed. Exiting." exit 1 fi } @@ -115,14 +117,14 @@ else if $NSL_PLUGIN_EXISTS; then show_message "NSL Plugin detected. Deleting and updating..." - sudo rm -rf "$LOCAL_DIR" + echo "$password" | sudo -S rm -rf "$LOCAL_DIR" fi show_message "Creating base directory and setting permissions..." - sudo mkdir -p "$LOCAL_DIR" - sudo chmod -R u+rw "$LOCAL_DIR" - sudo chown -R "$logged_in_user:$logged_in_user" "$LOCAL_DIR" + echo "$password" | sudo -S mkdir -p "$LOCAL_DIR" + echo "$password" | sudo -S chmod -R u+rw "$LOCAL_DIR" + echo "$password" | sudo -S chown -R "$logged_in_user:$logged_in_user" "$LOCAL_DIR" curl -L "$REPO_URL" -o /tmp/NonSteamLaunchersDecky.zip unzip -o /tmp/NonSteamLaunchersDecky.zip -d /tmp/