Crates.io | libpam-sys |
lib.rs | libpam-sys |
version | 0.2.0 |
created_at | 2025-07-31 19:25:14.680455+00 |
updated_at | 2025-08-03 05:09:02.131969+00 |
description | Low-level bindings for PAM (Pluggable Authentication Modules) |
homepage | |
repository | https://hg.pfish.zone/crates/nonstick/ |
max_upload_size | |
id | 1775555 |
size | 32,256 |
libpam-sys
: low-level bindings to Pluggable Authentication Moduleslibc
If you're looking for a nice, safe, Rusty API to PAM, may I recommend nonstick?
Supported PAM implementations are defined in the pam_impl::PamImpl
enum.
This crate automatically chooses the appropriate PAM implementation you are most likely to need installed based on the target OS.
You can also explicitly specify the PAM implementation you want (if not detected correctly) by setting the LIBPAMSYS_IMPL
environment variable at build time.
All build-time configuration is performed by the build script of the libpam-sys-impls
crate.
Normally, this crate exports all functionality available in the selected PAM library.
XSso
exports only the subset of the X/SSO specification supported by both OpenPAM and Sun PAM.
Downstream crates can detect the current PAM implementation using custom #[cfg]
s:
// 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:
#[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-impls
.
Tests are mostly run through libpam-sys-test
, which lives in the crate's workspace in its repository (along with nonstick).
ctest
verifies the correctness of the FFI bindings (function/struct alignment, etc.).There are some unit tests of glue code and other type checks.
This crate supports Rust 1.75, the current version in Debian Trixie and Ubuntu 24.04.2 LTS. There shouldn't be much that needs changing, since PAM's API is quite stable.