Increase dialog exit status parsing safety in the locker
This also stops using -1 as auth failed, and moves all failure statuses to positive numbers. It looks like Exiting with -1 ends up setting the status to 255 on exit, but then in the locker, it sees this as 255 and not -1, since things get coerced into 32-bit integers.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use std::{
|
||||
io::Read,
|
||||
os::unix::process::ExitStatusExt,
|
||||
process::{Child, Command, Stdio},
|
||||
time::Instant, path::{PathBuf, Path},
|
||||
};
|
||||
@ -9,7 +8,7 @@ use xcb::{randr, x, Xid, XidNew};
|
||||
use xcb_xembed::embedder::Embedder;
|
||||
|
||||
use bscreensaver_command::{BCommand, create_command_window};
|
||||
use bscreensaver_util::{*, settings::Configuration};
|
||||
use bscreensaver_util::{*, dialog::DialogExitStatus, settings::Configuration};
|
||||
|
||||
use crate::{
|
||||
monitor::*,
|
||||
@ -308,17 +307,24 @@ impl<'a> Screensaver<'a> {
|
||||
warn!("Failed to check unlock dialog's status: {}", err);
|
||||
self.unlock_dialog = Some(unlock_dialog);
|
||||
},
|
||||
Ok(Some(status)) if status.success() => {
|
||||
info!("Authentication succeeded");
|
||||
self.unlock_screen()?;
|
||||
}
|
||||
Ok(Some(status)) if status.signal().is_some() => {
|
||||
if let Some(signum) = status.signal() {
|
||||
warn!("Unlock dialog crashed with signal {}", signum);
|
||||
Ok(Some(status)) => {
|
||||
let ok = match DialogExitStatus::try_from(status) {
|
||||
Ok(result) => {
|
||||
info!("{}", result);
|
||||
result == DialogExitStatus::AuthSucceeded
|
||||
},
|
||||
Err(error) => {
|
||||
warn!("{}", error);
|
||||
false
|
||||
},
|
||||
};
|
||||
|
||||
if ok {
|
||||
self.unlock_screen()?;
|
||||
} else {
|
||||
self.hide_cursor();
|
||||
}
|
||||
self.hide_cursor();
|
||||
},
|
||||
Ok(Some(_)) => self.hide_cursor(), // auth failed, dialog has quit, do nothing
|
||||
Ok(None) => self.unlock_dialog = Some(unlock_dialog), // dialog still running
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user