# HG changeset patch # User Paul Fisher # Date 1749532599 14400 # Node ID a8f4718fed5d21185970e7d3e261f988b84faeca # Parent 5aa1a010f1e87bc79dad47e92ae6c856510ccdf8 When dynamically linking against the wrong PAM, fail. diff -r 5aa1a010f1e8 -r a8f4718fed5d build.rs --- a/build.rs Tue Jun 10 01:09:30 2025 -0400 +++ b/build.rs Tue Jun 10 01:16:39 2025 -0400 @@ -19,24 +19,36 @@ .dynamic_link_require_all(true) .default_macro_constant_type(MacroTypeVariation::Signed); - let linux_builder = common_builder.clone().header_contents( - "linux-pam.h", - r#" + let linux_builder = common_builder + .clone() + // This function is not available in OpenPAM. + // We don't use it, but we include it so that if the user + // tries to run this against the wrong PAM library, it fails. + .allowlist_function("pam_start_confdir") + .header_contents( + "linux-pam.h", + r#" #include #include #include #include "#, - ); - let openpam_builder = common_builder.clone().header_contents( - "openpam.h", - r#" + ); + let openpam_builder = common_builder + .clone() + // This function is not available in Linux-PAM. + // We don't use it, but we include it so that if the user + // tries to run this against the wrong PAM library, it fails. + .allowlist_function("pam_setenv") + .header_contents( + "openpam.h", + r#" #include #include #include #include "#, - ); + ); let (pam_impl, bindings) = { let bb = linux_builder.generate(); diff -r 5aa1a010f1e8 -r a8f4718fed5d src/libpam/pam_ffi.rs --- a/src/libpam/pam_ffi.rs Tue Jun 10 01:09:30 2025 -0400 +++ b/src/libpam/pam_ffi.rs Tue Jun 10 01:16:39 2025 -0400 @@ -3,9 +3,9 @@ #![allow(non_camel_case_types)] use crate::libpam::memory::Immovable; +use num_enum::{IntoPrimitive, TryFromPrimitive}; use std::ffi::{c_int, c_void}; use std::marker::PhantomData; -use num_enum::{IntoPrimitive, TryFromPrimitive}; /// An opaque structure that a PAM handle points to. #[repr(C)]