comparison 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
comparison
equal deleted inserted replaced
77:351bdc13005e 78:002adfb98c5c
1 /// Generates the dynamic library entry points for a [PamModule] implementation. 1 /// Generates the dynamic library entry points for a PAM module
2 /// 2 ///
3 /// Calling `pam_hooks!(SomeType)` on a type that implements [PamModule] will 3 /// Calling `pam_hooks!(SomeType)` on a type that implements
4 /// generate the exported `extern "C"` functions that PAM uses to call into 4 /// [`PamModule`](crate::PamModule) will generate the exported
5 /// your module. 5 /// `extern "C"` functions that PAM uses to call into your module.
6 /// 6 ///
7 /// ## Examples: 7 /// ## Examples:
8 /// 8 ///
9 /// Here is full example of a PAM module that would authenticate and authorize everybody: 9 /// Here is full example of a PAM module that would authenticate
10 /// and authorize everybody:
10 /// 11 ///
11 /// ```no_run 12 /// ```no_run
12 /// use nonstick::{Flags, SimpleConversation, OwnedLibPamHandle, PamModule, PamHandleModule, Result as PamResult, pam_hooks}; 13 /// use nonstick::{
14 /// pam_hooks, Flags, OwnedLibPamHandle, PamHandleModule, PamModule, Result as PamResult,
15 /// SimpleConversation,
16 /// };
13 /// use std::ffi::CStr; 17 /// use std::ffi::CStr;
14 /// # fn main() {} 18 /// # fn main() {}
15 /// 19 ///
16 /// struct MyPamModule; 20 /// struct MyPamModule;
17 /// pam_hooks!(MyPamModule); 21 /// pam_hooks!(MyPamModule);
18 /// 22 ///
19 /// impl<T: PamHandleModule> PamModule<T> for MyPamModule { 23 /// impl<T: PamHandleModule> PamModule<T> for MyPamModule {
20 /// fn authenticate(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> { 24 /// fn authenticate(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> {
21 /// let password = handle.get_authtok(Some("what's your password?"))?; 25 /// let password = handle.get_authtok(Some("what's your password?"))?;
22 /// let response = format!("If you say your password is {password:?}, who am I to disagree?"); 26 /// let response =
27 /// format!("If you say your password is {password:?}, who am I to disagree?");
23 /// handle.info_msg(&response); 28 /// handle.info_msg(&response);
24 /// Ok(()) 29 /// Ok(())
25 /// } 30 /// }
26 /// 31 ///
27 /// fn account_management(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> { 32 /// fn account_management(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> {