Mercurial > crates > nonstick
comparison src/constants.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 | efe2f5f8b5b2 |
| children | e97534be35e3 |
comparison
equal
deleted
inserted
replaced
| 102:94eb11cb1798 | 103:dfcd96a74ac4 |
|---|---|
| 4 // between Linux-PAM and OpenPAM header files. | 4 // between Linux-PAM and OpenPAM header files. |
| 5 #![allow(clippy::unnecessary_cast)] | 5 #![allow(clippy::unnecessary_cast)] |
| 6 | 6 |
| 7 #[cfg(feature = "link")] | 7 #[cfg(feature = "link")] |
| 8 use crate::libpam::pam_ffi; | 8 use crate::libpam::pam_ffi; |
| 9 use crate::{_linklist, _man7, _manbsd, _xsso}; | |
| 9 use bitflags::bitflags; | 10 use bitflags::bitflags; |
| 10 use libc::c_int; | 11 use libc::c_int; |
| 11 use num_enum::{IntoPrimitive, TryFromPrimitive}; | 12 use num_enum::{IntoPrimitive, TryFromPrimitive}; |
| 12 use std::error::Error; | 13 use std::error::Error; |
| 13 use std::ffi::c_uint; | 14 use std::ffi::c_uint; |
| 143 /// This flag is only used by `change_authtok`. | 144 /// This flag is only used by `change_authtok`. |
| 144 const UPDATE_AUTHTOK = pam_ffi::PAM_UPDATE_AUTHTOK as u32; | 145 const UPDATE_AUTHTOK = pam_ffi::PAM_UPDATE_AUTHTOK as u32; |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 | 148 |
| 148 /// The Linux-PAM error return values. Success is an Ok [Result]. | 149 /// The PAM error return codes. |
| 149 /// | 150 /// |
| 150 /// Most abbreviations (except `AuthTok` and `Max`) are now full words. | 151 /// These are returned by most PAM functions if an error of some kind occurs. |
| 151 /// For more detailed information, see | 152 /// |
| 152 /// `/usr/include/security/_pam_types.h`. | 153 /// Instead of being an error code, success is represented by an Ok [`Result`]. |
| 154 /// | |
| 155 /// # References | |
| 156 /// | |
| 157 #[doc = _linklist!(pam: man7, manbsd)] | |
| 158 /// - [X/SSO error code specification][xsso] | |
| 159 /// | |
| 160 #[doc = _man7!(3 pam "RETURN_VALUES")] | |
| 161 #[doc = _manbsd!(3 pam "RETURN%20VALUES")] | |
| 162 #[doc = _xsso!("chap5.htm#tagcjh_06_02")] | |
| 153 #[allow(non_camel_case_types, dead_code)] | 163 #[allow(non_camel_case_types, dead_code)] |
| 154 #[derive(Copy, Clone, Debug, PartialEq, TryFromPrimitive, IntoPrimitive)] | 164 #[derive(Copy, Clone, Debug, PartialEq, TryFromPrimitive, IntoPrimitive)] |
| 155 #[non_exhaustive] // C might give us anything! | 165 #[non_exhaustive] // C might give us anything! |
| 156 #[repr(u32)] | 166 #[repr(u32)] |
| 157 pub enum ErrorCode { | 167 pub enum ErrorCode { |
| 226 fn fmt_internal(self, f: &mut Formatter<'_>) -> fmt::Result { | 236 fn fmt_internal(self, f: &mut Formatter<'_>) -> fmt::Result { |
| 227 write!(f, "PAM error: {self:?} ({n})", n = self as c_uint) | 237 write!(f, "PAM error: {self:?} ({n})", n = self as c_uint) |
| 228 } | 238 } |
| 229 } | 239 } |
| 230 | 240 |
| 231 /// Returned when text that should not have any `\0` bytes in it does. | |
| 232 /// Analogous to [`std::ffi::NulError`], but the data it was created from | |
| 233 /// is borrowed. | |
| 234 #[cfg(test)] | 241 #[cfg(test)] |
| 235 mod tests { | 242 mod tests { |
| 236 use super::*; | 243 use super::*; |
| 237 | 244 |
| 238 #[test] | 245 #[test] |
