Mercurial > crates > nonstick
comparison 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 |
comparison
equal
deleted
inserted
replaced
124:f469b8d9ad78 | 125:2b255c92417b |
---|---|
1 //! Only the very base functions described in the X/SSO specification. | |
2 | |
3 use crate::pam_conv; | |
4 use crate::structs::{pam_handle_t, CleanupCallback}; | |
5 use std::ffi::{c_char, c_int, c_void}; | |
6 | |
7 extern "C" { | |
8 /// Account validation. | |
9 pub fn pam_acct_mgmt(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
10 | |
11 /// Authenticate a user. | |
12 pub fn pam_authenticate(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
13 | |
14 // Nobody implements pam_authenticate_secondary. | |
15 | |
16 /// Manage authentication tokens. | |
17 pub fn pam_chauthtok(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
18 | |
19 /// Close an opened user session. | |
20 pub fn pam_close_session(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
21 | |
22 /// Ends the PAM transaction. | |
23 pub fn pam_end(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
24 | |
25 /// Gets module-specific data. PAM still owns the data. | |
26 pub fn pam_get_data( | |
27 pamh: *mut pam_handle_t, | |
28 module_data_name: *const c_char, | |
29 data: &mut *const c_void, | |
30 ) -> c_int; | |
31 | |
32 /// Gets an environment variable. You own the return value. | |
33 pub fn pam_getenv(pamh: *mut pam_handle_t, name: *const c_char) -> *mut c_char; | |
34 | |
35 /// Gets all the environment variables. You own everything it points to. | |
36 pub fn pam_getenvlist(pamh: *mut pam_handle_t) -> *mut *mut c_char; | |
37 | |
38 /// Get information about the transaction. | |
39 pub fn pam_get_item( | |
40 pamh: *mut pam_handle_t, | |
41 item_type: c_int, | |
42 item: &mut *const c_void, | |
43 ) -> c_int; | |
44 | |
45 // Nobody implements pam_get_mapped_authtok. | |
46 // Nobody implements pam_get_mapped_username. | |
47 | |
48 /// Get the username. | |
49 pub fn pam_get_user( | |
50 pamh: *mut pam_handle_t, | |
51 user: &mut *const c_char, | |
52 prompt: *const c_char, | |
53 ) -> c_int; | |
54 | |
55 /// Opens a user session. | |
56 pub fn pam_open_session(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
57 | |
58 /// Sets the value of an environment variable. `namevalue` is copied. | |
59 pub fn pam_putenv(pamh: *mut pam_handle_t, namevalue: *const c_char) -> c_int; | |
60 | |
61 /// Update or delete user credentials. | |
62 pub fn pam_setcred(pamh: *mut pam_handle_t, flags: c_int) -> c_int; | |
63 | |
64 /// Set module-specific data. | |
65 pub fn pam_set_data( | |
66 pamh: *mut pam_handle_t, | |
67 module_data_name: *const c_char, | |
68 data: *mut c_void, | |
69 cleanup: CleanupCallback, | |
70 ) -> c_int; | |
71 | |
72 /// Set information about the transaction. The `item` is copied. | |
73 pub fn pam_set_item(pamh: *mut pam_handle_t, item_type: c_int, item: *const c_void) -> c_int; | |
74 | |
75 // Nobody implements pam_set_mapped_authtok. | |
76 // Nobody implements pam_set_mapped_username. | |
77 | |
78 // The pam_sm_whatever functions are prototypes for the functions that | |
79 // a PAM module should implement, not symbols provided by PAM. | |
80 | |
81 // Nobody implements pam_authenticate_secondary. | |
82 | |
83 /// Starts a PAM transaction. The `conv` may or may not be copied. | |
84 pub fn pam_start( | |
85 service: *const c_char, | |
86 user: *const c_char, | |
87 pam_conv: *mut pam_conv, | |
88 pamh: &mut *mut pam_handle_t, | |
89 ); | |
90 | |
91 /// Gets a statically-allocated error string. | |
92 /// | |
93 /// All implementations of PAM known to this library (Linux-PAM, OpenPAM, | |
94 /// and Sun) ignore `pamh` and will accept a null pointer. | |
95 pub fn pam_strerror(pamh: *const pam_handle_t, error_number: c_int) -> *const c_char; | |
96 | |
97 } |