forked from mtusi2026/mtusi2026lab7
test: verify security boundaries and recovery
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
. "$script_dir/openbao-common.sh"
|
||||
|
||||
require_command "$BAO_BIN"
|
||||
require_command python3
|
||||
require_file "$BAO_CACERT"
|
||||
|
||||
mkdir -p "$openbao_runtime_dir/operator"
|
||||
chmod 0700 "$openbao_runtime_dir" "$openbao_runtime_dir/operator"
|
||||
|
||||
status_file=$(mktemp "$openbao_runtime_dir/.status.XXXXXX")
|
||||
init_file=$(mktemp "$openbao_runtime_dir/operator/.init.XXXXXX")
|
||||
chmod 0600 "$status_file" "$init_file"
|
||||
|
||||
cleanup() {
|
||||
rm -f "$status_file" "$init_file"
|
||||
}
|
||||
|
||||
trap cleanup EXIT HUP INT TERM
|
||||
|
||||
openbao_status "$status_file"
|
||||
|
||||
if [ "$(json_field "$status_file" initialized)" = "true" ]; then
|
||||
echo "OpenBao is already initialized"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -e "$openbao_operator_file" ]; then
|
||||
fail "operator material already exists for an uninitialized OpenBao instance"
|
||||
fi
|
||||
|
||||
"$BAO_BIN" operator init \
|
||||
-key-shares=3 \
|
||||
-key-threshold=2 \
|
||||
-format=json >"$init_file"
|
||||
|
||||
chmod 0600 "$init_file"
|
||||
mv "$init_file" "$openbao_operator_file"
|
||||
|
||||
echo "OpenBao initialized; operator material saved to .runtime/openbao/operator/init.json"
|
||||
echo "Keep this file offline and run scripts/openbao-unseal.sh"
|
||||
|
||||
Reference in New Issue
Block a user