From 7407e8326fdeda36d6623283386d24886125fb4f Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 9 Mar 2024 02:46:32 +0100 Subject: [PATCH 1/2] Find SELinux library with pkgconf The SELinux library has had pkg-config/pkgconf integration since ~2009. To ease this change, the check without pkgconf is executed in case the libselinux.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-selinux \ SELINUX_CFLAGS=-I/path/to/libselinux \ SELINUX_LIBS="-L/path/to/libselinux -lselinux" This also removes the redundant symbol HAVE_SELINUX_SELINUX_H since the selinux/selinux.h header is considered a required part of the SELinux library package. --- sapi/fpm/config.m4 | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index de3b72120e04..54ff0b9df03e 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -525,11 +525,21 @@ if test "$PHP_FPM" != "no"; then fi if test "x$PHP_FPM_SELINUX" != "xno" ; then - AC_CHECK_HEADERS([selinux/selinux.h]) - AC_CHECK_LIB(selinux, security_setenforce, [ - PHP_ADD_LIBRARY(selinux) - AC_DEFINE(HAVE_SELINUX, 1, [ SElinux available ]) - ],[]) + PKG_CHECK_MODULES([SELINUX], [selinux], [ + PHP_EVAL_LIBLINE([$SELINUX_LIBS]) + PHP_EVAL_INCLINE([$SELINUX_CFLAGS]) + ], + [AC_CHECK_LIB([selinux], [security_setenforce], + [PHP_ADD_LIBRARY([selinux])], + [AC_MSG_ERROR([Required SELinux library not found.])])]) + + dnl Sanity check. + CFLAGS_save="$CFLAGS" + CFLAGS="$INCLUDES $CFLAGS" + AC_CHECK_HEADER([selinux/selinux.h], + [AC_DEFINE([HAVE_SELINUX], [1], [Whether SELinux is available.])], + [AC_MSG_ERROR([Required selinux/selinux.h not found.])]) + CFLAGS="$CFLAGS_save" fi PHP_SUBST_OLD(php_fpm_systemd) From 59431701781492dd77e15ea2290e1e1a829922da Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 9 Mar 2024 03:07:28 +0100 Subject: [PATCH 2/2] Fix typo - s/selinux/libselinux/ --- sapi/fpm/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 54ff0b9df03e..bb7ede4d399d 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -525,7 +525,7 @@ if test "$PHP_FPM" != "no"; then fi if test "x$PHP_FPM_SELINUX" != "xno" ; then - PKG_CHECK_MODULES([SELINUX], [selinux], [ + PKG_CHECK_MODULES([SELINUX], [libselinux], [ PHP_EVAL_LIBLINE([$SELINUX_LIBS]) PHP_EVAL_INCLINE([$SELINUX_CFLAGS]) ],