view libpam-sys/src/lib.rs @ 112:82995b4dccee

Finish renaming "illumos" to "sun".
author Paul Fisher <paul@pfish.zone>
date Sun, 29 Jun 2025 02:21:26 -0400
parents 2346fd501b7a
children
line wrap: on
line source

#![doc = include_str!("../README.md")]
//!
//! ## PAM implementation
//!
#![doc = concat!("This documentation was built for the **", __pam_impl_name__!(), "** implementation.")]

use libpam_sys_impls::{__pam_impl_enum__, __pam_impl_name__};

mod constants;
pub mod helpers;
mod structs;

/// A `cfg`-like attribute macro for code specific to one PAM implementation.
///
/// Different versions of PAM export different functions and have some
/// meaningful internal implementation differences, like the way `pam_conv`
/// is handled (see [the Linux-PAM man page for details][man7]).
///
/// This macro will let you figure out which PAM you're compiling
/// (and eventually running) against so you can make those critical changes.
///
/// The implementation names are the same as those in the [`PamImpl`] enum.
///
/// ```
/// use libpam_sys::cfg_pam_impl;
///
/// #[cfg_pam_impl("Sun")]
/// fn do_something() { /* Illumos/Solaris-only code */ }
///
/// #[cfg_pam_impl(not("Sun"))]
/// fn do_something() { /* non-Illumos code */ }
///
/// #[cfg_pam_impl(any("LinuxPam", "MinimalOpenPam"))]
/// fn do_something_else() { /* Linux-PAM or minimal OpenPAM */ }
///
/// #[cfg_pam_impl(not(any("Sun", "OpenPam")))]
/// fn do_a_third_thing() { /* Neither Sun nor OpenPAM */ }
///
/// #[cfg_pam_impl(any())]
/// fn this_will_never_build() { /* why would you do this? */ }
///
/// #[cfg_pam_impl(not(any()))]
/// fn this_will_always_build() { /* I, sure, whatever, you do you. */ }
/// ```
///
/// [man7]: https://man7.org/linux/man-pages/man3/pam_conv.3.html
#[doc(inline)]
pub use libpam_sys_impls::cfg_pam_impl;

// Looking for the actual code defining this enum?
// It's in the build.rs file for libpam_sys_impls.
__pam_impl_enum__!(#[non_exhaustive]);

#[doc(inline)]
pub use crate::{constants::*, structs::*};