fix(actions): never wait for a polkit prompt on remote reboot/shutdown

Without polkit permission (for example no active local session)
systemctl reboot/poweroff waited for an authentication dialog on the
controlled screen. Pass --no-ask-password so the action fails and is
logged instead. README: the viewer's terminal session list, reboot and
shutdown, and its Wayland window/clipboard were tested in a VM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
VallierDevandClaude Opus 5.5 committed 2026-10-17 16:31:41 +08:00
1 parent 1b10a22c8c
commit 94fd3c2fa7
3 files changed
+14 -7

No files matched your search

+4 -2
View File
@@ -61,6 +61,8 @@ fn save(settings: &Settings) {
#[derive(Default)]
pub struct PeerActions { started: AtomicBool }
/// Power actions pass --no-ask-password: without polkit permission (e.g. no active local session) systemctl
/// would otherwise wait for an authentication dialog on the controlled screen; fail and log instead.
fn quiet(program: &str, args: &[&str]) -> bool {
Command::new(program).args(args).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null())
.status().map(|s| s.success()).unwrap_or(false)
@@ -135,8 +137,8 @@ impl PeerActions {
let ok = detached("gnome-system-monitor", &[]) || detached("plasma-systemmonitor", &[]) || detached("xfce4-taskmanager", &[]);
log::info!("System action show_taskmgr: ok={}", ok); return false
}
REBOOT_SYSTEM => { log::warn!("System action reboot_system requested by viewer"); log::info!("reboot ok={}", quiet("systemctl", &["reboot"])); return false }
SHUTDOWN_SYSTEM => { log::warn!("System action shutdown_system requested by viewer"); log::info!("poweroff ok={}", quiet("systemctl", &["poweroff"])); return false }
REBOOT_SYSTEM => { log::warn!("System action reboot_system requested by viewer"); log::info!("reboot ok={}", quiet("systemctl", &["--no-ask-password", "reboot"])); return false }
SHUTDOWN_SYSTEM => { log::warn!("System action shutdown_system requested by viewer"); log::info!("poweroff ok={}", quiet("systemctl", &["--no-ask-password", "poweroff"])); return false }
_ => {}
}
let mut state = state().lock().unwrap();