From 816f6a53d02945e7e13a0df8db5203a7355856e7 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 10 Mar 2024 11:12:54 +0100 Subject: [PATCH] Find AppArmor library with pkgconf (#13644) The AppArmor library has had pkg-config/pkgconf integration since its early versions (2012), when it was integrated from the libaalogparse into the AppArmor project. To ease this change, the check without pkgconf is executed in case the libapparmor.pc file is not found on the system. A sanity check also covers cases where the library path is overriden: /configure --enable-fpm --with-fpm-apparmor \ APPARMOR_CFLAGS=-I/path/to/libapparmor \ APPARMOR_LIBS="-L/path/to/libapparmor -lapparmor" This also removes the redundant symbol HAVE_SYS_APPARMOR_H since the sys/apparmor.h header is considered a required part of the AppArmor library package. --- sapi/fpm/config.m4 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index de3b72120e0..ecf2a26fd46 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -515,13 +515,21 @@ if test "$PHP_FPM" != "no"; then fi if test "x$PHP_FPM_APPARMOR" != "xno" ; then - AC_CHECK_HEADERS([sys/apparmor.h]) - AC_CHECK_LIB(apparmor, aa_change_profile, [ - PHP_ADD_LIBRARY(apparmor) - AC_DEFINE(HAVE_APPARMOR, 1, [ AppArmor confinement available ]) - ],[ - AC_MSG_ERROR(libapparmor required but not found) - ]) + PKG_CHECK_MODULES([APPARMOR], [libapparmor], [ + PHP_EVAL_LIBLINE([$APPARMOR_LIBS]) + PHP_EVAL_INCLINE([$APPARMOR_CFLAGS]) + ], + [AC_CHECK_LIB([apparmor], [aa_change_profile], + [PHP_ADD_LIBRARY([apparmor])], + [AC_MSG_ERROR([libapparmor required but not found.])])]) + + dnl Sanity check. + CFLAGS_save="$CFLAGS" + CFLAGS="$INCLUDES $CFLAGS" + AC_CHECK_HEADER([sys/apparmor.h], + [AC_DEFINE([HAVE_APPARMOR], [1], [AppArmor confinement available])], + [AC_MSG_ERROR([Required sys/apparmor.h not found.])]) + CFLAGS="$CFLAGS_save" fi if test "x$PHP_FPM_SELINUX" != "xno" ; then