Mercurial > crates > nonstick
comparison libpam-sys/src/constants.rs @ 134:6c1e1bdb4164
Use standard #[cfg] directives rather than custom proc macros.
Instead of having to do a bunch of custom parsing and other logic
that tools often choke on, this change introduces an easy way
to depend upon custom #[cfg]s provided by the libpam-sys crate.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Thu, 03 Jul 2025 11:03:36 -0400 |
| parents | 32b2a545ca3e |
| children |
comparison
equal
deleted
inserted
replaced
| 133:32b2a545ca3e | 134:6c1e1bdb4164 |
|---|---|
| 1 //! All the constants. | 1 //! All the constants. |
| 2 //! | 2 //! |
| 3 //! These constants are tested on a per-platform basis by `libpam-sys-test`'s | 3 //! These constants are tested on a per-platform basis by `libpam-sys-test`'s |
| 4 //! `test_constants.rs`. | 4 //! `test_constants.rs`. |
| 5 | |
| 6 use libpam_sys_impls::cfg_pam_impl; | |
| 7 | 5 |
| 8 /// Macro to make defining a bunch of constants way easier. | 6 /// Macro to make defining a bunch of constants way easier. |
| 9 macro_rules! define { | 7 macro_rules! define { |
| 10 ($(#[$attr:meta])* $($name:ident = $value:expr);+$(;)?) => { | 8 ($(#[$attr:meta])* $($name:ident = $value:expr);+$(;)?) => { |
| 11 define!( | 9 define!( |
| 68 PAM_MAX_NUM_MSG = 32; | 66 PAM_MAX_NUM_MSG = 32; |
| 69 PAM_MAX_MSG_SIZE = 512; | 67 PAM_MAX_MSG_SIZE = 512; |
| 70 PAM_MAX_RESP_SIZE = 512; | 68 PAM_MAX_RESP_SIZE = 512; |
| 71 ); | 69 ); |
| 72 | 70 |
| 73 #[cfg_pam_impl("LinuxPam")] | 71 #[cfg(pam_impl = "LinuxPam")] |
| 74 pub use linux_pam::*; | 72 pub use linux_pam::*; |
| 75 #[cfg_pam_impl("LinuxPam")] | 73 #[cfg(pam_impl = "LinuxPam")] |
| 76 mod linux_pam { | 74 mod linux_pam { |
| 77 c_enum!( | 75 c_enum!( |
| 78 /// An error return code. | 76 /// An error return code. |
| 79 PAM_OPEN_ERR = 1, | 77 PAM_OPEN_ERR = 1, |
| 80 PAM_SYMBOL_ERR, | 78 PAM_SYMBOL_ERR, |
| 145 ); | 143 ); |
| 146 | 144 |
| 147 pub const PAM_MODUTIL_NGROUPS: i32 = 64; | 145 pub const PAM_MODUTIL_NGROUPS: i32 = 64; |
| 148 } | 146 } |
| 149 | 147 |
| 150 #[cfg_pam_impl(any("OpenPam", "Sun", "XSso"))] | 148 #[cfg(any(pam_impl = "OpenPam", pam_impl = "Sun", pam_impl = "XSso"))] |
| 151 pub use xsso_shared::*; | 149 pub use xsso_shared::*; |
| 152 #[cfg_pam_impl(any("OpenPam", "Sun", "XSso"))] | 150 #[cfg(any(pam_impl = "OpenPam", pam_impl = "Sun", pam_impl = "XSso"))] |
| 153 mod xsso_shared { | 151 mod xsso_shared { |
| 154 c_enum!( | 152 c_enum!( |
| 155 /// An error return code. | 153 /// An error return code. |
| 156 PAM_OPEN_ERR = 1, | 154 PAM_OPEN_ERR = 1, |
| 157 PAM_SYMBOL_ERR, | 155 PAM_SYMBOL_ERR, |
| 204 PAM_UPDATE_AUTHTOK = 0b0010; | 202 PAM_UPDATE_AUTHTOK = 0b0010; |
| 205 PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; | 203 PAM_CHANGE_EXPIRED_AUTHTOK = 0b0100; |
| 206 ); | 204 ); |
| 207 } | 205 } |
| 208 | 206 |
| 209 #[cfg_pam_impl("OpenPam")] | 207 #[cfg(pam_impl = "OpenPam")] |
| 210 pub use openpam::*; | 208 pub use openpam::*; |
| 211 #[cfg_pam_impl("OpenPam")] | 209 #[cfg(pam_impl = "OpenPam")] |
| 212 mod openpam { | 210 mod openpam { |
| 213 c_enum!( | 211 c_enum!( |
| 214 /// An error return code. | 212 /// An error return code. |
| 215 PAM_MODULE_UNKNOWN = 28, | 213 PAM_MODULE_UNKNOWN = 28, |
| 216 PAM_DOMAIN_UNKNOWN, | 214 PAM_DOMAIN_UNKNOWN, |
| 264 /// The number of PAM primitives. | 262 /// The number of PAM primitives. |
| 265 pub const PAM_NUM_PRIMITIVES: i32 = 6; | 263 pub const PAM_NUM_PRIMITIVES: i32 = 6; |
| 266 } | 264 } |
| 267 | 265 |
| 268 /// Constants exclusive to Illumos. | 266 /// Constants exclusive to Illumos. |
| 269 #[cfg_pam_impl("Sun")] | 267 #[cfg(pam_impl = "Sun")] |
| 270 pub use sun::*; | 268 pub use sun::*; |
| 271 #[cfg_pam_impl("Sun")] | 269 #[cfg(pam_impl = "Sun")] |
| 272 mod sun { | 270 mod sun { |
| 273 /// The total number of PAM error codes. | 271 /// The total number of PAM error codes. |
| 274 pub const PAM_TOTAL_ERRNUM: i32 = 28; | 272 pub const PAM_TOTAL_ERRNUM: i32 = 28; |
| 275 | 273 |
| 276 c_enum!( | 274 c_enum!( |
