Crate pamsm

Source
Expand description

PAM Service Module wrappers

§Usage

For example, here is a time based authentication module :

#[macro_use] extern crate pamsm;
extern crate time;

use pamsm::{PamServiceModule, Pam, PamFlags, PamError};

struct PamTime;

impl PamServiceModule for PamTime {
    fn authenticate(pamh: Pam, _: PamFlags, args: Vec<String>) -> PamError {
        let hour = time::OffsetDateTime::now_utc().hour();
        if hour != 4 {
            // Only allow authentication when it's 4 AM
            PamError::SUCCESS
        } else {
            PamError::AUTH_ERR
        }
    }
}

pam_module!(PamTime);

Macros§

pam_module
Define entrypoints for the PAM module.

Structs§

Pam
Opaque PAM handle, with additional native methods available via PamLibExt.
PamFlags
PamSendRef
This sendable reference to Pam can be created via Pam::as_send_ref or From/Into.

Enums§

LogLvl
PamError
PamMsgStyle

Traits§

PamData
Trait to implement for data stored with pam using PamLibExt::send_data in order to provide a cleanup callback.
PamLibExt
Extension trait over Pam, usually provided by the libpam shared library.
PamServiceModule
Default service module implementation. All default functions return SERVICE_ERR. You can override functions depending on what kind of module you implement. See the respective pam_sm_* man pages for documentation.

Type Aliases§

PamCleanupCb
Prototype of the callback used with PamLibExt::send_bytes
PamResult