diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,19 @@ ) endif() +# Handle different PAM header styles: +# - "Linux style" has pam_ext.h +# - "BSD style" has pam_appl.h +# +find_file(PAM_EXT_PATH security/pam_ext.h) +find_file(PAM_APPL_PATH security/pam_appl.h) +if (PAM_EXT_PATH) + add_definitions(-DHAVE_PAM_EXT) +endif() +if (PAM_APPL_PATH) + add_definitions(-DHAVE_PAM_APPL) +endif() + add_library (${library_name} SHARED ${pam_kwallet_SRCS}) set_target_properties (${library_name} PROPERTIES PREFIX "") target_link_libraries (${library_name} diff --git a/pam_kwallet.c b/pam_kwallet.c --- a/pam_kwallet.c +++ b/pam_kwallet.c @@ -31,17 +31,37 @@ #include #include #include +#include +#include +#include + +/* PAM headers. + * + * There are three styles in play: + * - Apple, which has no pam_ext.h, does have pam_appl.h, does have pam_syslog + * - Linux, which has pam_ext.h, does have pam_appl.h, does have pam_syslog + * - BSD, which has no pam_ext.h, does have pam_appl.h, but no pam_syslog + * In the latter case, #define pam_syslog away. + */ #ifdef __APPLE__ #include "pam_darwin.h" #include #else #include +#ifdef HAVE_PAM_EXT +/* "Linux style" */ #include #include #endif -#include -#include -#include +#ifdef HAVE_PAM_APPL +/* "BSD style" .. see also __APPLE__, above */ +#include +#ifndef HAVE_PAM_EXT +/* FreeBSD has no pam_syslog(), va-macro it away */ +#define pam_syslog(...) +#endif +#endif +#endif #define KWALLET_PAM_KEYSIZE 56 #define KWALLET_PAM_SALTSIZE 56