瀏覽代碼

fix: curl|sh sudo re-exec via temp file; Invercargill-Json clone from fabrica (not sr.ht)

clanker 1 周之前
父節點
當前提交
4c2cd55f0f
共有 2 個文件被更改,包括 1620 次插入0 次删除
  1. 11 0
      installer/compile.sh
  2. 1609 0
      installer/install-usm.sh

+ 11 - 0
installer/compile.sh

@@ -111,6 +111,17 @@ 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 (this guard must run before any other code so
+# the pipe hasn't been fully consumed yet)
+if [[ \$EUID -ne 0 && ! -f "\$0" ]]; then
+    _usm_tmp=\$(mktemp /tmp/usm-install.XXXXXX.sh)
+    cat > "\$_usm_tmp"
+    chmod +x "\$_usm_tmp"
+    exec sudo bash "\$_usm_tmp" "\$@"
+fi
+
 set -e
 
 SCRIPT_HEADER

文件差異過大導致無法顯示
+ 1609 - 0
installer/install-usm.sh


部分文件因文件數量過多而無法顯示