Skip to content

Commit

Permalink
Fix compilation with non-Linux PAM on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
pkern committed Jun 20, 2024
1 parent fe679ae commit e8211a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion login/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 <security/pam_ext.h>')
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,
Expand Down
11 changes: 10 additions & 1 deletion login/pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
#include <errno.h>
#include <limits.h>
#include <openssl/crypto.h>
#include <security/pam_ext.h>
#include <security/pam_modules.h>
#ifdef PAM_GLOME_LINUX
# include <security/pam_ext.h>
#else
# include <security/pam_appl.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
Expand All @@ -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)
Expand Down

0 comments on commit e8211a2

Please sign in to comment.