comparison src/module.rs @ 146:1bc52025156b

Split PAM items into their own separate struct. To trim down the number of methods on `PamShared`, this puts all the Items into their own struct(s). This also makes the split between authtok/authtok_item easier to understand.
author Paul Fisher <paul@pfish.zone>
date Sun, 06 Jul 2025 19:10:26 -0400
parents f6186e41399b
children
comparison
equal deleted inserted replaced
145:8f964b701652 146:1bc52025156b
2 2
3 // Temporarily allowed until we get the actual conversation functions hooked up. 3 // Temporarily allowed until we get the actual conversation functions hooked up.
4 #![allow(dead_code)] 4 #![allow(dead_code)]
5 5
6 use crate::constants::{ErrorCode, Flags, Result}; 6 use crate::constants::{ErrorCode, Flags, Result};
7 use crate::handle::PamHandleModule; 7 use crate::handle::ModuleClient;
8 use std::ffi::CStr; 8 use std::ffi::CStr;
9 9
10 /// A trait for a PAM module to implement. 10 /// A trait for a PAM module to implement.
11 /// 11 ///
12 /// The default implementations of all these hooks tell PAM to ignore them 12 /// The default implementations of all these hooks tell PAM to ignore them
19 /// and the [PAM Module Writer’s Guide][mwg]. 19 /// and the [PAM Module Writer’s Guide][mwg].
20 /// 20 ///
21 /// [manpage]: https://www.man7.org/linux/man-pages/man3/pam.3.html 21 /// [manpage]: https://www.man7.org/linux/man-pages/man3/pam.3.html
22 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/Linux-PAM_MWG.html 22 /// [mwg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/Linux-PAM_MWG.html
23 #[allow(unused_variables)] 23 #[allow(unused_variables)]
24 pub trait PamModule<T: PamHandleModule> { 24 pub trait PamModule<T: ModuleClient> {
25 // Functions for auth modules. 25 // Functions for auth modules.
26 26
27 /// Authenticate the user. 27 /// Authenticate the user.
28 /// 28 ///
29 /// This is probably the first thing you want to implement. 29 /// This is probably the first thing you want to implement.
30 /// In most cases, you will want to get the user and password, 30 /// In most cases, you will want to get the user and password,
31 /// using [`PamShared::username`](crate::PamShared::username) 31 /// using [`PamShared::username`](crate::PamShared::username)
32 /// and [`PamHandleModule::authtok`], 32 /// and [`ModuleClient::authtok`],
33 /// and verify them against something. 33 /// and verify them against something.
34 /// 34 ///
35 /// See [the Module Writer's Guide entry for `pam_sm_authenticate`][mwg] 35 /// See [the Module Writer's Guide entry for `pam_sm_authenticate`][mwg]
36 /// for more information. 36 /// for more information.
37 /// 37 ///