diff libpam-sys/src/ffi.rs @ 130:80c07e5ab22f

Transfer over (almost) completely to using libpam-sys. This reimplements everything in nonstick on top of the new -sys crate. We don't yet use libpam-sys's helpers for binary message payloads. Soon.
author Paul Fisher <paul@pfish.zone>
date Tue, 01 Jul 2025 06:11:43 -0400
parents 5b2de52dd8b2
children a632a8874131
line wrap: on
line diff
--- a/libpam-sys/src/ffi.rs	Mon Jun 30 23:49:54 2025 -0400
+++ b/libpam-sys/src/ffi.rs	Tue Jul 01 06:11:43 2025 -0400
@@ -78,11 +78,8 @@
 ///     pam_set_data(handle, name.as_ptr().cast_mut(), data_ptr.cast(), cleanup());
 /// }
 /// ```
-pub type CleanupCallback = unsafe extern "C" fn(
-    pamh: *mut pam_handle,
-    data: *mut c_void,
-    pam_end_status: c_int,
-);
+pub type CleanupCallback =
+    unsafe extern "C" fn(pamh: *mut pam_handle, data: *mut c_void, pam_end_status: c_int);
 
 /// Used by PAM to communicate between the module and the application.
 #[repr(C)]
@@ -111,7 +108,6 @@
     pub resp_retcode: c_int,
 }
 
-
 // These are the functions specified in X/SSO. Everybody exports them.
 extern "C" {
     /// Account validation.
@@ -139,16 +135,16 @@
     ) -> c_int;
 
     /// Gets an environment variable.  You own the return value.
-    pub fn pam_getenv(pamh: *mut pam_handle, name: *const c_char) -> *mut c_char;
+    pub fn pam_getenv(pamh: *const pam_handle, 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) -> *mut *mut c_char;
+    pub fn pam_getenvlist(pamh: *const pam_handle) -> *mut *mut c_char;
 
     /// Get information about the transaction.
     ///
     /// The item is owned by PAM.
     pub fn pam_get_item(
-        pamh: *mut pam_handle,
+        pamh: *const pam_handle,
         item_type: c_int,
         item: *mut *const c_void,
     ) -> c_int;
@@ -214,7 +210,12 @@
 // when it comes across the `cfg_pam_impl` macro.
 // This is a custom cfg variable set in our build.rs. Don't do this; just use
 // cfg_pam_impl.
-#[cfg(_private_pam_impl_hack = "LinuxPam")]
+#[cfg(any(_private_pam_impl_hack = "LinuxPam", _private_pam_impl_hack = "OpenPam"))]
 extern "C" {
-    pub fn pam_get_authtok(pamh: *mut pam_handle, x: c_int, token: *mut *const c_char, prompt: *const c_char) -> c_int;
+    pub fn pam_get_authtok(
+        pamh: *mut pam_handle,
+        x: c_int,
+        token: *mut *const c_char,
+        prompt: *const c_char,
+    ) -> c_int;
 }