From 8f818a64f2f0f3a833fc842d52a675358ec64c9c Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Wed, 18 Nov 2026 14:02:09 +0000 Subject: szecret: buckets beside the old store -- get/has/put/mv/rekey/list/check/enrol, admins from SZECRET_ADMINS_COMMAND; rotate retired (fleet hardening 12) A bucket is a directory of secrets with one set of readers: its recipients file plus the admins, the full set recorded in .szecret by rekey. put refuses when the readers or admins drift from that set, or with no admins; a plain put of a new name goes to admin-only, one still in the old store is rewritten there. The old store keeps working throughout. link/claude.sh leaves out an MCP server whose secret is in a bucket this host doesn't read. Design: cloud-setup docs/proposal-secret-roles.md. --- secrets/get.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'secrets/get.sh') diff --git a/secrets/get.sh b/secrets/get.sh index d88b696..4b5b983 100755 --- a/secrets/get.sh +++ b/secrets/get.sh @@ -4,23 +4,17 @@ set -euo pipefail if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then cat < + get searches every bucket and the old store + get / reads that bucket only get -h|--help -Arguments: - secret-name Name of the secret to retrieve - -The command will: -1. Check if the secret exists in the store -2. Ensure the private key is available -3. Decrypt the secret using age and output to stdout - -Note: Exits with error if secret doesn't exist or decryption fails. +Fails, naming both, if is in two places, and says so if this machine +isn't one of the bucket's readers. EOF exit 0 fi @@ -34,13 +28,19 @@ if [[ "$#" -lt 1 ]]; then fi name="$1" -file="$(file_for "${name}")" -if ! [[ -r "${file}" ]]; then - >&2 echo "ERROR: Secret '$name' not found" - exit 1 +file="$(find_secret "${name}")" || exit 1 + +if [[ -n "${store}" && "$(dirname "${file}")" == "${store}" ]]; then + # A machine that has moved to its own identity is not asked for the old key. + if [[ -r "${identity}" && ! -r "${private_key}" ]]; then + die "${name} is in the old store, and the old key is no longer on this machine" + fi + ensure_private_key +else + dir="$(dirname "${file}")" + if ! is_reader "${dir}"; then + die "$(basename "${file}" .age) is in bucket $(bucket_label "${dir}"); this machine isn't one of its readers" + fi fi -ensure_private_key - -age_decrypt "${private_key}" "${file}" - +decrypt "${file}" -- cgit v1.2.3