Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Preserve system preferences when rotating local authentication
pulse-triage[bot]f0f7e51d157c
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.jsonindex fd15e183d1..7676a6c12d 100644--- a/docs/release-control/v6/internal/status.json+++ b/docs/release-control/v6/internal/status.json@@ -5136,10 +5136,10 @@"name": "Self-hosted release confidence","target_score": 9,"current_score": 9,- "status": "target-met",+ "status": "partial","completion": {- "state": "complete",- "summary": "Self-hosted release confidence reached its target and was re-proved for v6.3.1 with exact-SHA dry-run, stable activation, published-asset integrity, installer, demo, container, Helm, private paid-runtime convergence, and bounded recovery from GitHub activation-marker propagation.",+ "state": "bounded-residual",+ "summary": "Self-hosted release confidence reached its target and was re-proved for v6.3.1 with exact-SHA dry-run, stable activation, published-asset integrity, installer, demo, container, Helm, private paid-runtime convergence, and bounded recovery from GitHub activation-marker propagation. Current maintenance residual: f04c230 source-binding repair is proposed as PR2091, not landed or released; its WebSocket/benchmark CI failures remain owned. Exact RC scope, qualification and required observation coverage remain outstanding.","tracking": []},"blockers": [],@@ -10403,16 +10403,16 @@],"work_claims": [{- "id": "pulse-maintainer-lane-l1",+ "id": "pulse-maintainer-lane-l6","agent_id": "pulse-maintainer",- "summary": "Bind future maintenance stable promotion to its soaked candidate, preserving explicit hotfix reason and soak checks",+ "summary": "Preserve non-auth system settings during quick security setup; retain authentication authorization and reviewed source identities","target_id": "v6-release-reliability",- "claimed_at": "2026-09-14T23:35:36Z",- "heartbeat_at": "2026-09-14T23:35:36Z",- "expires_at": "2026-09-15T01:35:36Z",+ "claimed_at": "2026-09-15T01:10:15Z",+ "heartbeat_at": "2026-09-15T01:10:15Z",+ "expires_at": "2026-09-15T03:10:15Z","work_item": {"kind": "lane",- "id": "L1"+ "id": "L6"}}],diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 04d5d36d3b..d70c06430f 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -8056,3 +8056,18 @@ provider keys, canonical IDs, JSON projection, temperature/size/cadence, separatnodes/controller members, and confirmed inventory removal.`TestPhysicalDiskReadbackSourceIDFallback` covers missing source metadata.This is synthetic runtime evidence, not USB hardware or reporter acceptance.++### Quick security setup preserves unrelated settings++Authenticated force setup in `internal/api/security_setup_fix.go` retains the+existing authentication and settings-write authorization checks. Rotating local+credentials does not reset non-auth system preferences.+`ConfigPersistence.InitializeSystemSettings` in `internal/config/persistence.go`+creates defaults only when system settings are absent, under the same instance+mutex as ordinary saves; existing bytes (including unknown fields and malformed+data requiring recovery) are not rewritten. A read error prevents initialization,+while authentication setup retains its existing nonfatal settings-error behavior.+This does not change token scopes, agent admission, or existing agent cleanup.+Regression coverage: `TestQuickSecuritySetupForcePreservesSystemSettings` and+`TestInitializeSystemSettingsPreservesExistingBytes`, `TestInitializeSystemSettingsMissing`,+`TestInitializeSystemSettingsReadError`.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 5f9fb209cc..a25dad0f0a 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -10840,3 +10840,18 @@ supported severity in frontend-modern/src/api/__tests__/notifications.test.ts.Formatting-only follow-up retains this warning-level contract. The production-componentbrowser matrix was rerun after formatting at desktop and narrow widths, includingall/critical/warning save/reload, cancel, and warning webhook creation.++### Quick security setup preserves unrelated settings++Authenticated force setup in `internal/api/security_setup_fix.go` retains the+existing authentication and settings-write authorization checks. Rotating local+credentials does not reset non-auth system preferences.+`ConfigPersistence.InitializeSystemSettings` in `internal/config/persistence.go`+creates defaults only when system settings are absent, under the same instance+mutex as ordinary saves; existing bytes (including unknown fields and malformed+data requiring recovery) are not rewritten. A read error prevents initialization,+while authentication setup retains its existing nonfatal settings-error behavior.+This does not change token scopes, agent admission, or existing agent cleanup.+Regression coverage: `TestQuickSecuritySetupForcePreservesSystemSettings` and+`TestInitializeSystemSettingsPreservesExistingBytes`, `TestInitializeSystemSettingsMissing`,+`TestInitializeSystemSettingsReadError`.diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 66d34fce95..cb8e03f21f 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -6085,3 +6085,18 @@ and the executor has no raw-command fallback. Missing runner admission isreported by canonical action readiness before a plan is persisted. Typedmutation completion and independently observed guest recovery remain separateresults. A running guest alone cannot prove a reboot.++### Quick security setup preserves unrelated settings++Authenticated force setup in `internal/api/security_setup_fix.go` retains the+existing authentication and settings-write authorization checks. Rotating local+credentials does not reset non-auth system preferences.+`ConfigPersistence.InitializeSystemSettings` in `internal/config/persistence.go`+creates defaults only when system settings are absent, under the same instance+mutex as ordinary saves; existing bytes (including unknown fields and malformed+data requiring recovery) are not rewritten. A read error prevents initialization,+while authentication setup retains its existing nonfatal settings-error behavior.+This does not change token scopes, agent admission, or existing agent cleanup.+Regression coverage: `TestQuickSecuritySetupForcePreservesSystemSettings` and+`TestInitializeSystemSettingsPreservesExistingBytes`, `TestInitializeSystemSettingsMissing`,+`TestInitializeSystemSettingsReadError`.diff --git a/internal/api/security_setup_fix.go b/internal/api/security_setup_fix.goindex b1b1d52ae8..7f89b6d203 100644--- a/internal/api/security_setup_fix.go+++ b/internal/api/security_setup_fix.go@@ -540,11 +540,12 @@ func handleQuickSecuritySetupFixed(r *Router) http.HandlerFunc {}}- // Save system settings to system.json+ // Initialize first-run defaults only; rotating authentication must not+ // reset unrelated preferences or overwrite settings needing recovery.systemSettings := config.DefaultSystemSettings()systemSettings.ConnectionTimeout = 10 // Default secondssystemSettings.AutoUpdateEnabled = false // Default disabled- if err := r.persistence.SaveSystemSettings(*systemSettings); err != nil {+ if err := r.persistence.InitializeSystemSettings(*systemSettings); err != nil {log.Error().Err(err).Msg("Failed to save system settings")// Continue anyway - not critical for auth setup}diff --git a/internal/api/security_setup_settings_preservation_test.go b/internal/api/security_setup_settings_preservation_test.gonew file mode 100644index 0000000000..00962d4b89--- /dev/null+++ b/internal/api/security_setup_settings_preservation_test.go@@ -0,0 +1,56 @@+package api++import (+ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ internalauth "github.com/rcourtman/pulse-go-rewrite/pkg/auth"+ "net/http"+ "net/http/httptest"+ "strings"+ "testing"+)++func TestQuickSecuritySetupForcePreservesSystemSettings(t *testing.T) {+ t.Setenv("PULSE_TRUSTED_PROXY_CIDRS", "")+ t.Setenv("PULSE_DOCKER", "true")+ resetTrustedProxyConfig()+ dir := t.TempDir()+ InitPersistentAuthStores(dir)+ hash, err := internalauth.HashPassword("ExistingPassword!1")+ if err != nil {+ t.Fatal(err)+ }+ token := strings.Repeat("ab", 32)+ record, err := config.NewAPITokenRecord(token, "synthetic", []string{config.ScopeSettingsWrite})+ if err != nil {+ t.Fatal(err)+ }+ cfg := &config.Config{AuthUser: "admin", AuthPass: hash, DataPath: dir, ConfigPath: dir, APITokens: []config.APITokenRecord{*record}}+ cfg.SortAPITokens()+ persistence := config.NewConfigPersistence(dir)+ before := config.DefaultSystemSettings()+ before.FullWidthMode = true+ before.ConnectionTimeout = 23+ if err := persistence.SaveSystemSettings(*before); err != nil {+ t.Fatal(err)+ }+ router := &Router{config: cfg, persistence: persistence}+ authLimiter.Reset("203.0.113.10")+ req := httptest.NewRequest(http.MethodPost, "/api/security/quick-setup", strings.NewReader(`{"username":"rotated","password":"RotatedPassword!1","apiToken":"`+token+`","force":true}`))+ req.RemoteAddr = "203.0.113.10:1234"+ req.Header.Set("X-API-Token", token)+ response := httptest.NewRecorder()+ handleQuickSecuritySetupFixed(router)(response, req)+ if response.Code != http.StatusOK {+ t.Fatalf("setup returned %d", response.Code)+ }+ after, err := persistence.LoadSystemSettings()+ if err != nil {+ t.Fatal(err)+ }+ if after == nil {+ t.Fatal("settings missing")+ }+ if !after.FullWidthMode || after.ConnectionTimeout != 23 {+ t.Fatalf("non-auth settings overwritten: fullWidthMode=%v connectionTimeout=%v", after.FullWidthMode, after.ConnectionTimeout)+ }+}diff --git a/internal/config/persistence.go b/internal/config/persistence.goindex cdbf221d8d..17d5eb11cf 100644--- a/internal/config/persistence.go+++ b/internal/config/persistence.go@@ -2070,11 +2070,29 @@ func (c *ConfigPersistence) LoadNodesConfig() (*NodesConfig, error) {return &config, nil}-// SaveSystemSettings saves system settings to file+// InitializeSystemSettings creates first-run settings without replacing existing+// bytes, including unknown fields or malformed data that needs recovery. The+// shared lock makes the existence check atomic with ordinary settings saves.+func (c *ConfigPersistence) InitializeSystemSettings(settings SystemSettings) error {+ c.mu.Lock()+ defer c.mu.Unlock()++ if _, err := c.fs.ReadFile(c.systemFile); err == nil {+ return nil+ } else if !os.IsNotExist(err) {+ return fmt.Errorf("inspect existing system settings: %w", err)+ }+ return c.saveSystemSettingsLocked(settings)+}++// SaveSystemSettings saves system settings to file.func (c *ConfigPersistence) SaveSystemSettings(settings SystemSettings) error {c.mu.Lock()defer c.mu.Unlock()+ return c.saveSystemSettingsLocked(settings)+}+func (c *ConfigPersistence) saveSystemSettingsLocked(settings SystemSettings) error {data, err := json.Marshal(settings)if err != nil {return fmt.Errorf("marshal system settings: %w", err)diff --git a/internal/config/system_settings_initialization_test.go b/internal/config/system_settings_initialization_test.gonew file mode 100644index 0000000000..55bececa90--- /dev/null+++ b/internal/config/system_settings_initialization_test.go@@ -0,0 +1,63 @@+package config++import (+ "errors"+ "os"+ "testing"+)++type initializationReadFailure struct{ FileSystem }++func (f initializationReadFailure) ReadFile(string) ([]byte, error) { return nil, os.ErrPermission }++func TestInitializeSystemSettingsPreservesExistingBytes(t *testing.T) {+ for name, content := range map[string]string{"custom": `{"fullWidthMode":true,"connectionTimeout":23,"futureOption":"keep"}`, "malformed": `{"broken":`, "empty": ""} {+ t.Run(name, func(t *testing.T) {+ p := NewConfigPersistence(t.TempDir())+ if err := os.WriteFile(p.systemFile, []byte(content), 0600); err != nil {+ t.Fatal(err)+ }+ if err := p.InitializeSystemSettings(*DefaultSystemSettings()); err != nil {+ t.Fatal(err)+ }+ got, err := os.ReadFile(p.systemFile)+ if err != nil {+ t.Fatal(err)+ }+ if string(got) != content {+ t.Fatalf("existing settings changed: %q", got)+ }+ })+ }+}+func TestInitializeSystemSettingsMissing(t *testing.T) {+ p := NewConfigPersistence(t.TempDir())+ if err := p.InitializeSystemSettings(*DefaultSystemSettings()); err != nil {+ t.Fatal(err)+ }+ got, err := p.LoadSystemSettings()+ if err != nil || got == nil {+ t.Fatalf("load initialized settings: %v", err)+ }+ got.FullWidthMode = true+ if err := p.SaveSystemSettings(*got); err != nil {+ t.Fatal(err)+ }+ if err := p.InitializeSystemSettings(*DefaultSystemSettings()); err != nil {+ t.Fatal(err)+ }+ got, err = p.LoadSystemSettings()+ if err != nil || !got.FullWidthMode {+ t.Fatalf("ordinary save lost after initialization: %v", err)+ }+}+func TestInitializeSystemSettingsReadError(t *testing.T) {+ p := NewConfigPersistence(t.TempDir())+ p.fs = initializationReadFailure{p.fs}+ if err := p.InitializeSystemSettings(*DefaultSystemSettings()); !errors.Is(err, os.ErrPermission) {+ t.Fatalf("expected read error, got %v", err)+ }+ if _, err := os.Stat(p.systemFile); !os.IsNotExist(err) {+ t.Fatalf("unexpected settings write: %v", err)+ }+}