16 releases

Uses old Rust 2015

0.5.5 Jun 28, 2024
0.5.4 Feb 9, 2024
0.5.3 Sep 1, 2023
0.5.2 May 2, 2022
0.1.0 Jun 25, 2017

#147 in Authentication

Download history 65/week @ 2024-07-22 161/week @ 2024-07-29 14/week @ 2024-08-05 10/week @ 2024-08-12 43/week @ 2024-08-19 63/week @ 2024-08-26 105/week @ 2024-09-02 57/week @ 2024-09-09 61/week @ 2024-09-16 45/week @ 2024-09-23 109/week @ 2024-09-30 280/week @ 2024-10-07 152/week @ 2024-10-14 270/week @ 2024-10-21 159/week @ 2024-10-28 184/week @ 2024-11-04

765 downloads per month
Used in shavee_pam

GPL-3.0 license

31KB
550 lines

PAM SM

Crates.io version shield Crates.io license shield

Rust FFI wrapper to implement PAM service modules for Linux.

Documentation - Cargo - Repository

Features

This crate supports the following optional features:

  • libpam: this enables the extension trait PamLibExt and linking against libpam.so for its native implementation.

lib.rs:

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);

Dependencies

~105KB