mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 17:35:16 +00:00
fix: Enhance sudo password input handling and expand tilde paths in maintenance.
This commit is contained in:
@@ -42,6 +42,11 @@ _request_password() {
|
|||||||
# Extra safety: ensure sudo cache is cleared before password input
|
# Extra safety: ensure sudo cache is cleared before password input
|
||||||
sudo -k 2> /dev/null
|
sudo -k 2> /dev/null
|
||||||
|
|
||||||
|
# Save original terminal settings and ensure they're restored on exit
|
||||||
|
local stty_orig
|
||||||
|
stty_orig=$(stty -g < "$tty_path" 2> /dev/null || echo "")
|
||||||
|
trap '[[ -n "$stty_orig" ]] && stty "$stty_orig" < "$tty_path" 2> /dev/null || true' RETURN
|
||||||
|
|
||||||
while ((attempts < 3)); do
|
while ((attempts < 3)); do
|
||||||
local password=""
|
local password=""
|
||||||
|
|
||||||
@@ -52,7 +57,13 @@ _request_password() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
printf "${PURPLE}${ICON_ARROW}${NC} Password: " > "$tty_path"
|
printf "${PURPLE}${ICON_ARROW}${NC} Password: " > "$tty_path"
|
||||||
IFS= read -r -s password < "$tty_path" || password=""
|
|
||||||
|
# Disable terminal echo to hide password input
|
||||||
|
stty -echo -icanon min 1 time 0 < "$tty_path" 2> /dev/null || true
|
||||||
|
IFS= read -r password < "$tty_path" || password=""
|
||||||
|
# Restore terminal echo immediately
|
||||||
|
stty echo icanon < "$tty_path" 2> /dev/null || true
|
||||||
|
|
||||||
printf "\n" > "$tty_path"
|
printf "\n" > "$tty_path"
|
||||||
|
|
||||||
if [[ -z "$password" ]]; then
|
if [[ -z "$password" ]]; then
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ fix_broken_login_items() {
|
|||||||
program=$(plutil -extract ProgramArguments.0 raw "$plist_file" 2> /dev/null || echo "")
|
program=$(plutil -extract ProgramArguments.0 raw "$plist_file" 2> /dev/null || echo "")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Expand tilde in path if present
|
||||||
|
program="${program/#\~/$HOME}"
|
||||||
|
|
||||||
# Skip if no program found or program exists
|
# Skip if no program found or program exists
|
||||||
[[ -z "$program" ]] && continue
|
[[ -z "$program" ]] && continue
|
||||||
[[ -e "$program" ]] && continue
|
[[ -e "$program" ]] && continue
|
||||||
|
|||||||
2
mole
2
mole
@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/lib/core/common.sh"
|
source "$SCRIPT_DIR/lib/core/common.sh"
|
||||||
|
|
||||||
# Version info
|
# Version info
|
||||||
VERSION="1.13.1"
|
VERSION="1.13.2"
|
||||||
MOLE_TAGLINE="can dig deep to clean your Mac."
|
MOLE_TAGLINE="can dig deep to clean your Mac."
|
||||||
|
|
||||||
# Check if Touch ID is already configured
|
# Check if Touch ID is already configured
|
||||||
|
|||||||
Reference in New Issue
Block a user