fix(terminal+journal): forward via WorkerMsg (GTK thread) + journal fallback

Terminal: idle_add_local_once from non-GTK thread silently fails.
Forward ShowTerminalCode/DismissTerminalCode through WorkerMsg channel
which IS polled on the GTK main thread via timeout_add_local.

Journal: try --user-unit first, fall back to unfiltered journal if
permission denied (bfkiosk user may not be in systemd-journal group on
non-reflashed images). Send error line back to admin UI on spawn failure
instead of silent drop.
This commit is contained in:
Mitchell R 2026-05-22 21:08:24 +02:00
parent 7425fa9c63
commit 6d577b5411
No known key found for this signature in database
2 changed files with 15 additions and 11 deletions

View file

@ -121,15 +121,22 @@ impl JournalStream {
let kill_clone = kill.clone(); let kill_clone = kill.clone();
std::thread::spawn(move || { std::thread::spawn(move || {
// Try unit-scoped first, fall back to all journal if permission denied.
let mut child = match Command::new("journalctl") let mut child = match Command::new("journalctl")
.args(["-u", "betterframe-kiosk", "-f", "--no-pager", "-o", "short-iso", "-n", "50"]) .args(["--user-unit", "betterframe-kiosk", "-f", "--no-pager", "-o", "short-iso", "-n", "50"])
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::null()) .stderr(Stdio::piped())
.spawn() .spawn()
.or_else(|_| Command::new("journalctl")
.args(["-f", "--no-pager", "-o", "short-iso", "-n", "50"])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn())
{ {
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {
warn!("remote-debug: journalctl spawn failed: {e}"); warn!("remote-debug: journalctl spawn failed: {e}");
on_line(&format!("[ERROR] journalctl spawn failed: {e}"));
return; return;
} }
}; };

View file

@ -266,17 +266,10 @@ fn activate(app: &Application) {
maybe_apply_firmware_update(&server_for_reload, &key_for_reload); maybe_apply_firmware_update(&server_for_reload, &key_for_reload);
} }
ServerMsg::ShowTerminalCode(code) => { ServerMsg::ShowTerminalCode(code) => {
// Overlay on all windows: big centered code text. let _ = tx_for_reload.send(WorkerMsg::ShowTerminalCode(code));
// NOT logged — security requirement.
let code_clone = code.clone();
gtk::glib::idle_add_local_once(move || {
show_terminal_code_overlay(&code_clone);
});
} }
ServerMsg::DismissTerminalCode => { ServerMsg::DismissTerminalCode => {
gtk::glib::idle_add_local_once(|| { let _ = tx_for_reload.send(WorkerMsg::DismissTerminalCode);
dismiss_terminal_code_overlay();
});
} }
} }
} }
@ -334,6 +327,8 @@ fn activate(app: &Application) {
} }
WorkerMsg::Standby(display_id) => standby_display(display_id), WorkerMsg::Standby(display_id) => standby_display(display_id),
WorkerMsg::Wake(display_id) => wake_display(display_id), WorkerMsg::Wake(display_id) => wake_display(display_id),
WorkerMsg::ShowTerminalCode(code) => show_terminal_code_overlay(&code),
WorkerMsg::DismissTerminalCode => dismiss_terminal_code_overlay(),
} }
} }
gtk::glib::ControlFlow::Continue gtk::glib::ControlFlow::Continue
@ -349,6 +344,8 @@ pub enum WorkerMsg {
}, },
Standby(Option<u32>), Standby(Option<u32>),
Wake(Option<u32>), Wake(Option<u32>),
ShowTerminalCode(String),
DismissTerminalCode,
} }
fn output_name_for_display(display_id: u32) -> Option<String> { fn output_name_for_display(display_id: u32) -> Option<String> {