Skip to content

Commit 40cdc5f

Browse files
orlitzkybukka
authored andcommitted
sapi/fpm/config.m4: add a new --with-fpm-apparmor configure flag.
The existing AC_FPM_APPARMOR macro (which is always run when FPM is enabled) checks for the existence of libapparmor, and adds it to $LIBS if found. The result is an "automagic" dependency on libapparmor that depends not only on the user's configuration, but also on the build host's environment. In particular, this can cause problems if the user just happens to have libapparmor installed (for testing or development) when he builds PHP. Later, he may remove libapparmor, not realizing that PHP depends on it. At that point, FPM will cease to work due to the missing library. This commit adds a new configure flag called "--with-fpm-apparmor", defaulting to "no", that enables or disables the feature. The new flag is used to signal the user's intent; whether or not he wants to use AppArmor. If he does, then we still check for the existence and usability of libapparmor; however, it is now an error for the library to be missing when --with-fpm-apparmor is requested. Gentoo-bug: https://bugs.gentoo.org/637402 PHP-bug: https://bugs.php.net/bug.php?id=75519
1 parent 6bc375f commit 40cdc5f

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

sapi/fpm/config.m4

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -488,22 +488,6 @@ AC_DEFUN([AC_FPM_SELECT],
488488
])
489489
])
490490

491-
AC_DEFUN([AC_FPM_APPARMOR],
492-
[
493-
AC_MSG_CHECKING([for apparmor])
494-
495-
SAVED_LIBS="$LIBS"
496-
LIBS="$LIBS -lapparmor"
497-
498-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/apparmor.h>]], [[change_hat("test", 0);]])], [
499-
AC_DEFINE([HAVE_APPARMOR], 1, [do we have apparmor support?])
500-
AC_MSG_RESULT([yes])
501-
], [
502-
LIBS="$SAVED_LIBS"
503-
AC_MSG_RESULT([no])
504-
])
505-
])
506-
507491
AC_MSG_CHECKING(for FPM build)
508492
if test "$PHP_FPM" != "no"; then
509493
AC_MSG_RESULT($PHP_FPM)
@@ -521,7 +505,6 @@ if test "$PHP_FPM" != "no"; then
521505
AC_FPM_DEVPOLL
522506
AC_FPM_EPOLL
523507
AC_FPM_SELECT
524-
AC_FPM_APPARMOR
525508

526509
PHP_ARG_WITH([fpm-user],,
527510
[AS_HELP_STRING([[--with-fpm-user[=USER]]],
@@ -548,6 +531,12 @@ if test "$PHP_FPM" != "no"; then
548531
[no],
549532
[no])
550533

534+
PHP_ARG_WITH([fpm-apparmor],,
535+
[AS_HELP_STRING([--with-fpm-apparmor],
536+
[Support AppArmor confinement through libapparmor])],
537+
[no],
538+
[no])
539+
551540
if test "$PHP_FPM_SYSTEMD" != "no" ; then
552541
PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209])
553542

@@ -580,6 +569,16 @@ if test "$PHP_FPM" != "no"; then
580569
])
581570
fi
582571

572+
if test "x$PHP_FPM_APPARMOR" != "xno" ; then
573+
AC_CHECK_HEADERS([sys/apparmor.h])
574+
AC_CHECK_LIB(apparmor, change_hat, [
575+
PHP_ADD_LIBRARY(apparmor)
576+
AC_DEFINE(HAVE_APPARMOR, 1, [ AppArmor confinement available ])
577+
],[
578+
AC_MSG_ERROR(libapparmor required but not found)
579+
])
580+
fi
581+
583582
PHP_SUBST_OLD(php_fpm_systemd)
584583
AC_DEFINE_UNQUOTED(PHP_FPM_SYSTEMD, "$php_fpm_systemd", [fpm systemd service type])
585584

0 commit comments

Comments
 (0)