From bd31eda97275a8ba80e4852a2821b032a708b5d6 Mon Sep 17 00:00:00 2001 From: Ednunp <29843396+Ednunp@users.noreply.github.com> Date: Mon, 27 Jul 2026 12:17:01 +0100 Subject: [PATCH] Live nag for a weak service password while the app is already open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-on: the weak-service-password warning fired only at app launch, so a service that went weak underneath a running app (or that the user hasn't relaunched the app since) wouldn't be surfaced until the next launch. Now the 1 Hz status tick also polls it — self-throttled to at most every 15s and one-shot per app session (the flag is set before the modal so a re-entrant tick can't stack it), sharing the same ServicePasswordNeedsStrengthening decision and the same offer-to-open-service-settings dialog. Costs nothing once handled or once the password is strong. (Confirmed against the service's DIAGNOSTIC log — the strength-rule flag has been present since the 08:20 self-update; an earlier check looked in the wrong log file.) Gate 71/71 + 7 relay tests. Co-Authored-By: Claude Fable 5 --- src/RemSound.App/MainForm.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/RemSound.App/MainForm.cs b/src/RemSound.App/MainForm.cs index 4e993c7..d030d2d 100644 --- a/src/RemSound.App/MainForm.cs +++ b/src/RemSound.App/MainForm.cs @@ -1373,6 +1373,10 @@ public sealed partial class MainForm : Form EvaluatePriorityModeScope(); UpdateStatus(); SnapshotLogIfDue(); + // Catch a weak SERVICE password even while the app is ALREADY open (e.g. the service + // auto-updated to 5.6 underneath us) — self-throttled + one-shot, so it costs nothing + // once handled. The service can't warn the user itself (headless, session 0). + MaybeWarnWeakServicePassword(); EnsureRequestedAudioRunning(); // Refresh the Connectivity tab's peer lists from the same 1 Hz tick — replaces // the dialog's old 1.5 s dedicated refresh timer. Each Sync* helper short-circuits @@ -1680,9 +1684,19 @@ public sealed partial class MainForm : Form /// notice sequence as the other startup warnings) and offer to open the service settings to fix it /// (Ed, 2026-07-27 — "people won't know to change the service password"). Self-resolving: once the /// service password is strengthened, this never fires again. + // Warn at most ONCE per app session (launch OR the live poll below), and re-check no more than + // every 15 s when driven from the 1 Hz status tick so we're not reading the service state every + // second. Cleared only by a new app session — once fixed, ServicePasswordNeedsStrengthening goes + // false and it never fires again anyway. + private bool serviceWeakPasswordWarned; + private long lastServicePwCheckTick; + private void MaybeWarnWeakServicePassword() { - if (IsDisposed || CuePlayer.GloballyMuted) return; + if (IsDisposed || CuePlayer.GloballyMuted || serviceWeakPasswordWarned) return; + var now = Environment.TickCount64; + if (lastServicePwCheckTick != 0 && now - lastServicePwCheckTick < 15_000) return; + lastServicePwCheckTick = now; try { var installed = ServiceControl.Query() is not (ServiceState.NotInstalled or ServiceState.Unknown); @@ -1691,6 +1705,7 @@ public sealed partial class MainForm : Form if (!ServicePasswordNeedsStrengthening(installed, pw)) return; } catch { return; } // service state unreadable (e.g. Win7 without the feature) — nothing to warn about + serviceWeakPasswordWarned = true; // set BEFORE the modal so a re-entrant tick can't stack it var open = ForegroundDialog.Show(owner => MessageBox.Show(owner, "Your RemSound background service is using a password that's too weak to meet the new " + "security rules, so the service won't stream until the password is changed. (The "