comparison src/libpam/mod.rs @ 80:5aa1a010f1e8

Start using PAM headers; improve owned/borrowed distinction. - Uses bindgen to generate bindings (only if needed). - Gets the story together on owned vs. borrowed handles. - Reduces number of mutable borrows in handle operation (since `PamHandle` is neither `Send` nor `Sync`, we never have to worry about thread safety. - Improves a bunch of macros so we don't have our own special syntax for docs. - Implement question indirection for standard XSSO PAM implementations.
author Paul Fisher <paul@pfish.zone>
date Tue, 10 Jun 2025 01:09:30 -0400
parents 002adfb98c5c
children
comparison
equal deleted inserted replaced
79:2128123b9406 80:5aa1a010f1e8
11 mod answer; 11 mod answer;
12 mod conversation; 12 mod conversation;
13 mod handle; 13 mod handle;
14 mod memory; 14 mod memory;
15 mod module; 15 mod module;
16 pub(crate) mod pam_ffi;
16 mod question; 17 mod question;
17 18
19 #[doc(inline)]
18 pub use handle::{LibPamHandle, OwnedLibPamHandle}; 20 pub use handle::{LibPamHandle, OwnedLibPamHandle};
19 use std::ffi::{c_char, c_int, c_void};
20
21 #[link(name = "pam")]
22 extern "C" {
23 fn pam_get_data(
24 pamh: *mut LibPamHandle,
25 module_data_name: *const c_char,
26 data: &mut *const c_void,
27 ) -> c_int;
28
29 fn pam_set_data(
30 pamh: *mut LibPamHandle,
31 module_data_name: *const c_char,
32 data: *const c_void,
33 cleanup: extern "C" fn(pamh: *const c_void, data: *mut c_void, error_status: c_int),
34 ) -> c_int;
35
36 fn pam_get_item(pamh: *mut LibPamHandle, item_type: c_int, item: &mut *const c_void) -> c_int;
37
38 fn pam_set_item(pamh: *mut LibPamHandle, item_type: c_int, item: *const c_void) -> c_int;
39
40 fn pam_get_user(
41 pamh: *mut LibPamHandle,
42 user: &mut *const c_char,
43 prompt: *const c_char,
44 ) -> c_int;
45
46 fn pam_get_authtok(
47 pamh: *mut LibPamHandle,
48 item_type: c_int,
49 data: &mut *const c_char,
50 prompt: *const c_char,
51 ) -> c_int;
52
53 fn pam_end(pamh: *mut LibPamHandle, status: c_int) -> c_int;
54
55 // TODO: pam_authenticate - app
56 // pam_setcred - app
57 // pam_acct_mgmt - app
58 // pam_chauthtok - app
59 // pam_open_session - app
60 // pam_close_session - app
61 // pam_putenv - shared
62 // pam_getenv - shared
63 // pam_getenvlist - shared
64 }