Mercurial > crates > nonstick
diff libpam-sys/libpam-sys-consts/README.md @ 148:4b3a5095f68c
Move libpam-sys helpers into their own library.
- Renames libpam-sys-helpers to libpam-sys-consts.
- Moves libpam-sys-helpers::helpers into libpam-sys-helpers,
which moves them completely out of libpam-sys's dependency chain.
- Moves the aliases from libpam-sys into libpam-sys::aliases.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 07 Jul 2025 12:11:43 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpam-sys/libpam-sys-consts/README.md Mon Jul 07 12:11:43 2025 -0400 @@ -0,0 +1,60 @@ +# `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 + +By default, this crate automatically detects your libpam version. +Known implementations are listed in the `PamImpl` enum. + +You can override this **at build time** by setting the `LIBPAMSYS_IMPL` environment variable to one of those names. +For example, `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. \ No newline at end of file