comparison libpam-sys/README.md @ 161:e9354e655f38

Improve PAM detection docs.
author Paul Fisher <paul@pfish.zone>
date Sun, 13 Jul 2025 16:06:51 -0400
parents 09dff285ff5e
children 180237d0b498
comparison
equal deleted inserted replaced
160:09dff285ff5e 161:e9354e655f38
13 You can also explicitly specify the PAM implementation you want (if not detected correctly) by setting the `LIBPAMSYS_IMPL` environment variable **at build time**. 13 You can also explicitly specify the PAM implementation you want (if not detected correctly) by setting the `LIBPAMSYS_IMPL` environment variable **at build time**.
14 All build-time configuration is performed by the build script of the [`libpam-sys-consts` crate](https://crates.io/crates/libpam-sys-consts). 14 All build-time configuration is performed by the build script of the [`libpam-sys-consts` crate](https://crates.io/crates/libpam-sys-consts).
15 15
16 Normally, this crate exports all functionality available in the selected PAM library. 16 Normally, this crate exports all functionality available in the selected PAM library.
17 `XSso` exports only the subset of the [X/SSO specification][xsso] supported by both OpenPAM and Sun PAM. 17 `XSso` exports only the subset of the [X/SSO specification][xsso] supported by both OpenPAM and Sun PAM.
18
19 ### Changing behavior based on PAM implementation
20
21 Downstream crates can detect the current PAM implementation using custom `#[cfg]`s:
22
23 ```rust
24 // Your package's build.rs:
25 use libpam_sys::pam_impl;
26
27 fn main() {
28 pam_impl::enable_pam_impl_cfg();
29
30 // the rest of your build script...
31 }
32 ```
33
34 This will enable the use of `#[cfg]`s that look like this:
35
36 ```rust
37 #[cfg(pam_impl = "Sun")]
38 fn some_func() { /* Sun-specific implementation */ }
39
40 #[cfg(any(pam_impl = "LinuxPam", pam_impl = "OpenPam"))]
41 fn some_func() { /* Linux-PAM / OpenPAM implementation */ }
42 ```
43
44 Further documentation on this is available in `libpam-sys-consts`.
18 45
19 ## Testing 46 ## Testing
20 47
21 Tests are mostly run through `libpam-sys-test`, which lives in the crate's workspace in its repository (along with [nonstick]). 48 Tests are mostly run through `libpam-sys-test`, which lives in the crate's workspace in its repository (along with [nonstick]).
22 49