view src/lib.rs @ 87:05291b601f0a

Well and truly separate the Linux extensions. This separates the Linux extensions on the libpam side, and disables the two enums on the interface side. Users can still call the Linux extensions from non-Linux PAM impls, but they'll get a conversation error back.
author Paul Fisher <paul@pfish.zone>
date Tue, 10 Jun 2025 04:40:01 -0400
parents c30811b4afae
children
line wrap: on
line source

//! A safe, nonstick interface to PAM.
//!
//! This implements a type-safe library to interact with PAM.
//! Currently, it implements a subset of PAM useful for implementing a module.
//!
//! To write a new PAM module using this crate:
//!
//!  1. Create a `dylib` crate.
//!  2. Implement a subset of the functions in the [`PamModule`] trait
//!     corresponding to what you want your module to do.
//!     In the simplest case (for a new password-based authenticator),
//!     this will be the [`PamModule::authenticate`] function.
//!  3. Export your PAM module using the [`pam_hooks!`] macro.
//!  4. Build and install the dynamic library.
//!     This usually entails placing it at
//!     <code>/usr/lib/security/pam_<var>your_module</var>.so</code>,
//!     or maybe
//!     <code>/usr/lib/<var>your-architecture</var>/security/pam_<var>your_module</var>.so</code>.
//!
//! For general information on writing PAM modules, see
//! [The Linux-PAM Module Writers' Guide][module-guide]
//!
//! [module-guide]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/Linux-PAM_MWG.html

// Temporary until everything is fully wired up.
#![allow(dead_code)]

pub mod constants;
pub mod conv;
pub mod module;

pub mod handle;

#[cfg(feature = "link")]
mod libpam;

#[cfg(feature = "link")]
pub use crate::libpam::{LibPamHandle, OwnedLibPamHandle};
#[doc(inline)]
pub use crate::{
    constants::{ErrorCode, Flags, Result},
    conv::{BinaryData, Conversation, SimpleConversation},
    handle::{PamHandleApplication, PamHandleModule, PamShared},
    module::PamModule,
};