view src/pam_ffi.rs @ 64:bbe84835d6db v0.0.5

More organization; add lots of docs. - moves `PamHandle` to its own module, since it will be used by both modules and clients. - adds a ton of documentation to the `PamModule` trait and reorders methods to most-interesting-first. - adds more flag values from pam_modules.h. - other misc cleanup.
author Paul Fisher <paul@pfish.zone>
date Thu, 22 May 2025 01:52:32 -0400
parents 05cc2c27334f
children
line wrap: on
line source

//! FFI to the PAM library.

use libc::c_char;
use std::ffi::c_int;

#[link(name = "pam")]
extern "C" {
    pub fn pam_get_data(
        pamh: *const libc::c_void,
        module_data_name: *const c_char,
        data: &mut *const libc::c_void,
    ) -> c_int;

    pub fn pam_set_data(
        pamh: *mut libc::c_void,
        module_data_name: *const c_char,
        data: *const libc::c_void,
        cleanup: extern "C" fn(
            pamh: *const libc::c_void,
            data: *mut libc::c_void,
            error_status: c_int,
        ),
    ) -> c_int;

    pub fn pam_get_item(
        pamh: *const libc::c_void,
        item_type: c_int,
        item: &mut *const libc::c_void,
    ) -> c_int;

    pub fn pam_set_item(
        pamh: *mut libc::c_void,
        item_type: c_int,
        item: *const libc::c_void,
    ) -> c_int;

    pub fn pam_get_user(
        pamh: *const libc::c_void,
        user: &mut *const c_char,
        prompt: *const c_char,
    ) -> c_int;

    pub fn pam_get_authtok(
        pamh: *const libc::c_void,
        item_type: c_int,
        data: &mut *const c_char,
        prompt: *const c_char,
    ) -> c_int;
}