Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-mv/blob/main/adapters/aien/scripts/m5-setup-judge.sh # interplane-mv INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-mv / adapters / aien / scripts / m5-setup-judge.sh` 51 lines ยท 2857 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # One-time operator setup for the VAC M5 slice: give the judge account its own P-256 signing key 3 # and pin the matching public key where the operator keeps trust inputs. 4 # 5 # The private key is created by the judge account inside its own home (mode 700, file mode 600) 6 # and never leaves it. The proposing account (RSI_USER) cannot read it. The operator account can, 7 # through sudo; that is the operator's authority and is stated as a limit in every M5 receipt. 8 # 9 # Usage: JUDGE_BIN= m5-setup-judge.sh 10 # An existing key is kept (never overwritten); the pin file is rewritten from it. 11 set -euo pipefail 12 die() { echo "M5 SETUP FAIL: $*" >&2; exit 1; } 13 pin="${1:?usage: m5-setup-judge.sh }" 14 : "${JUDGE_BIN:?JUDGE_BIN must name the spark-rsi-judge binary}" 15 judge_user="${JUDGE_USER:-aien-judge}" 16 rsi_user="${RSI_USER:-aien-rsi}" 17 judge_home="${JUDGE_HOME:-/var/lib/aien-judge}" 18 key="$judge_home/judge.key" 19 as_judge() { sudo -n -u "$judge_user" "$@"; } 20 21 [ "$(as_judge stat -c %a "$judge_home")" = 700 ] || die "$judge_home must be mode 700" 22 if ! as_judge test -f "$key"; then 23 as_judge sh -c 'umask 077; head -c 32 /dev/urandom | od -An -tx1 | tr -d " \n" > "$1"' _ "$key" 24 fi 25 [ "$(as_judge stat -c %a "$key")" = 600 ] || die "$key must be mode 600" 26 # The proposer must not be able to read the key: prove the account runs at all, then require a 27 # permission refusal (a missing account or sudo rule must not pass for "cannot read"). 28 sudo -n -u "$rsi_user" true || die "cannot run commands as $rsi_user, so the key check would prove nothing" 29 if err="$(sudo -n -u "$rsi_user" cat "$key" 2>&1 >/dev/null)"; then die "$rsi_user can read $key"; fi 30 case "$err" in *"Permission denied"*) ;; *) die "unexpected result reading $key as $rsi_user: $err";; esac 31 bin_copy="$(as_judge mktemp "$judge_home/judge-bin.XXXXXX")" 32 as_judge sh -c 'cat > "$1" && chmod 700 "$1"' _ "$bin_copy" <"$JUDGE_BIN" 33 mkdir -p "$(dirname "$pin")" 34 # Neither service account may replace the pinned key: not the file, its directory, or any directory 35 # above it (which would let it rename the whole path), and neither may become root through sudo. 36 pin_dir="$(cd "$(dirname "$pin")" && pwd -P)" 37 for u in "$rsi_user" "$judge_user"; do 38 if [ -e "$pin" ] && sudo -n -u "$u" test -w "$pin"; then die "$u can write $pin"; fi 39 d="$pin_dir" 40 while :; do 41 if sudo -n -u "$u" test -w "$d"; then die "$u can write $d, above the pinned key"; fi 42 [ "$d" = / ] && break 43 d="$(dirname "$d")" 44 done 45 if sudo -n -u "$u" sudo -n true 2>/dev/null; then die "$u can use sudo"; fi 46 done 47 as_judge "$bin_copy" --signing-key-file "$key" --public-key >"$pin.new" 48 as_judge rm -f "$bin_copy" 49 grep -Eq '^04[0-9a-f]{128}$' "$pin.new" || die "unexpected public key output" 50 mv "$pin.new" "$pin" 51 echo "judge public key pinned at $pin"