set -euo pipefail umask 077 test "$(hostname -s | tr A-Z a-z)" = absdev-ci stage=$(mktemp -d /var/tmp/absdev-revocation-fix.XXXXXX) suffix=$(tr '[:upper:]' '[:lower:]' <<< "${stage##*.}") account="abrev$suffix" created=0 cleanup() { rc=$? if ((created)); then userdel "$account" || rc=1; fi rm -rf -- "$stage" || rc=1 exit "$rc" } trap cleanup EXIT mkdir "$stage/source" "$stage/evidence" "$stage/tmp" tar -xm -f - -C "$stage/source" chmod 0711 "$stage" chmod -R a+rX "$stage/source" useradd -U -M -d /nonexistent -s /usr/sbin/nologin "$account" created=1 install -d -m 0750 -o root -g "$account" "$stage/authority" install -d -m 0700 -o "$account" -g "$account" "$stage/operator-tmp" export TMPDIR="$stage/tmp" out="$stage/evidence" cd "$stage/source" printf 'host=%s\nrevision=2719378f67da153f0210b886d66e8e2b68cf6c01\noperator_uid=%s\n' "$(hostname -s)" "$(id -u "$account")" > "$out/scope.txt" python3 -B bin/absdev-deploy capabilities > "$out/capabilities-before.json" python3 -B controller.py "$account" "$(id -u "$account")" "$(id -g "$account")" "$stage/authority" > "$out/checks.jsonl" userdel "$account" created=0 rm -rf -- "$stage/authority" "$stage/operator-tmp" if getent passwd "$account"; then exit 1; fi printf '%s\n' '{"check":"disposable operator and authority files removed","result":"PASS"}' >> "$out/checks.jsonl" bash scripts/ci-check.sh > "$out/framework-ci.txt" 2>&1 || { tail -80 "$out/framework-ci.txt" >&2; exit 1; } python3 -B bin/absdev-deploy capabilities > "$out/capabilities-after.json" cmp "$out/capabilities-before.json" "$out/capabilities-after.json" (cd "$out" && sha256sum ./* > SHA256SUMS) tar -czf - -C "$out" .