15 releases

Uses old Rust 2015

0.5.4 Feb 9, 2024
0.5.3 Sep 1, 2023
0.5.2 May 2, 2022
0.5.1 Mar 27, 2022
0.1.0 Jun 25, 2017

#142 in Authentication

Download history 36/week @ 2023-12-18 7/week @ 2023-12-25 40/week @ 2024-01-01 48/week @ 2024-01-08 33/week @ 2024-01-15 8/week @ 2024-01-22 14/week @ 2024-01-29 13/week @ 2024-02-05 24/week @ 2024-02-12 155/week @ 2024-02-19 77/week @ 2024-02-26 9/week @ 2024-03-04 18/week @ 2024-03-11 19/week @ 2024-03-18 2/week @ 2024-03-25 71/week @ 2024-04-01

111 downloads per month
Used in shavee_pam

GPL-3.0 license

30KB
540 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

~91KB