mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2026-08-03 13:27:30 +03:00
Refactor sudo password handling in installer script
This commit is contained in:
+11
-9
@@ -4,12 +4,14 @@
|
|||||||
logged_in_user=$(logname 2>/dev/null || whoami)
|
logged_in_user=$(logname 2>/dev/null || whoami)
|
||||||
logged_in_home=$(eval echo "~${logged_in_user}")
|
logged_in_home=$(eval echo "~${logged_in_user}")
|
||||||
|
|
||||||
# Function to prompt for sudo using sudo's normal credential handling, instead of
|
# Function to prompt for sudo password
|
||||||
# capturing the password with zenity and piping it into `sudo -S` (which exposes it
|
|
||||||
# via the environment/argv and process listings).
|
|
||||||
prompt_for_sudo() {
|
prompt_for_sudo() {
|
||||||
if ! sudo -v; then
|
password=$(zenity --password --title="Authentication Required" --text="Please enter your password to proceed with installation/update.")
|
||||||
zenity --error --text="Sudo authentication failed. Exiting."
|
|
||||||
|
# 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
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -115,14 +117,14 @@ else
|
|||||||
|
|
||||||
if $NSL_PLUGIN_EXISTS; then
|
if $NSL_PLUGIN_EXISTS; then
|
||||||
show_message "NSL Plugin detected. Deleting and updating..."
|
show_message "NSL Plugin detected. Deleting and updating..."
|
||||||
sudo rm -rf "$LOCAL_DIR"
|
echo "$password" | sudo -S rm -rf "$LOCAL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
show_message "Creating base directory and setting permissions..."
|
show_message "Creating base directory and setting permissions..."
|
||||||
|
|
||||||
sudo mkdir -p "$LOCAL_DIR"
|
echo "$password" | sudo -S mkdir -p "$LOCAL_DIR"
|
||||||
sudo chmod -R u+rw "$LOCAL_DIR"
|
echo "$password" | sudo -S chmod -R u+rw "$LOCAL_DIR"
|
||||||
sudo chown -R "$logged_in_user:$logged_in_user" "$LOCAL_DIR"
|
echo "$password" | sudo -S chown -R "$logged_in_user:$logged_in_user" "$LOCAL_DIR"
|
||||||
|
|
||||||
curl -L "$REPO_URL" -o /tmp/NonSteamLaunchersDecky.zip
|
curl -L "$REPO_URL" -o /tmp/NonSteamLaunchersDecky.zip
|
||||||
unzip -o /tmp/NonSteamLaunchersDecky.zip -d /tmp/
|
unzip -o /tmp/NonSteamLaunchersDecky.zip -d /tmp/
|
||||||
|
|||||||
Reference in New Issue
Block a user