Mercurial > crates > nonstick
comparison libpam-sys/src/lib.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 | 39760dfc9b3b |
comparison
equal
deleted
inserted
replaced
| 109:bb465393621f | 110:2346fd501b7a |
|---|---|
| 1 #![doc = include_str!("../README.md")] | 1 #![doc = include_str!("../README.md")] |
| 2 //! | 2 //! |
| 3 //! ## PAM implementation | 3 //! ## PAM implementation |
| 4 //! | 4 //! |
| 5 #![doc = concat!("This documentation was built for the **", pam_impl_name!(), "** implementation.")] | 5 #![doc = concat!("This documentation was built for the **", __pam_impl_name__!(), "** implementation.")] |
| 6 | 6 |
| 7 #[doc(inline)] | 7 use libpam_sys_impls::{__pam_impl_enum__, __pam_impl_name__}; |
| 8 pub use libpam_sys_impls::cfg_pam_impl; | 8 |
| 9 use libpam_sys_impls::{pam_impl_enum, pam_impl_name}; | |
| 10 mod constants; | 9 mod constants; |
| 11 | |
| 12 pam_impl_enum!(); | |
| 13 | |
| 14 pub mod helpers; | 10 pub mod helpers; |
| 15 mod structs; | 11 mod structs; |
| 16 | 12 |
| 13 /// A `cfg`-like attribute macro for code specific to one PAM implementation. | |
| 14 /// | |
| 15 /// Different versions of PAM export different functions and have some | |
| 16 /// meaningful internal implementation differences, like the way `pam_conv` | |
| 17 /// is handled (see [the Linux-PAM man page for details][man7]). | |
| 18 /// | |
| 19 /// This macro will let you figure out which PAM you're compiling | |
| 20 /// (and eventually running) against so you can make those critical changes. | |
| 21 /// | |
| 22 /// The implementation names are the same as those in the [`PamImpl`] enum. | |
| 23 /// | |
| 24 /// ``` | |
| 25 /// use libpam_sys::cfg_pam_impl; | |
| 26 /// | |
| 27 /// #[cfg_pam_impl("Sun")] | |
| 28 /// fn do_something() { /* Illumos/Solaris-only code */ } | |
| 29 /// | |
| 30 /// #[cfg_pam_impl(not("Sun"))] | |
| 31 /// fn do_something() { /* non-Illumos code */ } | |
| 32 /// | |
| 33 /// #[cfg_pam_impl(any("LinuxPam", "MinimalOpenPam"))] | |
| 34 /// fn do_something_else() { /* Linux-PAM or minimal OpenPAM */ } | |
| 35 /// | |
| 36 /// #[cfg_pam_impl(not(any("Sun", "OpenPam")))] | |
| 37 /// fn do_a_third_thing() { /* Neither Sun nor OpenPAM */ } | |
| 38 /// | |
| 39 /// #[cfg_pam_impl(any())] | |
| 40 /// fn this_will_never_build() { /* why would you do this? */ } | |
| 41 /// | |
| 42 /// #[cfg_pam_impl(not(any()))] | |
| 43 /// fn this_will_always_build() { /* I, sure, whatever, you do you. */ } | |
| 44 /// ``` | |
| 45 /// | |
| 46 /// [man7]: https://man7.org/linux/man-pages/man3/pam_conv.3.html | |
| 47 #[doc(inline)] | |
| 48 pub use libpam_sys_impls::cfg_pam_impl; | |
| 49 | |
| 50 // Looking for the actual code defining this enum? | |
| 51 // It's in the build.rs file for libpam_sys_impls. | |
| 52 __pam_impl_enum__!(#[non_exhaustive]); | |
| 53 | |
| 17 #[doc(inline)] | 54 #[doc(inline)] |
| 18 pub use crate::{constants::*, structs::*}; | 55 pub use crate::{constants::*, structs::*}; |
