From e8211a205bb4ec100fb39a38c2e7d1fe54d5324e Mon Sep 17 00:00:00 2001 From: Philipp Kern Date: Thu, 20 Jun 2024 22:12:27 +0200 Subject: [PATCH] Fix compilation with non-Linux PAM on macOS --- login/meson.build | 11 ++++++++++- login/pam.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/login/meson.build b/login/meson.build index faa5bf2..8d3de9e 100644 --- a/login/meson.build +++ b/login/meson.build @@ -72,9 +72,18 @@ endif if get_option('pam-glome') cc = meson.get_compiler('c') libpam = cc.find_library('pam') + + args = ['-DPAM_GLOME'] + pam_ext_present = cc.has_function('pam_syslog', + dependencies: libpam, + prefix: '#include ') + if pam_ext_present + args += ['-DPAM_GLOME_LINUX'] + endif + pam_glome = shared_library( 'pam_glome', ['pam.c', 'login.c'], - c_args : '-DPAM_GLOME', + c_args : args, dependencies : [libpam, openssl_dep], link_with : [glome_lib, login_lib], include_directories : glome_incdir, diff --git a/login/pam.c b/login/pam.c index 3622fbe..59eaf72 100644 --- a/login/pam.c +++ b/login/pam.c @@ -15,8 +15,12 @@ #include #include #include -#include #include +#ifdef PAM_GLOME_LINUX +# include +#else +# include +#endif #include #include #include @@ -29,6 +33,11 @@ #define MODULE_NAME "pam_glome" +#ifndef PAM_GLOME_LINUX +void pam_syslog(void *pamh, ...) { (void)(pamh); } +void pam_vsyslog(void *pamh, ...) { (void)(pamh); } +#endif + #define MAX_ERROR_MESSAGE_SIZE 4095 #define UNUSED(var) (void)(var)