fix: improve error handling to prevent softlock
- handle greetd ipc auth_message error types as errors - handle locker pam error_msg as errors - fixes an issue where greeter would get stuck in 'Authenticating...' state due to error messages being treated as normal messages
This commit is contained in:
parent
d5c4746a5a
commit
5dc1db27ed
2 changed files with 24 additions and 5 deletions
|
|
@ -101,9 +101,7 @@ pub fn subscription() -> Subscription<Message> {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
//TODO: treat error type differently?
|
greetd_ipc::AuthMessageType::Info => {
|
||||||
greetd_ipc::AuthMessageType::Info
|
|
||||||
| greetd_ipc::AuthMessageType::Error => {
|
|
||||||
_ = sender
|
_ = sender
|
||||||
.send(
|
.send(
|
||||||
common::Message::Prompt(auth_message, false, None)
|
common::Message::Prompt(auth_message, false, None)
|
||||||
|
|
@ -111,6 +109,9 @@ pub fn subscription() -> Subscription<Message> {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
greetd_ipc::AuthMessageType::Error => {
|
||||||
|
_ = sender.send(Message::Error(auth_message)).await;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
greetd_ipc::Response::Error {
|
greetd_ipc::Response::Error {
|
||||||
error_type,
|
error_type,
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,25 @@ impl Conversation {
|
||||||
pam_client::ErrorCode::CONV_ERR
|
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 {
|
impl pam_client::ConversationHandler for Conversation {
|
||||||
|
|
@ -223,9 +242,8 @@ impl pam_client::ConversationHandler for Conversation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn error_msg(&mut self, prompt_c: &CStr) {
|
fn error_msg(&mut self, prompt_c: &CStr) {
|
||||||
//TODO: treat error type differently?
|
|
||||||
tracing::info!("error_msg {:?}", prompt_c);
|
tracing::info!("error_msg {:?}", prompt_c);
|
||||||
match self.message(prompt_c) {
|
match self.error_message(prompt_c) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::warn!("failed to send error_msg: {:?}", err);
|
tracing::warn!("failed to send error_msg: {:?}", err);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue