You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/core/sudo.sh
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -108,14 +108,41 @@ request_sudo_access() {
108
108
return 0
109
109
fi
110
110
111
-
#Get TTY path
111
+
#Detect if running in TTY environment
112
112
local tty_path="/dev/tty"
113
+
local is_gui_mode=false
114
+
113
115
if [[ !-r"$tty_path"||!-w"$tty_path" ]];then
114
116
tty_path=$(tty 2> /dev/null ||echo"")
115
117
if [[ -z"$tty_path"||!-r"$tty_path"||!-w"$tty_path" ]];then
116
-
log_error "No interactive terminal available"
118
+
is_gui_mode=true
119
+
fi
120
+
fi
121
+
122
+
# GUI mode: use osascript for password dialog
123
+
if [[ "$is_gui_mode"==true ]];then
124
+
# Clear sudo cache before attempting authentication
125
+
sudo -k 2> /dev/null
126
+
127
+
# Display native macOS password dialog
128
+
local password
129
+
password=$(osascript -e "display dialog \"$prompt_msg\" default answer \"\" with title \"Mole\" with icon caution with hidden answer" -e 'text returned of result'2> /dev/null)
130
+
131
+
if [[ -z"$password" ]];then
132
+
# User cancelled the dialog
133
+
unset password
117
134
return 1
118
135
fi
136
+
137
+
# Attempt sudo authentication with the provided password
0 commit comments