fix(fuse,core,cli,gui): say when the keyring refuses the refreshed sign-in

A rotation the keyring refused was retried and kept in the kernel
keyring, but only the log said so, and a reboot before the keyring took
it still signed the user out.

`Response::Status` carries `tokens_unsaved` while one waits. The tray
says "Sign-in not saved — unlock your keyring" and needs attention, the
app's status says the same, `pdfs status` prints a Keyring line and
`pdfs diagnose` warns. New strings are translated in every catalog
(B61).
This commit is contained in:
nvrl committed 2026-10-09 12:22:02 +02:00
1 parent 3458e2e72d
commit 2b6c37f543
17 files changed
+616 -438

No files matched your search

+16
View File
@@ -2025,6 +2025,7 @@ fn cmd_status() -> Result<()> {
paused,
paused_until,
session_expired,
tokens_unsaved,
..
}) => {
let state = match (online, paused) {
@@ -2061,6 +2062,11 @@ fn cmd_status() -> Result<()> {
failing_error.as_deref().unwrap_or("no error recorded"),
);
}
if tokens_unsaved {
println!(
"Keyring refuses the refreshed sign-in; unlock it, or a reboot needs `pdfs login`"
);
}
}
Ok(other) => println!("Mount: unexpected response {other:?}"),
Err(_) => println!("Mount: not running."),
@@ -3435,6 +3441,7 @@ fn cmd_diagnose() -> Result<()> {
mountpoint,
online,
session_expired,
tokens_unsaved,
pending_uploads,
pending_changes,
..
@@ -3456,6 +3463,15 @@ fn cmd_diagnose() -> Result<()> {
|kind| format!("{mountpoint} ({kind})"),
),
);
// The keyring check above read the blob, which still holds the
// tokens the daemon could not replace.
if tokens_unsaved {
report.finding(
DiagnoseLevel::Warn,
" session tokens",
"the keyring refuses the refreshed ones; unlock it, or a reboot needs `pdfs login`",
);
}
// A refused session reads as offline too, but no connection will
// bring it back, and the keyring check above cannot tell.
if session_expired {
+10
View File
@@ -750,6 +750,16 @@ pub fn stored_session_is_newer() -> bool {
}
}
/// Whether a session in this process holds refreshed tokens the keyring has
/// not taken yet. They are retried and kept in the kernel keyring meanwhile,
/// which a reboot clears, so the user is asked to unlock the keyring (B61).
pub fn tokens_unsaved() -> bool {
TOKEN_SINKS
.lock()
.values()
.any(|sink| sink.state.lock().unsaved.is_some())
}
/// Where each live session in this process writes its rotated tokens, by
/// session id, for [`persist`] to find.
static TOKEN_SINKS: parking_lot::Mutex<BTreeMap<String, Arc<TokenSink>>> =
+5
View File
@@ -1964,6 +1964,11 @@ pub enum Response {
/// connection brings it back: only signing in again does.
#[serde(default)]
session_expired: bool,
/// True while the keyring refuses the session's refreshed tokens. The
/// daemon keeps retrying; until it succeeds, a reboot signs the user
/// out.
#[serde(default)]
tokens_unsaved: bool,
},
/// A human-readable success message.
Ok { message: String },
+1
View File
@@ -335,6 +335,7 @@ pub(crate) fn status_response(core: &Core, username: &str, mountpoint: &Path) ->
pins,
online: core.online.load(Ordering::Relaxed),
session_expired: core.session_expired(),
tokens_unsaved: pdfs_core::auth::tokens_unsaved(),
pending_uploads: queued.uploads.max(0) as u64 + landing,
pending_changes: queued.changes.max(0) as u64,
}
+3 -1
View File
@@ -236,6 +236,7 @@ fn status_keys(status: &CtlResponse) -> (String, String) {
budget,
online,
session_expired,
tokens_unsaved,
pending_uploads,
pending_changes,
..
@@ -248,7 +249,7 @@ fn status_keys(status: &CtlResponse) -> (String, String) {
);
let key = format!(
"{queue}/{staged_bytes}/{paused}/{paused_until:?}/{username}/{mountpoint}/{pinned}/\
{used}/{budget}/{online}/{session_expired}"
{used}/{budget}/{online}/{session_expired}/{tokens_unsaved}"
);
(key, queue)
}
@@ -327,6 +328,7 @@ mod tests {
pins: Vec::new(),
online: true,
session_expired: false,
tokens_unsaved: false,
pending_uploads: 1,
pending_changes: 0,
};
+14
View File
@@ -1229,6 +1229,7 @@ pub(crate) fn paint_status(ui: &Rc<Ui>, status: Response) {
paused,
paused_until,
session_expired,
tokens_unsaved,
..
} = status
else {
@@ -1241,6 +1242,8 @@ pub(crate) fn paint_status(ui: &Rc<Ui>, status: Response) {
let queued = i18n::pending_summary(pending_uploads, pending_changes);
let state = if session_expired {
SyncState::SessionExpired { queued }
} else if tokens_unsaved {
SyncState::TokensUnsaved
} else if paused {
SyncState::Paused {
until: paused_until,
@@ -1309,6 +1312,9 @@ pub(crate) enum SyncState {
SessionExpired {
queued: Option<String>,
},
/// The keyring refuses the session's refreshed tokens. Sync goes on, but
/// a reboot before the keyring takes them signs the user out.
TokensUnsaved,
/// The user paused syncing; nothing goes up until it resumes. Outranks
/// everything else, because it is the reason for everything else.
Paused {
@@ -1358,6 +1364,14 @@ fn paint_sync_status(ui: &Rc<Ui>, state: SyncState) {
None => gettext("Sign in again to sync"),
}),
),
SyncState::TokensUnsaved => (
"dialog-warning-symbolic",
Some("warning"),
gettext("Sign-in not saved"),
Some(gettext(
"Unlock your keyring, or the next reboot signs you out",
)),
),
SyncState::Paused { until, queued } => (
"media-playback-pause-symbolic",
Some("warning"),
+18
View File
@@ -238,6 +238,7 @@ fn status_state(
failing_ops,
paused,
session_expired,
tokens_unsaved,
..
} = status
else {
@@ -247,6 +248,8 @@ fn status_state(
let queued = i18n::pending_summary(*pending_uploads, *pending_changes);
let phase = if *session_expired {
Phase::SessionExpired
} else if *tokens_unsaved {
Phase::Attention
} else {
phase_of(
paused,
@@ -260,6 +263,8 @@ fn status_state(
// Outranks everything: it is why nothing else moves, and the one
// thing that fixes it is the user's to do.
_ if *session_expired => gettext("Session expired — sign in again"),
// Sync goes on meanwhile, but a reboot ends it until the next login.
_ if *tokens_unsaved => gettext("Sign-in not saved — unlock your keyring"),
_ if paused => gettext("Sync paused"),
_ if failing_ops > 0 => ngettext_f(
"{n} change needs attention",
@@ -642,6 +647,19 @@ mod tests {
assert_eq!(state.line, "Session expired — sign in again");
}
/// B61: the keyring refusing the refreshed tokens was only in the log.
#[test]
fn a_sign_in_the_keyring_refused_needs_attention() {
let state = status_state(
&status(r#","tokens_unsaved":true"#),
&[],
&[],
Path::new("/m"),
);
assert_eq!(state.phase, Phase::Attention);
assert_eq!(state.line, "Sign-in not saved — unlock your keyring");
}
#[test]
fn a_daemon_that_does_not_say_has_a_live_session() {
let state = status_state(&status(""), &[], &[], Path::new("/m"));