From 79fed06fd9c7283b8b997f9e6b87b5f6c4f90ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=85=8E=E9=A5=BC=E6=9E=9C=E5=AD=90=E5=8D=B7=E9=B2=A8?= =?UTF-8?q?=E9=B1=BC=E8=BE=A3=E6=A4=92?= Date: Mon, 10 Feb 2025 16:16:38 +0800 Subject: [PATCH] refactor: Improve codesign process with timeout and fallback mechanisms - Added timeout for signature removal to prevent hanging - Implemented fallback strategies for signature removal - Enhanced error handling for Helper process signature removal - Added logging for signature removal attempts and failures --- scripts/run/cursor_mac_id_modifier.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/run/cursor_mac_id_modifier.sh b/scripts/run/cursor_mac_id_modifier.sh index 3435702..56fd5e6 100644 --- a/scripts/run/cursor_mac_id_modifier.sh +++ b/scripts/run/cursor_mac_id_modifier.sh @@ -319,12 +319,18 @@ modify_cursor_app_files() { log_info "移除应用签名..." find "$temp_app" -type f -exec chmod 644 {} \; find "$temp_app" -type d -exec chmod 755 {} \; - codesign --remove-signature "$temp_app" >/dev/null 2>&1 || log_warn "签名移除失败(可能已无签名)" + timeout 120 codesign --remove-signature --all-architectures "$temp_app" > >(while read line; do echo -n .; done) 2>&1 || { + log_warn "签名移除超时,尝试快速模式..." + codesign --remove-signature --preserve-metadata=entitlements "$temp_app" >/dev/null 2>&1 || true + } # 处理所有Helper进程 find "${temp_app}/Contents/Frameworks" -name "*Helper*.app" | while read helper; do log_debug "处理Helper进程: $helper" - codesign --remove-signature "$helper" >/dev/null 2>&1 + timeout 30 codesign --remove-signature "$helper" >/dev/null 2>&1 || { + log_warn "无法移除 $helper 签名,尝试强制模式..." + codesign --remove-signature --force "$helper" >/dev/null 2>&1 || true + } done # 修改目标文件