Skip to content

Commit 816f6a5

Browse files
authored
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.
1 parent 539d8d9 commit 816f6a5

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

sapi/fpm/config.m4

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,21 @@ if test "$PHP_FPM" != "no"; then
515515
fi
516516

517517
if test "x$PHP_FPM_APPARMOR" != "xno" ; then
518-
AC_CHECK_HEADERS([sys/apparmor.h])
519-
AC_CHECK_LIB(apparmor, aa_change_profile, [
520-
PHP_ADD_LIBRARY(apparmor)
521-
AC_DEFINE(HAVE_APPARMOR, 1, [ AppArmor confinement available ])
522-
],[
523-
AC_MSG_ERROR(libapparmor required but not found)
524-
])
518+
PKG_CHECK_MODULES([APPARMOR], [libapparmor], [
519+
PHP_EVAL_LIBLINE([$APPARMOR_LIBS])
520+
PHP_EVAL_INCLINE([$APPARMOR_CFLAGS])
521+
],
522+
[AC_CHECK_LIB([apparmor], [aa_change_profile],
523+
[PHP_ADD_LIBRARY([apparmor])],
524+
[AC_MSG_ERROR([libapparmor required but not found.])])])
525+
526+
dnl Sanity check.
527+
CFLAGS_save="$CFLAGS"
528+
CFLAGS="$INCLUDES $CFLAGS"
529+
AC_CHECK_HEADER([sys/apparmor.h],
530+
[AC_DEFINE([HAVE_APPARMOR], [1], [AppArmor confinement available])],
531+
[AC_MSG_ERROR([Required sys/apparmor.h not found.])])
532+
CFLAGS="$CFLAGS_save"
525533
fi
526534

527535
if test "x$PHP_FPM_SELINUX" != "xno" ; then

0 commit comments

Comments
 (0)