diff options
| author | Igor Soarez <igor@soarez.org> | 2026-11-18 14:02:09 +0000 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-11-18 14:02:09 +0000 |
| commit | 8f818a64f2f0f3a833fc842d52a675358ec64c9c (patch) | |
| tree | eac13a48cada4595c9073d62060c1145189c6344 /link | |
| parent | 6444d6a508cdfdcf52cc6c83bab1e29a7e2a2e10 (diff) | |
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.
Diffstat (limited to 'link')
| -rwxr-xr-x | link/claude.sh | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/link/claude.sh b/link/claude.sh index 56f3724..2d6679c 100755 --- a/link/claude.sh +++ b/link/claude.sh @@ -41,7 +41,10 @@ link "$config_dir/claude/CLAUDE.md" "$HOME/.claude/CLAUDE.md" # trust, which includes $HOME, so a token fetched there # would simply be missing. The secret ends up in # ~/.claude.json, which Claude Code keeps mode 600. A -# secret that cannot be read skips that server, loudly. +# secret that exists but is in a bucket this host +# doesn't read leaves that server out here, and takes +# out one registered before; one that cannot be read +# otherwise skips that server, loudly. # # "desktop" a whole spec to give Claude Desktop instead of this one, # e.g. a local stdio server where Claude Code gets a remote @@ -120,13 +123,21 @@ then then echo "Will register MCP server (user scope): $name" else - if ! code_spec="$(python3 -c 'import json, re, subprocess, sys + rc=0 + code_spec="$(python3 -c 'import json, re, subprocess, sys spec = json.loads(sys.argv[1]) spec.pop("desktop", None) def secret(match): name = match.group(1) try: + if subprocess.run(["szecret", "has", name], capture_output=True).returncode != 0: + # Not a reader only when it exists elsewhere; anything else is a fault. + names = subprocess.run(["szecret", "list", "--names", "--all"], check=True, capture_output=True, text=True).stdout.split() + if any(n.endswith("/" + name) for n in names): + print("this host does not read %s" % name) + sys.exit(3) + sys.exit("szecret has no %s" % name) return subprocess.run(["szecret", "get", name], check=True, capture_output=True, text=True).stdout.strip() except (OSError, subprocess.CalledProcessError): sys.exit("szecret get %s failed" % name) @@ -140,9 +151,16 @@ def expand(value): return [expand(v) for v in value] return value -print(json.dumps(expand(spec)))' "$spec" 2>&1)" +print(json.dumps(expand(spec)))' "$spec" 2>&1)" || rc=$? + if [[ "$rc" -ne 0 ]] then - red "MCP server (user scope) not registered: $name: $code_spec" + if [[ "$rc" -eq 3 ]] + then + claude mcp remove --scope user "$name" >/dev/null 2>&1 || true + echo "MCP server (user scope) not here: $name: $code_spec" + else + red "MCP server (user scope) not registered: $name: $code_spec" + fi continue fi green "MCP server (user scope): $name" |
