Mercurial > crates > nonstick
diff src/pam_ffi/mod.rs @ 72:47eb242a4f88
Fill out the PamHandle trait.
This updates the PamHandle trait to have methods for each Item,
and implements them on the LibPamHandle.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Wed, 04 Jun 2025 03:53:36 -0400 |
parents | 58f9d2a4df38 |
children | ac6881304c78 |
line wrap: on
line diff
--- a/src/pam_ffi/mod.rs Tue Jun 03 21:54:58 2025 -0400 +++ b/src/pam_ffi/mod.rs Wed Jun 04 03:53:36 2025 -0400 @@ -5,7 +5,7 @@ //! those data structures. //! //! Everything in here is hazmat. -//! +//! #![allow(dead_code)] @@ -15,13 +15,15 @@ use crate::pam_ffi::memory::Immovable; use crate::pam_ffi::message::OwnedMessages; +#[doc(inline)] pub use message::Message; +#[doc(inline)] pub use response::RawResponse; use std::ffi::{c_char, c_int, c_void}; /// An opaque structure that a PAM handle points to. #[repr(C)] -pub struct Handle { +pub struct LibPamHandle { _data: (), _marker: Immovable, } @@ -43,7 +45,7 @@ /// which PAM sets in response to a module's request. /// This is an array of structs, not an array of pointers to a struct. /// There should always be exactly as many `responses` as `num_msg`. -/// - `appdata` is the `appdata` field of the [`Conversation`] we were passed. +/// - `appdata` is the `appdata` field of the [`LibPamConversation`] we were passed. pub type ConversationCallback = extern "C" fn( num_msg: c_int, messages: &OwnedMessages, @@ -51,44 +53,51 @@ appdata: *const AppData, ) -> c_int; -/// A callback and the associated [`AppData`] pointer that needs to be passed back to it. +/// The type used by libpam to call back into a conversation. #[repr(C)] -pub struct Conversation { +pub struct LibPamConversation { + /// The function that is called to get information from the user. callback: ConversationCallback, + /// The pointer that will be passed as the last parameter + /// to the conversation callback. appdata: *const AppData, } #[link(name = "pam")] extern "C" { pub fn pam_get_data( - pamh: *const Handle, + pamh: *const LibPamHandle, module_data_name: *const c_char, data: &mut *const c_void, ) -> c_int; pub fn pam_set_data( - pamh: *mut Handle, + pamh: *mut LibPamHandle, module_data_name: *const c_char, data: *const c_void, cleanup: extern "C" fn(pamh: *const c_void, data: *mut c_void, error_status: c_int), ) -> c_int; - pub fn pam_get_item(pamh: *const Handle, item_type: c_int, item: &mut *const c_void) -> c_int; + pub fn pam_get_item( + pamh: *mut LibPamHandle, + item_type: c_int, + item: &mut *const c_void, + ) -> c_int; - pub fn pam_set_item(pamh: *mut Handle, item_type: c_int, item: *const c_void) -> c_int; + pub fn pam_set_item(pamh: *mut LibPamHandle, item_type: c_int, item: *const c_void) -> c_int; pub fn pam_get_user( - pamh: *const Handle, + pamh: *mut LibPamHandle, user: &mut *const c_char, prompt: *const c_char, ) -> c_int; pub fn pam_get_authtok( - pamh: *const Handle, + pamh: *mut LibPamHandle, item_type: c_int, data: &mut *const c_char, prompt: *const c_char, ) -> c_int; - pub fn pam_end(pamh: *mut Handle, status: c_int) -> c_int; + pub fn pam_end(pamh: *mut LibPamHandle, status: c_int) -> c_int; }