From d371f35e3a26463b724c72dd4e456be87c3fc33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 30 Aug 2024 17:33:44 +0200 Subject: [PATCH] build: Check for openpam headers usability Ensure that openpam headers can be used, we might even just checked for the openpam_version.h header, but this respects more the real world scenario --- meson.build | 33 +++++++++++++++++++++++++-------- pam/pam_fprintd.c | 2 ++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index d926548..76405ec 100644 --- a/meson.build +++ b/meson.build @@ -91,18 +91,35 @@ gmodule_dep = dependency('gmodule-2.0', version: '>=' + glib_min_version) libfprint_dep = dependency('libfprint-2', version: '>=' + libfprint_min_version) polkit_gobject_dep = dependency('polkit-gobject-1', version: '>= 0.91') dbus_dep = dependency('dbus-1', required: false) -libsystemd_dep = dependency(get_option('libsystemd'), required: get_option('pam')) -pam_dep = cc.find_library('pam', - required: get_option('pam'), - has_headers: 'security/pam_modules.h', -) -# Check if the PAM implementation is OpenPAM instead of linux-pam -has_openpam = cc.check_header('security/openpam.h', required: false) +if get_option('pam') + libsystemd_dep = dependency(get_option('libsystemd'), required: true) + + has_openpam = false + pam_dep = cc.find_library('pam', + required: true, + has_headers: 'security/pam_modules.h', + ) + + # Check if the PAM implementation is OpenPAM instead of linux-pam + if host_machine.system().endswith('bsd') or host_machine.system() == 'dragonfly' + has_openpam = cc.compiles(''' + #include + #include + int main(void) { return 0; } + ''', + dependencies: pam_dep, + name: 'openpam', + ) + assert(has_openpam) + endif +endif if host_machine.system() == 'linux' or host_machine.system() == 'gnu' gettext_deps = [] -elif host_machine.system() == 'freebsd' or host_machine.system() == 'openbsd' or host_machine.system() == 'dragonfly' +elif (host_machine.system() == 'freebsd' or + host_machine.system() == 'openbsd' or + host_machine.system() == 'dragonfly') gettext_deps = [cc.find_library('intl', dirs: ['/usr/local/lib'])] elif host_machine.system() == 'netbsd' gettext_deps = [cc.find_library('intl', dirs: ['/usr/pkg/lib'])] diff --git a/pam/pam_fprintd.c b/pam/pam_fprintd.c index f5d856a..93cade9 100644 --- a/pam/pam_fprintd.c +++ b/pam/pam_fprintd.c @@ -58,6 +58,8 @@ #else /* defined (FPRINTD_PAM_USE_OPENPAM) */ +#include + #define pam_syslog(H, C, ...) \ syslog (C, __VA_ARGS__)