diff 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
line wrap: on
line diff
--- a/libpam-sys/README.md	Sun Jul 13 15:38:00 2025 -0400
+++ b/libpam-sys/README.md	Sun Jul 13 16:06:51 2025 -0400
@@ -16,6 +16,33 @@
 Normally, this crate exports all functionality available in the selected PAM library.
 `XSso` exports only the subset of the [X/SSO specification][xsso] supported by both OpenPAM and Sun PAM.
 
+### Changing behavior based on PAM implementation
+
+Downstream crates can detect the current PAM implementation using custom `#[cfg]`s:
+
+```rust
+// Your package's build.rs:
+use libpam_sys::pam_impl;
+
+fn main() {
+  pam_impl::enable_pam_impl_cfg();
+  
+  // the rest of your build script...
+}
+```
+
+This will enable the use of `#[cfg]`s that look like this:
+
+```rust
+#[cfg(pam_impl = "Sun")]
+fn some_func() { /* Sun-specific implementation */ }
+
+#[cfg(any(pam_impl = "LinuxPam", pam_impl = "OpenPam"))]
+fn some_func() { /* Linux-PAM / OpenPAM implementation */ }
+```
+
+Further documentation on this is available in `libpam-sys-consts`.
+
 ## Testing
 
 Tests are mostly run through `libpam-sys-test`, which lives in the crate's workspace in its repository (along with [nonstick]).