Mercurial > crates > nonstick
comparison src/libpam/handle.rs @ 103:dfcd96a74ac4
write a truly prodigious amount of documentation
adds a bunch of links to the OpenPAM man pages and the XSSO spec
as well as just a bunch of prose and stuff.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Wed, 25 Jun 2025 00:59:24 -0400 |
| parents | 94eb11cb1798 |
| children | 13b4d2a19674 |
comparison
equal
deleted
inserted
replaced
| 102:94eb11cb1798 | 103:dfcd96a74ac4 |
|---|---|
| 5 use crate::handle::PamShared; | 5 use crate::handle::PamShared; |
| 6 use crate::libpam::environ::{LibPamEnviron, LibPamEnvironMut}; | 6 use crate::libpam::environ::{LibPamEnviron, LibPamEnvironMut}; |
| 7 pub use crate::libpam::pam_ffi::LibPamHandle; | 7 pub use crate::libpam::pam_ffi::LibPamHandle; |
| 8 use crate::libpam::{memory, pam_ffi}; | 8 use crate::libpam::{memory, pam_ffi}; |
| 9 use crate::logging::Level; | 9 use crate::logging::Level; |
| 10 use crate::{Conversation, EnvironMap, Flags, PamHandleApplication, PamHandleModule}; | 10 use crate::{ |
| 11 Conversation, EnvironMap, Flags, PamHandleApplication, PamHandleModule, _guide, _linklist, | |
| 12 _stdlinks, | |
| 13 }; | |
| 11 use num_enum::{IntoPrimitive, TryFromPrimitive}; | 14 use num_enum::{IntoPrimitive, TryFromPrimitive}; |
| 12 use std::cell::Cell; | 15 use std::cell::Cell; |
| 13 use std::ffi::{c_char, c_int, CString}; | 16 use std::ffi::{c_char, c_int, CString}; |
| 14 use std::ops::{Deref, DerefMut}; | 17 use std::ops::{Deref, DerefMut}; |
| 15 use std::ptr; | 18 use std::ptr; |
| 76 /// | 79 /// |
| 77 /// The service name is what controls the steps and checks PAM goes through | 80 /// The service name is what controls the steps and checks PAM goes through |
| 78 /// when authenticating a user. This corresponds to the configuration file | 81 /// when authenticating a user. This corresponds to the configuration file |
| 79 /// named <code>/etc/pam.d/<var>service_name</var></code>. | 82 /// named <code>/etc/pam.d/<var>service_name</var></code>. |
| 80 /// | 83 /// |
| 81 /// For more information, see the [`pam_start` man page][man], or | 84 /// # References |
| 82 /// [`pam_start` in the PAM Application Developers' Guide][adg]. | 85 #[doc = _linklist!(pam_start: adg, _std)] |
| 83 /// | 86 /// |
| 84 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_start.3.html | 87 #[doc = _stdlinks!(3 pam_start)] |
| 85 /// [adg]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/adg-interface-by-app-expected.html#adg-pam_start | 88 #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_start")] |
| 86 pub fn build_with_service(service_name: String) -> HandleBuilder { | 89 pub fn build_with_service(service_name: String) -> HandleBuilder { |
| 87 HandleBuilder { service_name, username: None } | 90 HandleBuilder { |
| 91 service_name, | |
| 92 username: None, | |
| 93 } | |
| 88 } | 94 } |
| 89 | 95 |
| 90 fn start( | 96 fn start( |
| 91 service_name: String, | 97 service_name: String, |
| 92 username: Option<String>, | 98 username: Option<String>, |
| 150 // pam_getenvlist - shared | 156 // pam_getenvlist - shared |
| 151 | 157 |
| 152 impl Drop for OwnedLibPamHandle<'_> { | 158 impl Drop for OwnedLibPamHandle<'_> { |
| 153 /// Closes the PAM session on an owned PAM handle. | 159 /// Closes the PAM session on an owned PAM handle. |
| 154 /// | 160 /// |
| 155 /// See the [`pam_end` manual page][man] for more information. | 161 /// This internally calls `pam_end` with the appropriate error code. |
| 156 /// | 162 /// |
| 157 /// [man]: https://www.man7.org/linux/man-pages/man3/pam_end.3.html | 163 /// # References |
| 164 #[doc = _linklist!(pam_end: adg, _std)] | |
| 165 /// | |
| 166 #[doc = _guide!(adg: "adg-interface-by-app-expected.html#adg-pam_end")] | |
| 167 #[doc = _stdlinks!(3 pam_end)] | |
| 158 fn drop(&mut self) { | 168 fn drop(&mut self) { |
| 159 unsafe { | 169 unsafe { |
| 160 pam_ffi::pam_end( | 170 pam_ffi::pam_end( |
| 161 self.handle.0, | 171 self.handle.0, |
| 162 ErrorCode::result_to_c(self.last_return.get()), | 172 ErrorCode::result_to_c(self.last_return.get()), |
