meson: use pkg-config to find audit

The previous checks were wrong, because when building statically,
cap-ng would have to be linked for the audit_log_user_avc_message
check to succeed.  Rather than duplicating this knowledge in dbus,
though, let's take advantage of audit.pc.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
This commit is contained in:
Alyssa Ross 2026-05-18 18:24:24 +02:00
parent 4f5796a37d
commit 76218a30ef
No known key found for this signature in database
GPG key ID: 9975DC24B77D6915

View file

@ -601,14 +601,9 @@ config.set_quoted('DBUS_CONSOLE_OWNER_FILE', console_owner_file)
if get_option('libaudit').disabled()
have_libaudit = false
else
libaudit = cc.find_library('audit', required: false)
libaudit_ok = cc.has_function('audit_log_user_avc_message', dependencies: libaudit)
cap_ng = cc.find_library('cap-ng', required: false)
cap_ng_ok = cc.has_function('capng_clear', dependencies: cap_ng)
have_libaudit = libaudit_ok and cap_ng_ok
if get_option('libaudit').enabled() and not have_libaudit
error('libaudit support requested but not found')
endif
libaudit = dependency('audit', required: get_option('libaudit'))
cap_ng = dependency('libcap-ng', required: get_option('libaudit'))
have_libaudit = libaudit.found() and cap_ng.found()
# For the systemd system unit
data_config.set('AMBIENT_CAPS', 'AmbientCapabilities=CAP_AUDIT_WRITE')
endif