跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

sign-macos-guest.sh

37 行 · 1.7 KB历史下载
1#!/bin/bash
2# Sign only the guest kit's Mach-O code, inside out. Source and foreign payloads
3# are data; every native executable is refreshed even if a cache was ad-hoc signed.
4set -euo pipefail
5[[ $# == 2 && -d $1 ]] || { echo 'Usage: sign-macos-guest.sh /guest-kit signing-identity' >&2; exit 2; }
6kit=$1 identity=$2
7src=$(cd "$(dirname "$0")" && pwd)
8sign=(/usr/bin/codesign --force --sign "$identity")
9if [[ $identity != - ]]; then
10 [[ $identity == 'Developer ID Application:'* || $identity =~ ^[[:xdigit:]]{40}$ ]] || { echo 'Guest release code requires a Developer ID Application name or certificate fingerprint.' >&2; exit 2; }
11 sign+=(--timestamp --options runtime)
12fi
13count=0
14while IFS= read -r -d '' executable; do
15 kind=$(/usr/bin/file -b "$executable")
16 [[ $kind == *Mach-O* ]] || continue
17 if [[ $executable == "$kit/project/cage-sshfs" ]]; then
18 # macFUSE is installed in the guest by its own publisher, outside our team.
19 "${sign[@]}" --entitlements "$src/sshfs.entitlements" "$executable"
20 else
21 "${sign[@]}" "$executable"
22 fi
23 /usr/bin/codesign --verify --strict "$executable"
24 if [[ $identity != - ]]; then
25 metadata=$(/usr/bin/codesign -d --verbose=4 "$executable" 2>&1)
26 grep -q '^Authority=Developer ID Application:' <<< "$metadata"
27 grep -q 'flags=.*runtime' <<< "$metadata"
28 grep -q '^Timestamp=' <<< "$metadata"
29 fi
30 count=$((count+1))
31done < <(/usr/bin/find "$kit" -type f -print0)
32[[ $count -gt 0 ]] || { echo 'Guest kit contains no native executable.' >&2; exit 1; }
33while IFS= read -r -d '' app; do
34 "${sign[@]}" "$app"
35 /usr/bin/codesign --verify --deep --strict "$app"
36done < <(/usr/bin/find "$kit" -depth -type d -name '*.app' -print0)
37printf 'Signed and verified %s guest Mach-O files.\n' "$count"