pam: Cleanup non-linux codepaths

This commit is contained in:
Marco Trevisan (Treviño) 2024-08-30 13:36:13 +02:00
parent 8d4e3e6fb7
commit b9e55394e9
3 changed files with 19 additions and 21 deletions

View file

@ -96,8 +96,9 @@ 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')
has_openpam = cc.check_header('security/openpam.h', required: false)
if host_machine.system() == 'linux' or host_machine.system() == 'gnu'
gettext_deps = []

View file

@ -20,8 +20,9 @@ pam_fprintd = shared_module('pam_fprintd',
],
c_args: [
'-DLOCALEDIR="@0@"'.format(localedir),
] + (libsystemd_dep.name() == 'basu' ? ['-DFPRINTD_PAM_USE_BASU'] : [])
+ (has_openpam ? ['-DFPRINTD_PAM_USE_OPENPAM'] : []),
libsystemd_dep.name() == 'basu' ? ['-DFPRINTD_PAM_USE_BASU'] : [],
has_openpam ? ['-DFPRINTD_PAM_USE_OPENPAM'] : [],
],
link_args: [
'-Wl,--version-script,@0@/@1@'.format(meson.source_root(), mapfile[0]),
'-Wl,--unresolved-symbols=report-all',

View file

@ -50,10 +50,18 @@
#define PAM_SM_AUTH
#include <security/pam_modules.h>
#include <security/pam_appl.h>
#if defined(FPRINTD_PAM_USE_OPENPAM)
#define pam_syslog(H, C, ...) syslog (C, __VA_ARGS__)
#else
#ifndef FPRINTD_PAM_USE_OPENPAM
#include <security/pam_ext.h>
#define FPRINTD_PAM_INCOMPLETE PAM_INCOMPLETE
#else /* defined (FPRINTD_PAM_USE_OPENPAM) */
#define pam_syslog(H, C, ...) \
syslog (C, __VA_ARGS__)
#define FPRINTD_PAM_INCOMPLETE PAM_CONV_ERR
#endif
#define _(s) ((char *) dgettext (GETTEXT_PACKAGE, s))
@ -475,11 +483,7 @@ do_verify (sd_bus *bus,
data->timed_out = false;
data->verify_started = false;
#if defined(FPRINTD_PAM_USE_OPENPAM)
data->verify_ret = PAM_CONV_ERR;
#else
data->verify_ret = PAM_INCOMPLETE;
#endif
data->verify_ret = FPRINTD_PAM_INCOMPLETE;
free (data->result);
data->result = NULL;
@ -530,11 +534,7 @@ do_verify (sd_bus *bus,
r = sd_bus_process (bus, NULL);
if (r < 0)
break;
#if defined(FPRINTD_PAM_USE_OPENPAM)
if (data->verify_ret != PAM_CONV_ERR)
#else
if (data->verify_ret != PAM_INCOMPLETE)
#endif
if (data->verify_ret != FPRINTD_PAM_INCOMPLETE)
break;
if (!data->verify_started)
continue;
@ -571,11 +571,7 @@ do_verify (sd_bus *bus,
}
}
#if defined(FPRINTD_PAM_USE_OPENPAM)
if (data->verify_ret != PAM_CONV_ERR)
#else
if (data->verify_ret != PAM_INCOMPLETE)
#endif
if (data->verify_ret != FPRINTD_PAM_INCOMPLETE)
return data->verify_ret;
if (now () >= verification_end)