Mercurial > crates > nonstick
view libpam-sys/libpam-sys-consts/README.md @ 158:d5b7b28d754e
Add `__TARGET_DEFAULT__` PamImpl and set up for docsrs build.
Also fixes some formatting stuff.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 12 Jul 2025 17:17:37 -0400 |
parents | 4b3a5095f68c |
children | 09dff285ff5e |
line wrap: on
line source
# `libpam-sys-consts`: Constants for LibPAM This crate does two primary things: - Detects which implementation of LibPAM the current machine uses (as part of the build script), and exports that information to downstream crates. - Exports the constants specific to that version of LibPAM. These are located in the `constants` module. ## Handling different PAM implmementations Different PAM implementations have different constants and some different behaviors. If you need to change your library's behavior based on PAM implementation, there are a few ways to do so. ### Constants The current PAM implementation is available in `PamImpl::CURRENT`. This is present as a string literal macro in `pam_impl_name!`. ### Conditional compilation This package provides custom `#[cfg]`s to compile based on the current PAM implementation. First, **enable custom `#[cfg]`s in your build.rs**: ```rust // build.rs use libpam_sys_helpers::pam_impl; fn main() { pam_impl::enable_pam_impl_cfg(); // everything else you do at build time } ``` This will then allow you to use the `pam_impl` configuration variable at compile time: ```rust #[cfg(pam_impl = "LinuxPam")] fn handle_pam() { // do things in a Linux-PAM specific way } #[cfg(not(pam_impl = "LinuxPam"))] fn handle_pam() { // do things in another, more different way } ``` ## Configuration Known implementations of PAM are listed in the `PamImpl` enum, and your currently installed implementation is automatically detected. If you need to configure this, you can override it **at build time** with the `LIBPAMSYS_IMPL` environment variable: - Unset or `` (the default): Probe the currently installed LibPAM to figure out which implementation it is. If LibPAM is not present, this will fall back to `__TARGET_DEFAULT__`. - `__TARGET_DEFAULT__`: Select the version of LibPAM most likely to be installed on the current OS. This is a useful setting for cross-compiling. - The name of a `PamEnum` entry: The named PAM implementation. For instance, `LIBPAMSYS_IMPL=OpenPam cargo build` will build this library for OpenPAM. ## MSRV This library supports **Rust 1.75**, as the version currently (July 2025) available in Debian Trixie and Ubuntu 24.04 LTS.