diff --git a/src/greeter/ipc.rs b/src/greeter/ipc.rs index c6e070d..ff930af 100644 --- a/src/greeter/ipc.rs +++ b/src/greeter/ipc.rs @@ -101,9 +101,7 @@ pub fn subscription() -> Subscription { ) .await; } - //TODO: treat error type differently? - greetd_ipc::AuthMessageType::Info - | greetd_ipc::AuthMessageType::Error => { + greetd_ipc::AuthMessageType::Info => { _ = sender .send( common::Message::Prompt(auth_message, false, None) @@ -111,6 +109,9 @@ pub fn subscription() -> Subscription { ) .await; } + greetd_ipc::AuthMessageType::Error => { + _ = sender.send(Message::Error(auth_message)).await; + } }, greetd_ipc::Response::Error { error_type, diff --git a/src/locker.rs b/src/locker.rs index 7c147c0..49b13fe 100644 --- a/src/locker.rs +++ b/src/locker.rs @@ -202,6 +202,25 @@ impl Conversation { pam_client::ErrorCode::CONV_ERR }) } + + fn error_message(&mut self, prompt_c: &CStr) -> Result<(), pam_client::ErrorCode> { + let prompt = prompt_c.to_str().map_err(|err| { + tracing::error!("failed to convert prompt to UTF-8: {:?}", err); + pam_client::ErrorCode::CONV_ERR + })?; + + futures::executor::block_on(async { + self.msg_tx + .send(cosmic::Action::App( + Message::Error(prompt.to_string()), + )) + .await + }) + .map_err(|err| { + tracing::error!("failed to send error message: {:?}", err); + pam_client::ErrorCode::CONV_ERR + }) + } } impl pam_client::ConversationHandler for Conversation { @@ -223,9 +242,8 @@ impl pam_client::ConversationHandler for Conversation { } } fn error_msg(&mut self, prompt_c: &CStr) { - //TODO: treat error type differently? tracing::info!("error_msg {:?}", prompt_c); - match self.message(prompt_c) { + match self.error_message(prompt_c) { Ok(()) => (), Err(err) => { tracing::warn!("failed to send error_msg: {:?}", err);