Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Publish billing state through owned private temporary files

pulse-triage[bot]e220fb037de4
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index 96e8a5da87..d87e8445de 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -44,6 +44,20 @@ replacement against stale regular files, symlinks, hardlinks and directories.
errors, independent concurrent writes and unchanged import staging. Existing
filesystem fault tests inject write errors through the same descriptor seam.
+The public Core `FileBillingStore` uses the same private publication primitive
+for default and named organisations, including plaintext-secret and integrity
+migrations. A stale `billing.json.tmp` is never opened, removed or renamed by
+the new writer. Independent store instances own separate temporary files;
+replacement publishes one complete encrypted, signed state, not mixed writes.
+Encryption, HMAC verification, normalisation, entitlement decisions and the
+existing best-effort migration error policy are unchanged. This does not add
+cross-instance read/modify/write serialisation or power-loss durability.
+`billing_state_atomic_test.go` exercises real saves and fresh-store recovery
+against stale files, symlinks, hardlinks and directories in both storage layouts,
+plus existing destination-link replacement, failed-publication cleanup/retry,
+plaintext migration and independent concurrent writers. Consuming Billing Admin
+proof must include the persisted producer responses, not only mocked save data.
+
### SSO settings results remain with their current reader
The existing SSO provider inventory, provider-detail editor, connection test and
diff --git a/internal/config/billing_state.go b/internal/config/billing_state.go
index 5dbe2c132a..ee975c53fb 100644
--- a/internal/config/billing_state.go
+++ b/internal/config/billing_state.go
@@ -215,18 +215,7 @@ func (s *FileBillingStore) SaveBillingState(orgID string, state *pkglicensing.Bi
return fmt.Errorf("create billing directory for org %q: %w", orgID, err)
}
- tmpPath := billingPath + ".tmp"
- if err := os.WriteFile(tmpPath, data, 0o600); err != nil {
- return fmt.Errorf("write temp billing state for org %q: %w", orgID, err)
- }
- if err := os.Rename(tmpPath, billingPath); err != nil {
- if removeErr := os.Remove(tmpPath); removeErr != nil && !errors.Is(removeErr, os.ErrNotExist) {
- log.Warn().
- Err(removeErr).
- Str("tmp_path", tmpPath).
- Str("org_id", orgID).
- Msg("Failed to remove temporary billing state file after failed rename")
- }
+ if err := writeConfigFileAtomic(defaultFileSystem{}, billingPath, data, 0o600); err != nil {
return fmt.Errorf("commit billing state for org %q: %w", orgID, err)
}