comparison src/libpam/module.rs @ 90:f6186e41399b

Miscellaneous fixes and cleanup: - Rename `get_user` to `username` and `get_authtok` to `authtok`. - Use pam_strerror for error messages. - Add library linkage to build.rs (it was missing???).
author Paul Fisher <paul@pfish.zone>
date Sat, 14 Jun 2025 09:30:16 -0400
parents 002adfb98c5c
children f3e260f9ddcb
comparison
equal deleted inserted replaced
89:dd3e9c4bcde3 90:f6186e41399b
20 /// struct MyPamModule; 20 /// struct MyPamModule;
21 /// pam_hooks!(MyPamModule); 21 /// pam_hooks!(MyPamModule);
22 /// 22 ///
23 /// impl<T: PamHandleModule> PamModule<T> for MyPamModule { 23 /// impl<T: PamHandleModule> PamModule<T> for MyPamModule {
24 /// fn authenticate(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> { 24 /// fn authenticate(handle: &mut T, args: Vec<&CStr>, flags: Flags) -> PamResult<()> {
25 /// let password = handle.get_authtok(Some("what's your password?"))?; 25 /// let password = handle.authtok(Some("what's your password?"))?;
26 /// let response = 26 /// let response =
27 /// format!("If you say your password is {password:?}, who am I to disagree?"); 27 /// format!("If you say your password is {password:?}, who am I to disagree?");
28 /// handle.info_msg(&response); 28 /// handle.info_msg(&response);
29 /// Ok(()) 29 /// Ok(())
30 /// } 30 /// }
31 /// 31 ///
32 /// 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<()> {
33 /// let username = handle.get_user(None)?; 33 /// let username = handle.username(None)?;
34 /// let response = format!("Hello {username}! I trust you unconditionally."); 34 /// let response = format!("Hello {username}! I trust you unconditionally.");
35 /// handle.info_msg(&response); 35 /// handle.info_msg(&response);
36 /// Ok(()) 36 /// Ok(())
37 /// } 37 /// }
38 /// } 38 /// }