comparison src/handle.rs @ 166:2f5913131295

Separate flag/action flags into flags and action. This also individualizes the type of flag for each PAM function, so that you can only call a function with the right flags and values.
author Paul Fisher <paul@pfish.zone>
date Tue, 15 Jul 2025 00:32:24 -0400
parents 634cd5f2ac8b
children 77470e45e397
comparison
equal deleted inserted replaced
165:c4b1e280463c 166:2f5913131295
1 //! The wrapper types and traits for handles into the PAM library. 1 //! The wrapper types and traits for handles into the PAM library.
2 2
3 use crate::_doc::{guide, linklist, man7, manbsd, stdlinks}; 3 use crate::_doc::{guide, linklist, man7, manbsd, stdlinks};
4 use crate::constants::{Flags, Result}; 4 use crate::constants::{AuthnFlags, AuthtokFlags, Result};
5 use crate::conv::Conversation; 5 use crate::conv::Conversation;
6 use crate::environ::{EnvironMap, EnvironMapMut}; 6 use crate::environ::{EnvironMap, EnvironMapMut};
7 use crate::items::{getter, Items, ItemsMut}; 7 use crate::items::{getter, Items, ItemsMut};
8 use crate::logging::Logger; 8 use crate::logging::Logger;
9 use std::ffi::{OsStr, OsString}; 9 use std::ffi::{OsStr, OsString};
117 /// # References 117 /// # References
118 #[doc = linklist!(pam_authenticate: adg, _std)] 118 #[doc = linklist!(pam_authenticate: adg, _std)]
119 /// 119 ///
120 #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_authenticate")] 120 #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_authenticate")]
121 #[doc = stdlinks!(3 pam_authenticate)] 121 #[doc = stdlinks!(3 pam_authenticate)]
122 fn authenticate(&mut self, flags: Flags) -> Result<()>; 122 fn authenticate(&mut self, flags: AuthnFlags) -> Result<()>;
123 123
124 /// Verifies the validity of the user's account (and other stuff). 124 /// Verifies the validity of the user's account (and other stuff).
125 /// 125 ///
126 /// After [authentication](Self::authenticate), an application should call 126 /// After [authentication](Self::authenticate), an application should call
127 /// this to ensure that the user's account is still valid. This may check 127 /// this to ensure that the user's account is still valid. This may check
130 /// # References 130 /// # References
131 #[doc = linklist!(pam_acct_mgmt: adg, _std)] 131 #[doc = linklist!(pam_acct_mgmt: adg, _std)]
132 /// 132 ///
133 #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_acct_mgmt")] 133 #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_acct_mgmt")]
134 #[doc = stdlinks!(3 pam_acct_mgmt)] 134 #[doc = stdlinks!(3 pam_acct_mgmt)]
135 fn account_management(&mut self, flags: Flags) -> Result<()>; 135 fn account_management(&mut self, flags: AuthnFlags) -> Result<()>;
136 136
137 /// Changes the authentication token. 137 /// Changes the authentication token.
138 /// 138 ///
139 /// # References 139 /// # References
140 #[doc = linklist!(pam_chauthtok: adg, _std)] 140 #[doc = linklist!(pam_chauthtok: adg, _std)]
141 /// 141 ///
142 #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_chauthtok")] 142 #[doc = guide!(adg: "adg-interface-by-app-expected.html#adg-pam_chauthtok")]
143 #[doc = stdlinks!(3 pam_chauthtok)] 143 #[doc = stdlinks!(3 pam_chauthtok)]
144 fn change_authtok(&mut self, flags: Flags) -> Result<()>; 144 fn change_authtok(&mut self, flags: AuthtokFlags) -> Result<()>;
145 } 145 }
146 146
147 /// Functionality of a PAM handle that can be expected by a PAM module. 147 /// Functionality of a PAM handle that can be expected by a PAM module.
148 /// 148 ///
149 /// If you are not writing a PAM module (e.g., you are writing an application), 149 /// If you are not writing a PAM module (e.g., you are writing an application),