diff --git a/tool/store-helper/pass-auth.sh b/tool/store-helper/pass-auth.sh index f858cea..dd668b1 100755 --- a/tool/store-helper/pass-auth.sh +++ b/tool/store-helper/pass-auth.sh @@ -2,7 +2,11 @@ # We use sudo twice to avoid ACE bug here # https://gitee.com/amber-ce/amber-ce-bookworm/commit/43e1a1599ede474b37e41aa10c53fd8afc4d35a1 -function zenity() { +#!/bin/bash +# We use sudo twice to avoid ACE bug here +# https://gitee.com/amber-ce/amber-ce-bookworm/commit/43e1a1599ede474b37e41aa10c53fd8afc4d35a1 + +function zenity_prompt() { if [[ -e /usr/bin/garma ]]; then garma "$@" else @@ -10,36 +14,33 @@ function zenity() { fi } - - # 检查sudo是否需要密码 -if sudo sudo -n true 2>/dev/null; then +if sudo -n true 2>/dev/null; then echo "sudo 无需密码,继续执行" - else - -# 循环输入密码直到成功或用户取消 -while true; do - # 使用zenity弹出密码输入框 - PASSWORD=$(zenity --password --title="需要sudo权限" ) - - # 检查用户是否取消输入 - if [ -z "$PASSWORD" ]; then - zenity --error --text="操作已取消" - exit 1 - fi - - # 尝试使用输入的密码执行sudo命令 - echo "$PASSWORD" | sudo sudo -S true 2>/dev/null - - # 检查sudo是否成功 - if [ $? -eq 0 ]; then - echo "密码正确,继续执行" - break - else - zenity --error --text="密码错误,请重新输入" - fi -done + # 循环输入密码直到成功或用户取消 + while true; do + # 使用zenity弹出密码输入框 + PASSWORD=$(zenity_prompt --password --title="需要sudo权限") + + # 检查用户是否取消输入 + if [ -z "$PASSWORD" ]; then + zenity_prompt --error --text="操作已取消" + exit 1 + fi + + # 尝试使用输入的密码执行sudo命令 + echo "$PASSWORD" | sudo -S -v 2>/dev/null + + # 检查sudo是否成功 + if [ $? -eq 0 ]; then + echo "密码正确,继续执行" + break + else + zenity_prompt --error --text="密码错误,请重新输入" + fi + done fi +# 使用sudo命令执行目标程序 echo "$PASSWORD" | sudo sudo -S "$@" diff --git a/tool/update-upgrade/ss-do-upgrade.sh b/tool/update-upgrade/ss-do-upgrade.sh index 191198d..615209d 100755 --- a/tool/update-upgrade/ss-do-upgrade.sh +++ b/tool/update-upgrade/ss-do-upgrade.sh @@ -1,6 +1,6 @@ #!/bin/bash if [ "$(id -u)" != "0" ] ; then - if [[ IS_ACE_ENV="1" ]];then + if [ "$IS_ACE_ENV" = "1" ];then /opt/durapps/spark-store/bin/store-helper/pass-auth.sh "$0" "$@" else pkexec "$0" "$@"