hub v0.160.0: a live re-enroll mails the operator (R-1156); further refused backups counted, alarm once a day (R-1157); the reinstall's off-site re-issue says what it still does (R-1158)

This commit is contained in:
admin committed 2026-10-19 10:34:41 +02:00
1 parent d5e3c8b0d9
commit 503c93fada
10 files changed
+251 -28

No files matched your search

+11 -6
View File
@@ -97,8 +97,12 @@ type Handler struct {
// offsiteReissuer (F3, v0.57.0) re-issues the customer's offsite credentials on clean-slate
// re-enrollment — main.go wires it to the web server's ReissueOffsiteForCustomer (same machinery
// as the manual "Re-issue offsite credentials" button, so escrow invalidation + events ride
// along). nil = no auto re-issue; a no-op when offsite isn't provisioned/enabled for the customer.
// as the manual "Re-issue offsite credentials" button). nil = no auto re-issue; a no-op when
// offsite isn't provisioned/enabled for the customer. WHAT IT STILL DOES (R-1158, 2026-10-19): it
// resets the Storage Box sub-account password that only the HUB uses (offsitekeys.TargetFor — the
// registrar's login); no box reads it since hub v0.127.0 (consume-password answers 410, every box
// reaches the store with its own registered key). Kept because it hands the hub a fresh, working
// login at every clean reinstall — which repairs a broken stored one — not because the box needs it.
offsiteReissuer func(ctx context.Context, customerID string) error
// intentHub (v0.58.0, Direction-2 immediate-sync) is the in-memory per-customer generation
@@ -1266,8 +1270,8 @@ func (h *Handler) handleHostEnroll(w http.ResponseWriter, r *http.Request) {
// above never re-issues; it tells the operator to delete). For a CLAIMED customer the fresh box has no
// password; auto-issue a reset code so the customer isn't stranded at the claim page hunting for
// the manual "request a new code" button (delivery rides the report ACK). No-op for an unclaimed
// customer (first provision). Also re-issue offsite credentials to the fresh box (F3) — the
// one-time offsite password only ever reached the OLD controller, so the fresh one has no target.
// customer (first provision). Also re-issue the off-site login (F3) — since hub v0.127.0 that is the
// HUB's own Storage Box login, not something the fresh box receives (R-1158; see offsiteReissuer).
h.reissueOnReenroll(cc)
w.Header().Set("Content-Type", "application/json")
@@ -1292,8 +1296,9 @@ func (h *Handler) reissueOnReenroll(cc *store.CustomerConfig) {
}
}
}
// F3 — offsite continuity: re-stage the one-time offsite password to the fresh controller (the
// one-time password only ever reached the OLD controller). ⚠ CORRECTED 2026-08-04 (R-196): this
// F3 — the off-site login: a fresh Storage Box sub-account password, stored for the HUB's registrar
// (R-1158: no box receives it since hub v0.127.0; the fresh box registers its own key with the
// controller API key). ⚠ CORRECTED 2026-08-04 (R-196): this
// used to claim "the re-issuer resets the restic repo password, which makes the OLD escrow blob
// stale". It does not and cannot — the re-issuer resets the PROVIDER account password; the
// repository password is generated on the box and never leaves it except sealed under R. The
+22 -5
View File
@@ -232,8 +232,16 @@ func TestR1154_DeliberatelyOffOldHostWarnsAndReissuesNothing(t *testing.T) {
}
}
// A LIVE box enrolling again (an installer --resume after its agent started, a repair re-run) is recorded as info,
// NOT mailed, and nothing is re-issued. Three ways to be live, each alone, plus connected-while-off.
// A LIVE box enrolling again (an installer --resume after its agent started, a repair re-run, or a reinstall within the
// stale threshold) never raises the reinstall-over-old-host event and re-issues nothing; since hub v0.160.0 (R-1156) it
// is a WARNING mailed to the operator with the same instruction. Three ways to be live, each alone, plus
// connected-while-off.
//
// COMPANION RED-PROOF R-1156 (observed 2026-10-19): with the live branch's severity back at "info" this fails with
//
// r1154_reenroll_test.go: host report fresh: the live re-enroll must be a warning (mailed): info|Host …
//
// Restored.
//
// COMPANION RED-PROOF (observed 2026-10-19): with classifyReenroll replaced by an unconditional "gone" this fails
// with
@@ -241,7 +249,7 @@ func TestR1154_DeliberatelyOffOldHostWarnsAndReissuesNothing(t *testing.T) {
// r1154_reenroll_test.go: host report fresh: a live box raised the reinstall warning
//
// (and the same for the other three cases). Restored.
func TestR1154_LiveHostIsRecordedNotWarned(t *testing.T) {
func TestR1154_LiveHostWarnsButIsNotAReinstall(t *testing.T) {
cases := []struct {
name string
setup func(t *testing.T, f *r1154Fixture)
@@ -282,8 +290,17 @@ func TestR1154_LiveHostIsRecordedNotWarned(t *testing.T) {
if f.eventAt(t, eventHostReenrollWhileLive).IsZero() {
t.Errorf("%s: the live re-enroll was not recorded (host_reenroll_while_live)", c.name)
}
if !strings.HasPrefix(f.eventMessage(t, eventHostReenrollWhileLive), "info|") {
t.Errorf("%s: the live record must be info (recorded, never mailed): %s", c.name, f.eventMessage(t, eventHostReenrollWhileLive))
got := f.eventMessage(t, eventHostReenrollWhileLive)
if !strings.HasPrefix(got, "warning|") {
t.Fatalf("%s: the live re-enroll must be a warning (mailed): %s", c.name, got)
}
for _, want := range []string{r1154Host, "nothing was re-issued", "delete the old host (Hosts page) and run the installer again", "nothing needs doing"} {
if !strings.Contains(got, want) {
t.Errorf("%s: the live warning lacks %q: %s", c.name, want, got)
}
}
if !f.operatorMailed(t, eventHostReenrollWhileLive) {
t.Errorf("%s: the operator mail path was not reached for the live re-enroll", c.name)
}
})
}
+11 -6
View File
@@ -25,8 +25,10 @@ import (
// controller's report are older than staleThreshold or absent; the hostStatus threshold and comparison):
// the operator-only WARNING host_reinstall_over_old_host, mailed to the operator, saying what to do.
// - The box is live (a --resume after its agent started, a repair re-run, or a reinstall done within the
// threshold of the old box's last report): the operator-only INFO host_reenroll_while_live, recorded on
// the event list, never mailed.
// threshold of the old box's last report): the operator-only WARNING host_reenroll_while_live, mailed to the
// operator with the same instruction (R-1156, hub v0.160.0: a reinstall done within 45 minutes of the old
// box's last report reads as live, and was recorded without a mail until then). The cost: a --resume or a
// repair re-run mails too — the text says that case needs nothing.
//
// WHY NOT RE-ISSUE AUTOMATICALLY (security review of the first draft, 2026-10-19): the passphrase is a
// household-held secret typed into the installer. Re-issuing a household's off-site credential and
@@ -101,10 +103,13 @@ func (h *Handler) noteReenrollOverExistingHost(cc *store.CustomerConfig, host *s
"re-issue the claim code and the off-site login from the customer page."
h.saveReenrollEvent(cc.CustomerID, eventHostReinstallOverOldHost, "warning", msg, host.HostID, why)
case reenrollLive:
h.logger.Printf("[INFO] host re-enrolled: %s (customer %s) — the box is live: %s", host.HostID, cc.CustomerID, why)
msg := "Host " + host.HostID + " enrolled again while the box is live (" + why + "); nothing was re-issued. " +
"If this box was reinstalled, delete the old host and run the installer again, or re-issue from the customer page."
h.saveReenrollEvent(cc.CustomerID, eventHostReenrollWhileLive, "info", msg, host.HostID, why)
h.logger.Printf("[WARN] host re-enrolled: %s (customer %s) while the box looks live: %s; nothing re-issued, the operator is told",
host.HostID, cc.CustomerID, why)
msg := "Host " + host.HostID + " of " + cc.CustomerID + " enrolled again while the box looks live (" + why +
"); nothing was re-issued. If this box was reinstalled: delete the old host (Hosts page) and run the installer " +
"again, or re-issue the claim code and the off-site login from the customer page. If it was an installer " +
"--resume or a repair re-run, nothing needs doing."
h.saveReenrollEvent(cc.CustomerID, eventHostReenrollWhileLive, "warning", msg, host.HostID, why)
default:
h.logger.Printf("[WARN] host re-enrolled: %s (customer %s) — not classified: %s", host.HostID, cc.CustomerID, why)
}