Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions linux/user-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,24 @@ async fn main() {
.after_help("By default expects to be run via systemd as root and passed a socket file-descriptor to listen on.")
.get_matches();

let socket_path = Path::new(args.get_one::<String>(SOCKET_PATH_ARG).expect("default"));
let socket_path = match args.get_one::<String>(SOCKET_PATH_ARG) {
Some(path) => Path::new(path),
None => {
error!("No socket path provided in arguments");
return;
}
};

if libsystemd::logging::connected_to_journal() {
tracing_subscriber::registry()
.with(tracing_journald::layer().expect("Unable to connect to journald socket"))
.init();
match tracing_journald::layer() {
Ok(layer) => {
tracing_subscriber::registry().with(layer).init();
}
Err(e) => {
error!("Unable to connect to journald socket: {}", e);
tracing_subscriber::fmt::init();
}
}
} else {
tracing_subscriber::fmt::init();
}
Expand Down
26 changes: 22 additions & 4 deletions linux/user-daemon/src/user_presence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ impl NotificationUserPresence {
.timeout(*TIMEOUT);

let mut apply_workaround = false;
let server_info = notify_rust::get_server_information().unwrap();
let server_info = match notify_rust::get_server_information() {
Ok(info) => info,
Err(e) => {
debug!("Failed to get server information: {}", e);
return Err(io::Error::new(
io::ErrorKind::Other,
format!("Failed to get server information: {}", e),
));
}
};
if let Some(version) = WORKAROUND_SERVERS.get(server_info.name.as_str()) {
if version == &server_info.version {
debug!(
Expand All @@ -69,7 +78,16 @@ impl NotificationUserPresence {
notification.action("deny", "Deny");
}

let notify_handle = notification.show().unwrap();
let notify_handle = match notification.show() {
Ok(handle) => handle,
Err(e) => {
debug!("Failed to show notification: {}", e);
return Err(io::Error::new(
io::ErrorKind::Other,
format!("Failed to show notification: {}", e),
));
}
};

let mut action = String::new();
notify_handle.wait_for_action(|a| action = a.to_owned());
Expand All @@ -91,13 +109,13 @@ impl NotificationUserPresence {
#[async_trait]
impl UserPresence for NotificationUserPresence {
async fn approve_registration(&self, application: &AppId) -> Result<bool, io::Error> {
let site_name = try_reverse_app_id(application).unwrap_or(String::from("site"));
let site_name = try_reverse_app_id(application).unwrap_or_else(|| String::from("site"));
let message = format!("Register {}", site_name);
self.test_user_presence(message).await
}

async fn approve_authentication(&self, application: &AppId) -> Result<bool, io::Error> {
let site_name = try_reverse_app_id(application).unwrap_or(String::from("site"));
let site_name = try_reverse_app_id(application).unwrap_or_else(|| String::from("site"));
let message = format!("Authenticate {}", site_name);
self.test_user_presence(message).await
}
Expand Down