فهرست منبع

fix: curl|sh materialises to temp file then re-execs as user (guided flow intact: banner, summary, confirm, then sudo prompt)

clanker 1 هفته پیش
والد
کامیت
22b7581847
2فایلهای تغییر یافته به همراه1008 افزوده شده و 979 حذف شده
  1. 10 7
      installer/compile.sh
  2. 998 972
      installer/install-usm.sh

+ 10 - 7
installer/compile.sh

@@ -111,15 +111,18 @@ cat > "$HEADER_FILE" << SCRIPT_HEADER
 # Version: $VERSION
 # Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
 
-# Handle curl | sh with sudo re-exec: when piped, \$0 isn't a re-readable
-# file, so capture the remaining script from stdin into a temp file and
-# re-exec that with sudo; stdin must be reattached to the terminal so
-# interactive prompts work (the pipe is exhausted after cat)
-if [[ \$EUID -ne 0 && ! -f "\$0" ]]; then
+# Materialise to a temp file when piped (curl | sh), then re-exec WITHOUT
+# sudo so the guided install flow (banner → summary → confirm → sudo prompt)
+# runs exactly as if the user had downloaded and run the script directly
+if [[ ! -f "\$0" ]]; then
+    echo "Downloading USM installer..."
     _usm_tmp=\$(mktemp /tmp/usm-install.XXXXXX.sh)
-    cat > "\$_usm_tmp"
+    _usm_bytes=\$(tee "\$_usm_tmp" | wc -c)
+    _usm_kb=\$((_usm_bytes / 1024))
     chmod +x "\$_usm_tmp"
-    exec sudo bash "\$_usm_tmp" "\$@" < /dev/tty
+    echo "  Downloaded \${_usm_kb}KB"
+    echo ""
+    exec bash "\$_usm_tmp" "\$@" < /dev/tty
 fi
 
 set -e

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 998 - 972
installer/install-usm.sh


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است