annotate libpam-sys/src/ffi.rs @ 131:a632a8874131

Get all the Linux-PAM functions into libpam-sys, and get tests right.
author Paul Fisher <paul@pfish.zone>
date Wed, 02 Jul 2025 02:24:21 -0400
parents 80c07e5ab22f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
1 //! The actual PAM FFI bindings.
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
2 //!
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
3 //! They live in this specific file rather than lib.rs because otherwise
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
4 //! ctest gets very upset about some of the macros we use.
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
5 #![allow(non_camel_case_types)]
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
6 #![allow(unused_imports)]
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
7
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
8 use num_enum::{IntoPrimitive, TryFromPrimitive};
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
9 use std::ffi::{c_char, c_int, c_uint, c_void};
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
10 use std::fmt;
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
11 use std::marker::{PhantomData, PhantomPinned};
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
12
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
13 /// A marker struct to make whatever it's in `!Sync`, `!Send`, and `!Unpin`.
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
14 #[derive(Default, PartialOrd, PartialEq, Ord, Eq)]
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
15 #[repr(C)]
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
16 struct ExtremelyUnsafe {
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
17 _value: (),
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
18 _marker: PhantomData<(PhantomPinned, *mut c_void)>,
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
19 }
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
20
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
21 impl fmt::Debug for ExtremelyUnsafe {
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
23 write!(f, "ExtremelyUnsafe({self:p})")
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
24 }
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
25 }
106
49d9e2b5c189 An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
26
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
27 /// An opaque structure that PAM uses to communicate.
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
28 ///
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
29 /// This is only ever returned in pointer form and cannot be constructed.
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
30 #[repr(C)]
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
31 pub struct pam_handle(ExtremelyUnsafe);
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
32
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
33 impl fmt::Debug for pam_handle {
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
35 write!(f, "pam_handle({self:p}")
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
36 }
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
37 }
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
38
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
39 /// An opaque structure that is passed through PAM in a conversation.
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
40 #[repr(C)]
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
41 pub struct AppData(ExtremelyUnsafe);
106
49d9e2b5c189 An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
42
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
43 impl fmt::Debug for AppData {
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
45 write!(f, "AppData({self:p}")
106
49d9e2b5c189 An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
46 }
49d9e2b5c189 An irresponsible mix of implementing libpam-sys and other stuff.
Paul Fisher <paul@pfish.zone>
parents:
diff changeset
47 }
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
48
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
49 /// Just an alias for the type of [`pam_conv::conv`].
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
50 ///
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
51 /// For important details about the format of `messages`,
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
52 /// see the [`helpers`](crate::helpers) module.
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
53 ///
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
54 /// ```no_run
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
55 /// # use libpam_sys::{ConversationCallback, pam_conv};
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
56 /// fn convo() -> ConversationCallback {
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
57 /// // ...
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
58 /// # unimplemented!()
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
59 /// }
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
60 /// let conv = pam_conv{conv: convo(), appdata_ptr: std::ptr::null_mut()};
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
61 /// ```
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
62 pub type ConversationCallback = unsafe extern "C" fn(
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
63 num_msg: c_int,
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
64 msg: *const *const pam_message,
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
65 resp: *mut *mut pam_response,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
66 appdata: *mut AppData,
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
67 ) -> c_int;
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
68
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
69 /// Alias for the callback to [`pam_set_data`](crate::pam_set_data).
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
70 ///
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
71 /// ```no_run
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
72 /// # use std::ffi::CString;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
73 /// use libpam_sys::{CleanupCallback, pam_set_data};
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
74 /// # use libpam_sys::pam_handle;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
75 /// # let handle: *mut pam_handle = std::ptr::null_mut();
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
76 /// # let mut my_data = 100;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
77 /// # let data_ptr = &mut my_data as *mut i32;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
78 /// fn cleanup() -> CleanupCallback {
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
79 /// // ...
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
80 /// # unimplemented!()
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
81 /// }
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
82 /// let name = CString::new("name").unwrap();
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
83 /// unsafe {
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
84 /// pam_set_data(handle, name.as_ptr().cast_mut(), data_ptr.cast(), cleanup());
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
85 /// }
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
86 /// ```
130
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
87 pub type CleanupCallback =
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
88 unsafe extern "C" fn(pamh: *mut pam_handle, data: *mut c_void, pam_end_status: c_int);
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
89
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
90 /// Used by PAM to communicate between the module and the application.
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
91 #[repr(C)]
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
92 pub struct pam_conv {
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
93 pub conv: unsafe extern "C" fn(
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
94 num_msg: c_int,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
95 msg: *const *const pam_message,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
96 resp: *mut *mut pam_response,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
97 appdata: *mut AppData,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
98 ) -> c_int,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
99 pub appdata_ptr: *mut AppData,
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
100 }
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
101
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
102 /// A message sent into a PAM conversation.
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
103 #[repr(C)]
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
104 pub struct pam_message {
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
105 pub msg_style: c_int,
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
106 pub msg: *const c_char,
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
107 }
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
108
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
109 /// A response returned from a PAM conversation.
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
110 #[repr(C)]
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
111 pub struct pam_response {
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
112 pub resp: *mut c_char,
125
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
113 /// Completely unused.
2b255c92417b Introduce base PAM functions; use the real X/SSO PAM header for tests.
Paul Fisher <paul@pfish.zone>
parents: 119
diff changeset
114 pub resp_retcode: c_int,
118
39760dfc9b3b Detect PAM library based only on system lib; rename minimal lib to XSso.
Paul Fisher <paul@pfish.zone>
parents: 117
diff changeset
115 }
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
116
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
117 /// Definition of the PAM_XAUTHDATA item. Compatible with `xcb_auth_info_t`.
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
118 #[cfg(_hack_impl = "LinuxPam")]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
119 #[repr(C)]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
120 pub struct pam_xauth_data {
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
121 namelen: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
122 name: *mut c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
123 datalen: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
124 data: *mut c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
125 }
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
126
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
127 #[cfg(_hack_impl = "LinuxPam")]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
128 #[derive(Copy, Clone, Debug, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
129 #[repr(i32)]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
130 pub enum pam_modutil_redirect_fd {
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
131 PAM_MODUTIL_IGNORE_FD,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
132 PAM_MODUTIL_PIPE_FD,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
133 PAM_MODUTIL_NULL_FD,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
134 }
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
135
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
136 #[cfg(_hack_impl = "LinuxPam")]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
137 pub use pam_modutil_redirect_fd::*;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
138
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
139 #[cfg(_hack_impl = "LinuxPam")]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
140 #[derive(Debug)]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
141 #[repr(C)]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
142 pub struct pam_modutil_privs {
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
143 grplist: *mut libc::gid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
144 number_of_groups: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
145 allocated: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
146 old_gid: libc::gid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
147 old_uid: libc::uid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
148 is_dropped: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
149 }
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
150
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
151 // These are the functions specified in X/SSO. Everybody exports them.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
152 extern "C" {
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
153 /// Account validation.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
154 pub fn pam_acct_mgmt(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
155
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
156 /// Authenticate a user.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
157 pub fn pam_authenticate(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
158
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
159 // Nobody implements pam_authenticate_secondary.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
160
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
161 /// Manage authentication tokens.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
162 pub fn pam_chauthtok(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
163
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
164 /// Close an opened user session.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
165 pub fn pam_close_session(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
166
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
167 /// Ends the PAM transaction.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
168 pub fn pam_end(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
169
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
170 /// Gets module-specific data. PAM still owns the data.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
171 pub fn pam_get_data(
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
172 pamh: *mut pam_handle,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
173 module_data_name: *const c_char,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
174 data: *mut *const c_void,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
175 ) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
176
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
177 /// Gets an environment variable. You own the return value.
130
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
178 pub fn pam_getenv(pamh: *const pam_handle, name: *const c_char) -> *mut c_char;
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
179
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
180 /// Gets all the environment variables. You own everything it points to.
130
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
181 pub fn pam_getenvlist(pamh: *const pam_handle) -> *mut *mut c_char;
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
182
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
183 /// Get information about the transaction.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
184 ///
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
185 /// The item is owned by PAM.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
186 pub fn pam_get_item(
130
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
187 pamh: *const pam_handle,
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
188 item_type: c_int,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
189 item: *mut *const c_void,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
190 ) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
191
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
192 // Nobody implements pam_get_mapped_authtok.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
193 // Nobody implements pam_get_mapped_username.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
194
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
195 /// Get the username. PAM owns it.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
196 pub fn pam_get_user(
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
197 pamh: *mut pam_handle,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
198 user: *mut *const c_char,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
199 prompt: *const c_char,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
200 ) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
201
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
202 /// Opens a user session.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
203 pub fn pam_open_session(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
204
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
205 /// Sets the value of an environment variable. `namevalue` is copied.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
206 pub fn pam_putenv(pamh: *mut pam_handle, namevalue: *const c_char) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
207
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
208 /// Update or delete user credentials.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
209 pub fn pam_setcred(pamh: *mut pam_handle, flags: c_int) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
210
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
211 /// Set module-specific data. PAM will call `cleanup` when completed.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
212 pub fn pam_set_data(
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
213 pamh: *mut pam_handle,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
214 module_data_name: *const c_char,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
215 data: *mut c_void,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
216 cleanup: unsafe extern "C" fn(
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
217 pamh: *mut pam_handle,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
218 data: *mut c_void,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
219 pam_end_status: c_int,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
220 ),
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
221 ) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
222
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
223 /// Set information about the transaction. The `item` is copied.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
224 pub fn pam_set_item(pamh: *mut pam_handle, item_type: c_int, item: *const c_void) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
225
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
226 // Nobody implements pam_set_mapped_authtok.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
227 // Nobody implements pam_set_mapped_username.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
228
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
229 // The pam_sm_whatever functions are prototypes for the functions that
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
230 // a PAM module should implement, not symbols provided by PAM.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
231
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
232 // Nobody implements pam_authenticate_secondary.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
233
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
234 /// Starts a PAM transaction. The `conv` may or may not be copied.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
235 pub fn pam_start(
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
236 service: *const c_char,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
237 user: *const c_char,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
238 pam_conv: *mut pam_conv,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
239 pamh: *mut *mut pam_handle,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
240 ) -> c_int;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
241
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
242 /// Gets a statically-allocated error string.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
243 ///
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
244 /// All implementations of PAM known to this library (Linux-PAM, OpenPAM,
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
245 /// and Sun) ignore `pamh` and will accept a null pointer.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
246 pub fn pam_strerror(pamh: *const pam_handle, error_number: c_int) -> *mut c_char;
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
247 }
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
248
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
249 // We use `_hack_impl` because ctest loses its mind
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
250 // when it comes across the `cfg_pam_impl` macro.
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
251 // This is a custom cfg variable set in our build.rs. Don't do this; just use
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
252 // cfg_pam_impl.
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
253 #[cfg(any(_hack_impl = "LinuxPam", _hack_impl = "OpenPam"))]
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
254 extern "C" {
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
255 /// Gets `PAM_AUTHTOK`, or asks the user if that is unset.
130
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
256 pub fn pam_get_authtok(
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
257 pamh: *mut pam_handle,
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
258 item: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
259 authtok: *mut *const c_char,
130
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
260 prompt: *const c_char,
80c07e5ab22f Transfer over (almost) completely to using libpam-sys.
Paul Fisher <paul@pfish.zone>
parents: 129
diff changeset
261 ) -> c_int;
127
c77846f3a979 GET CTEST WORKING.
Paul Fisher <paul@pfish.zone>
parents: 125
diff changeset
262 }
131
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
263
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
264 #[cfg(_hack_impl = "LinuxPam")]
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
265 extern "C" {
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
266 pub fn pam_fail_delay(pamh: *mut pam_handle, musec_delay: c_uint) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
267
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
268 /// Start a PAM transaction based on configuration in the given directory.
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
269 pub fn pam_start_confdir(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
270 service_name: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
271 user: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
272 pam_conversation: *mut pam_conv,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
273 confdir: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
274 pamh: *mut *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
275 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
276
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
277 // We don't export the v-variants of the formatting functions.
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
278
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
279 pub fn pam_syslog(pamh: *const pam_handle, priority: c_int, fmt: *const c_char, ...);
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
280
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
281 pub fn pam_prompt(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
282 pamh: *const pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
283 style: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
284 response: *mut *mut c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
285 fmt: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
286 ...
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
287 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
288
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
289 pub fn pam_get_authtok_noverify(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
290 pamh: *const pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
291 authtok: *mut *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
292 prompt: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
293 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
294
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
295 pub fn pam_get_authtok_verify(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
296 pamh: *const pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
297 authtok: *mut *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
298 prompt: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
299 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
300
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
301 // pam_modutil also lives in libpam for Linux.
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
302
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
303 pub fn pam_modutil_check_user_in_passwd(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
304 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
305 user_name: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
306 file_name: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
307 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
308
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
309 pub fn pam_modutil_getpwnam(pamh: *mut pam_handle, user: *const c_char) -> *mut libc::passwd;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
310
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
311 pub fn pam_modutil_getpwuid(pamh: *mut pam_handle, uid: libc::uid_t) -> *mut libc::passwd;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
312
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
313 pub fn pam_modutil_getgrnam(pamh: *mut pam_handle, group: *const c_char) -> *mut libc::group;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
314
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
315 pub fn pam_modutil_getgrgid(pamh: *mut pam_handle, gid: libc::gid_t) -> *mut libc::group;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
316
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
317 pub fn pam_modutil_getspnam(pamh: *mut pam_handle, user: *const c_char) -> *mut libc::spwd;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
318
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
319 pub fn pam_modutil_user_in_group_nam_nam(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
320 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
321 user: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
322 group: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
323 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
324 pub fn pam_modutil_user_in_group_nam_gid(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
325 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
326 user: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
327 group: libc::gid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
328 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
329
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
330 pub fn pam_modutil_user_in_group_uid_nam(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
331 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
332 user: libc::uid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
333 group: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
334 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
335
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
336 pub fn pam_modutil_user_in_group_uid_gid(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
337 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
338 user: libc::uid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
339 group: libc::gid_t,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
340 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
341
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
342 pub fn pam_modutil_getlogin(pamh: *mut pam_handle) -> *const c_char;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
343
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
344 pub fn pam_modutil_read(fd: c_int, buffer: *mut c_char, count: c_int) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
345
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
346 pub fn pam_modutil_write(fd: c_int, buffer: *const c_char, count: c_int) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
347
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
348 pub fn pam_modutil_audit_write(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
349 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
350 typ: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
351 message: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
352 retval: c_int,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
353 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
354
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
355 pub fn pam_modutil_drop_priv(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
356 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
357 p: *mut pam_modutil_privs,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
358 pw: *const libc::passwd,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
359 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
360
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
361 pub fn pam_modutil_regain_priv(pamh: *mut pam_handle, p: *mut pam_modutil_privs) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
362
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
363 pub fn pam_modutil_sanitize_helper_fds(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
364 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
365 redirect_stdin: pam_modutil_redirect_fd,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
366 redirect_stdout: pam_modutil_redirect_fd,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
367 redirect_stderr: pam_modutil_redirect_fd,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
368 ) -> c_int;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
369
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
370 pub fn pam_modutil_search_key(
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
371 pamh: *mut pam_handle,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
372 file_name: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
373 key: *const c_char,
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
374 ) -> *mut c_char;
a632a8874131 Get all the Linux-PAM functions into libpam-sys, and get tests right.
Paul Fisher <paul@pfish.zone>
parents: 130
diff changeset
375 }