Mercurial > crates > nonstick
diff src/module.rs @ 72:47eb242a4f88
Fill out the PamHandle trait.
This updates the PamHandle trait to have methods for each Item,
and implements them on the LibPamHandle.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Wed, 04 Jun 2025 03:53:36 -0400 |
parents | 58f9d2a4df38 |
children | ac6881304c78 |
line wrap: on
line diff
--- a/src/module.rs Tue Jun 03 21:54:58 2025 -0400 +++ b/src/module.rs Wed Jun 04 03:53:36 2025 -0400 @@ -32,7 +32,7 @@ /// /// This is probably the first thing you want to implement. /// In most cases, you will want to get the user and password, - /// using [`LibPamHandle::get_user`] and [`LibPamHandle::get_authtok`], + /// using [`PamHandle::get_user`] and [`PamModuleHandle::get_authtok`], /// and verify them against something. /// /// See [the Module Writer's Guide entry for `pam_sm_authenticate`][mwg] @@ -255,15 +255,15 @@ /// let token = mux.masked_prompt("enter your one-time token")?; /// # Ok(()) /// # } -pub struct ConversationMux<C: Conversation>(pub C); +pub struct ConversationMux<'a, C: Conversation>(pub &'a mut C); -impl<C: Conversation> Conversation for ConversationMux<C> { +impl<C: Conversation> Conversation for ConversationMux<'_, C> { fn send(&mut self, messages: &[Message]) -> Result<Vec<Response>> { self.0.send(messages) } } -impl<C: Conversation> ConversationMux<C> { +impl<C: Conversation> ConversationMux<'_, C> { /// Prompts the user for something. pub fn prompt(&mut self, request: &str) -> Result<String> { let resp = self.send(&[Message::Prompt(request)])?.pop(); @@ -524,7 +524,9 @@ } } - let mut mux = ConversationMux(MuxTester); + let mut tester = MuxTester; + + let mut mux = ConversationMux(&mut tester); assert_eq!("answer", mux.prompt("question").unwrap()); assert_eq!( SecureString::from("open sesame"),