Mercurial > crates > nonstick
diff src/libpam/module.rs @ 78:002adfb98c5c
Rename files, reorder structs, remove annoying BorrowedBinaryData type.
This is basically a cleanup change. Also it adds tests.
- Renames the files with Questions and Answers to question and answer.
- Reorders the structs in those files to put the important ones first.
- Removes the BorrowedBinaryData type. It was a bad idea all along.
Instead, we just use (&[u8], u8).
- Adds some tests because I just can't help myself.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 08 Jun 2025 03:48:40 -0400 |
parents | 351bdc13005e |
children |
line wrap: on
line diff
--- a/src/libpam/module.rs Sun Jun 08 01:03:46 2025 -0400 +++ b/src/libpam/module.rs Sun Jun 08 03:48:40 2025 -0400 @@ -1,15 +1,19 @@ -/// Generates the dynamic library entry points for a [PamModule] implementation. +/// Generates the dynamic library entry points for a PAM module /// -/// Calling `pam_hooks!(SomeType)` on a type that implements [PamModule] will -/// generate the exported `extern "C"` functions that PAM uses to call into -/// your module. +/// Calling `pam_hooks!(SomeType)` on a type that implements +/// [`PamModule`](crate::PamModule) will generate the exported +/// `extern "C"` functions that PAM uses to call into your module. /// /// ## Examples: /// -/// Here is full example of a PAM module that would authenticate and authorize everybody: +/// Here is full example of a PAM module that would authenticate +/// and authorize everybody: /// /// ```no_run -/// use nonstick::{Flags, SimpleConversation, OwnedLibPamHandle, PamModule, PamHandleModule, Result as PamResult, pam_hooks}; +/// use nonstick::{ +/// pam_hooks, Flags, OwnedLibPamHandle, PamHandleModule, PamModule, Result as PamResult, +/// SimpleConversation, +/// }; /// use std::ffi::CStr; /// # fn main() {} /// @@ -19,7 +23,8 @@ /// impl<T: PamHandleModule> PamModule<T> for MyPamModule { /// fn authenticate(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> { /// let password = handle.get_authtok(Some("what's your password?"))?; -/// let response = format!("If you say your password is {password:?}, who am I to disagree?"); +/// let response = +/// format!("If you say your password is {password:?}, who am I to disagree?"); /// handle.info_msg(&response); /// Ok(()) /// }