Mercurial > crates > nonstick
comparison libpam-sys/src/constants.rs @ 110:2346fd501b7a
Add tests for constants and do other macro niceties.
- Adds tests for all the constants. Pretty sweet.
- Moves documentation for cfg-pam-impl macro to `libpam-sys`.
- Renames `Illumos` to `Sun`.
- other stuff
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Sun, 29 Jun 2025 02:15:46 -0400 |
| parents | bb465393621f |
| children | 82995b4dccee |
comparison
equal
deleted
inserted
replaced
| 109:bb465393621f | 110:2346fd501b7a |
|---|---|
| 1 //! All the constants. | 1 //! All the constants. |
| 2 //! | |
| 3 //! These constants are tested on a per-platform basis by `libpam-sys-test`'s | |
| 4 //! `test_constants.rs`. | |
| 2 | 5 |
| 3 use libpam_sys_impls::cfg_pam_impl; | 6 use libpam_sys_impls::cfg_pam_impl; |
| 4 | 7 |
| 5 /// Macro to make defining a bunch of constants way easier. | 8 /// Macro to make defining a bunch of constants way easier. |
| 6 macro_rules! define { | 9 macro_rules! define { |
| 69 PAM_CRED_EXPIRED = 16; | 72 PAM_CRED_EXPIRED = 16; |
| 70 PAM_CRED_ERR = 17; | 73 PAM_CRED_ERR = 17; |
| 71 PAM_NO_MODULE_DATA = 18; | 74 PAM_NO_MODULE_DATA = 18; |
| 72 PAM_CONV_ERR = 19; | 75 PAM_CONV_ERR = 19; |
| 73 PAM_AUTHTOK_ERR = 20; | 76 PAM_AUTHTOK_ERR = 20; |
| 77 PAM_AUTHTOK_RECOVER_ERR = 21; | |
| 74 PAM_AUTHTOK_RECOVERY_ERR = 21; | 78 PAM_AUTHTOK_RECOVERY_ERR = 21; |
| 75 PAM_AUTHTOK_LOCK_BUSY = 22; | 79 PAM_AUTHTOK_LOCK_BUSY = 22; |
| 76 PAM_AUTHTOK_DISABLE_AGING = 23; | 80 PAM_AUTHTOK_DISABLE_AGING = 23; |
| 77 PAM_TRY_AGAIN = 24; | 81 PAM_TRY_AGAIN = 24; |
| 78 PAM_IGNORE = 25; | 82 PAM_IGNORE = 25; |
| 104 define!( | 108 define!( |
| 105 PAM_USER_PROMPT = 9; | 109 PAM_USER_PROMPT = 9; |
| 106 PAM_FAIL_DELAY = 10; | 110 PAM_FAIL_DELAY = 10; |
| 107 PAM_XDISPLAY = 11; | 111 PAM_XDISPLAY = 11; |
| 108 PAM_XAUTHDATA = 12; | 112 PAM_XAUTHDATA = 12; |
| 109 PAM_AUTHTOKTYPE = 13; | 113 PAM_AUTHTOK_TYPE = 13; |
| 110 ); | 114 ); |
| 111 | 115 |
| 112 /// To suppress messages in the item cleanup function. | 116 /// To suppress messages in the item cleanup function. |
| 113 pub const PAM_DATA_SILENT: u32 = 0x40000000; | 117 pub const PAM_DATA_SILENT: u32 = 0x40000000; |
| 114 | 118 |
| 182 PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; | 186 PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; |
| 183 ); | 187 ); |
| 184 } | 188 } |
| 185 | 189 |
| 186 /// Constants exclusive to Illumos. | 190 /// Constants exclusive to Illumos. |
| 187 #[cfg_pam_impl("Illumos")] | 191 #[cfg_pam_impl("Sun")] |
| 188 pub use illumos::*; | 192 pub use sun::*; |
| 189 #[cfg_pam_impl("Illumos")] | 193 #[cfg_pam_impl("Sun")] |
| 190 mod illumos { | 194 mod sun { |
| 191 /// The total number of PAM error codes. | 195 /// The total number of PAM error codes. |
| 192 pub const PAM_TOTAL_ERRNUM: u32 = 28; | 196 pub const PAM_TOTAL_ERRNUM: u32 = 28; |
| 193 | 197 |
| 194 define!( | 198 define!( |
| 195 /// An item type. | 199 /// An item type. |
| 225 ); | 229 ); |
| 226 /// The total number of PAM items. | 230 /// The total number of PAM items. |
| 227 pub const PAM_NUM_ITEMS: u32 = 14; | 231 pub const PAM_NUM_ITEMS: u32 = 14; |
| 228 } | 232 } |
| 229 | 233 |
| 230 #[cfg(test)] | |
| 231 mod test {} |
