Mercurial > crates > nonstick
diff libpam-sys/src/funcs/xsso_base.rs @ 125:2b255c92417b
Introduce base PAM functions; use the real X/SSO PAM header for tests.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 30 Jun 2025 17:47:32 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpam-sys/src/funcs/xsso_base.rs Mon Jun 30 17:47:32 2025 -0400 @@ -0,0 +1,97 @@ +//! Only the very base functions described in the X/SSO specification. + +use crate::pam_conv; +use crate::structs::{pam_handle_t, CleanupCallback}; +use std::ffi::{c_char, c_int, c_void}; + +extern "C" { + /// Account validation. + pub fn pam_acct_mgmt(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + /// Authenticate a user. + pub fn pam_authenticate(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + // Nobody implements pam_authenticate_secondary. + + /// Manage authentication tokens. + pub fn pam_chauthtok(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + /// Close an opened user session. + pub fn pam_close_session(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + /// Ends the PAM transaction. + pub fn pam_end(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + /// Gets module-specific data. PAM still owns the data. + pub fn pam_get_data( + pamh: *mut pam_handle_t, + module_data_name: *const c_char, + data: &mut *const c_void, + ) -> c_int; + + /// Gets an environment variable. You own the return value. + pub fn pam_getenv(pamh: *mut pam_handle_t, name: *const c_char) -> *mut c_char; + + /// Gets all the environment variables. You own everything it points to. + pub fn pam_getenvlist(pamh: *mut pam_handle_t) -> *mut *mut c_char; + + /// Get information about the transaction. + pub fn pam_get_item( + pamh: *mut pam_handle_t, + item_type: c_int, + item: &mut *const c_void, + ) -> c_int; + + // Nobody implements pam_get_mapped_authtok. + // Nobody implements pam_get_mapped_username. + + /// Get the username. + pub fn pam_get_user( + pamh: *mut pam_handle_t, + user: &mut *const c_char, + prompt: *const c_char, + ) -> c_int; + + /// Opens a user session. + pub fn pam_open_session(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + /// Sets the value of an environment variable. `namevalue` is copied. + pub fn pam_putenv(pamh: *mut pam_handle_t, namevalue: *const c_char) -> c_int; + + /// Update or delete user credentials. + pub fn pam_setcred(pamh: *mut pam_handle_t, flags: c_int) -> c_int; + + /// Set module-specific data. + pub fn pam_set_data( + pamh: *mut pam_handle_t, + module_data_name: *const c_char, + data: *mut c_void, + cleanup: CleanupCallback, + ) -> c_int; + + /// Set information about the transaction. The `item` is copied. + pub fn pam_set_item(pamh: *mut pam_handle_t, item_type: c_int, item: *const c_void) -> c_int; + + // Nobody implements pam_set_mapped_authtok. + // Nobody implements pam_set_mapped_username. + + // The pam_sm_whatever functions are prototypes for the functions that + // a PAM module should implement, not symbols provided by PAM. + + // Nobody implements pam_authenticate_secondary. + + /// Starts a PAM transaction. The `conv` may or may not be copied. + pub fn pam_start( + service: *const c_char, + user: *const c_char, + pam_conv: *mut pam_conv, + pamh: &mut *mut pam_handle_t, + ); + + /// Gets a statically-allocated error string. + /// + /// All implementations of PAM known to this library (Linux-PAM, OpenPAM, + /// and Sun) ignore `pamh` and will accept a null pointer. + pub fn pam_strerror(pamh: *const pam_handle_t, error_number: c_int) -> *const c_char; + +}