view testharness/src/lib.rs @ 139:33b9622ed6d2

Remove redundant memory management in nonstick::libpam; fix UB. - Uses the libpam-sys-helpers BinaryPayload / OwnedBinaryPayload structs to handle memory management and parsing for Linux-PAM binary messages. - Gets rid of the (technically) undefined behavior in PtrPtrVec due to pointer provenance. - Don't check for malloc failing. It won't, even if it does. - Formatting/cleanups/etc.
author Paul Fisher <paul@pfish.zone>
date Thu, 03 Jul 2025 23:57:49 -0400
parents c77846f3a979
children 1bc52025156b
line wrap: on
line source

//! The nonstick library
extern crate nonstick;

use nonstick::{pam_hooks, Flags, PamHandleModule, PamModule};
use std::ffi::CStr;

struct TestHarness;

impl<M: PamHandleModule> PamModule<M> for TestHarness {
    fn authenticate(_handle: &mut M, _args: Vec<&CStr>, _flags: Flags) -> nonstick::Result<()> {
        Ok(())
    }

    fn account_management(
        _handle: &mut M,
        _args: Vec<&CStr>,
        _flags: Flags,
    ) -> nonstick::Result<()> {
        Ok(())
    }
}

pam_hooks!(TestHarness);