server init adds the guardrails to a server.yaml from before them

An upgrade replaces the binary and leaves server.yaml alone, so a control
plane installed before guardrails stayed unguarded. Run again, init now
appends the baseline guard section (and so fetches the judge) when the file
has no guard key at all, keeping the old file as server.yaml.bak-<time>.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-05 12:39:28 +02:00
1 parent 3558dba485
commit dc65ea6899
5 files changed
+103 -3

No files matched your search

+13 -1
View File
@@ -144,7 +144,9 @@ func newServerInitCmd() *cobra.Command {
"SQLite or PostgreSQL, is moved in. Run again, it changes nothing.\n\n" +
"Each step is skipped when its result already exists, so it is safe to run\n" +
"again: to finish an install that stopped, or with another --host to\n" +
"reissue the certificate. It never overwrites server.yaml or the authority.\n\n" +
"reissue the certificate. It never overwrites server.yaml or the authority;\n" +
"to a server.yaml from before guardrails it adds the guard section, the old\n" +
"file kept beside it.\n\n" +
"The authority's key stays in " + defaultPKIDir + " on this machine. Move it\n" +
"somewhere safer once the nodes are onboarded if this machine is exposed.",
Args: cobra.NoArgs,
@@ -548,6 +550,16 @@ func (in *serverInit) ensureConfig(context.Context) error {
path := in.configPath()
if _, err := os.Stat(path); err == nil {
in.kept("%s (never overwritten)", path)
// A file from before guardrails has no guard: at all, and an
// upgrade alone leaves it unguarded. One that says guard:, even
// empty, was decided on and stays as it is.
added, err := appendGuardIfMissing(path, in.judgeWanted())
if err != nil {
return fmt.Errorf("%s: %w", path, err)
}
if added {
in.done("server.yaml: guardrails added (baseline policy), the old file kept beside it")
}
} else {
contact := in.admin
if contact == "" {