changeset 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
files libpam-sys/README.md libpam-sys/libpam-sys-consts/README.md libpam-sys/libpam-sys-consts/src/lib.rs
diffstat 3 files changed, 40 insertions(+), 1 deletions(-) [+]
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]).
--- a/libpam-sys/libpam-sys-consts/README.md	Sun Jul 13 15:38:00 2025 -0400
+++ b/libpam-sys/libpam-sys-consts/README.md	Sun Jul 13 16:06:51 2025 -0400
@@ -24,7 +24,7 @@
 
 ```rust
 // build.rs
-use libpam_sys_helpers::pam_impl;
+use libpam_sys_consts::pam_impl;
 
 fn main() {
     pam_impl::enable_pam_impl_cfg();
--- a/libpam-sys/libpam-sys-consts/src/lib.rs	Sun Jul 13 15:38:00 2025 -0400
+++ b/libpam-sys/libpam-sys-consts/src/lib.rs	Sun Jul 13 16:06:51 2025 -0400
@@ -15,6 +15,18 @@
 /// Use [`enable_pam_impl_cfg`] in your `build.rs` to generate custom `#[cfg]`s
 /// for conditional compilation based on PAM implementation.
 ///
+/// ```
+/// // Your package's build.rs:
+///
+/// use libpam_sys_consts::pam_impl;
+/// // also available at libpam_sys::pam_impl
+///
+/// fn main() {
+///     pam_impl::enable_pam_impl_cfg();
+///     // whatever else you do in your build script.
+/// }
+/// ```
+///
 /// This will set the current `pam_impl` as well as registering all known
 /// PAM implementations with `rustc-check-cfg` to get cfg-checking.
 ///