fix: audit fixes — RefCell across await, async avatar decode (v0.6.10)

- init_fingerprint_async: hoist username before the await so a concurrent
  connect_monitor signal (hotplug / suspend-resume) cannot cause a RefCell
  panic. Re-borrow after the await for signal wiring.
- set_avatar_from_file: decode via gio::File::read_future +
  Pixbuf::from_stream_at_scale_future so the GTK main thread stays
  responsive during monitor hotplug. Default icon shown while loading.
This commit is contained in:
2026-04-24 12:34:00 +02:00
parent 3adc5e980d
commit 39d9cbb624
5 changed files with 61 additions and 37 deletions
+23 -17
View File
@@ -168,32 +168,38 @@ fn init_fingerprint_async(
let mut listener = FingerprintListener::new();
listener.init_async().await;
let handles = all_handles.borrow();
if handles.is_empty() {
return;
}
// Extract username without holding a borrow across the await below —
// otherwise a concurrent connect_monitor signal (hotplug / suspend-resume)
// that tries to borrow_mut() panics at runtime.
let username = {
let handles = all_handles.borrow();
if handles.is_empty() {
return;
}
let u = handles[0].username.clone();
if u.is_empty() {
return;
}
u
};
// Use the first monitor's username to check enrollment
let username = &handles[0].username;
if username.is_empty() {
return;
}
if !listener.is_available_async(username).await {
if !listener.is_available_async(&username).await {
log::debug!("fprintd not available or no enrolled fingers");
return;
}
let fp_rc = Rc::new(RefCell::new(listener));
// Show fingerprint label on all existing monitors
for h in handles.iter() {
lockscreen::show_fingerprint_label(h, &fp_rc);
// Re-borrow after the await — no further awaits in this scope, so it is
// safe to hold the borrow briefly while wiring up the labels.
{
let handles = all_handles.borrow();
for h in handles.iter() {
lockscreen::show_fingerprint_label(h, &fp_rc);
}
lockscreen::start_fingerprint(&handles[0], &fp_rc);
}
// Start verification listener on the first monitor only
lockscreen::start_fingerprint(&handles[0], &fp_rc);
// Publish the listener so hotplugged monitors get FP labels too
*shared_fp.borrow_mut() = Some(fp_rc);
});