Просмотр исходного кода

fix(deps): check passwordless sudo before prompting with sudo -v (#4980)

sudo -v asks for a password with sudo-rs (Ubuntu 25.10+) even with
NOPASSWD, and with classic sudo when the user also matches the default
%sudo rule. Try sudo -n true first and only fall back to the sudo -v
prompt when passwordless sudo is not available.
Daniel Gibbs 1 неделя назад
Родитель
Сommit
b50339a828
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      lgsm/modules/check_deps.sh

+ 8 - 4
lgsm/modules/check_deps.sh

@@ -156,13 +156,17 @@ fn_install_missing_deps() {
 			fn_script_log_warn "Missing dependencies: ${array_deps_missing[*]}"
 		fi
 
-		# Attempt automatic dependency installation
-		if [ "${autoinstall}" == "1" ]; then
-			sudo -n true > /dev/null 2>&1
+		# Attempt automatic dependency installation.
+		# Check for passwordless sudo first: sudo-rs (default sudo from Ubuntu 25.10) always asks
+		# for a password for sudo -v, even when the user has NOPASSWD.
+		if sudo -n true > /dev/null 2>&1; then
+			autodepinstall="0"
+		elif [ "${autoinstall}" == "1" ]; then
+			autodepinstall="1"
 		else
 			sudo -v > /dev/null 2>&1
+			autodepinstall="$?"
 		fi
-		autodepinstall="$?"
 
 		if [ "${monoinstalled}" == "false" ]; then
 			fn_install_mono_repo