Skip to content

Commit 586a0dd

Browse files
authored
Find SELinux library with pkgconf (#13645)
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.
1 parent d2635b1 commit 586a0dd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

sapi/fpm/config.m4

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,21 @@ if test "$PHP_FPM" != "no"; then
533533
fi
534534

535535
if test "x$PHP_FPM_SELINUX" != "xno" ; then
536-
AC_CHECK_HEADERS([selinux/selinux.h])
537-
AC_CHECK_LIB(selinux, security_setenforce, [
538-
PHP_ADD_LIBRARY(selinux)
539-
AC_DEFINE(HAVE_SELINUX, 1, [ SElinux available ])
540-
],[])
536+
PKG_CHECK_MODULES([SELINUX], [libselinux], [
537+
PHP_EVAL_LIBLINE([$SELINUX_LIBS])
538+
PHP_EVAL_INCLINE([$SELINUX_CFLAGS])
539+
],
540+
[AC_CHECK_LIB([selinux], [security_setenforce],
541+
[PHP_ADD_LIBRARY([selinux])],
542+
[AC_MSG_ERROR([Required SELinux library not found.])])])
543+
544+
dnl Sanity check.
545+
CFLAGS_save="$CFLAGS"
546+
CFLAGS="$INCLUDES $CFLAGS"
547+
AC_CHECK_HEADER([selinux/selinux.h],
548+
[AC_DEFINE([HAVE_SELINUX], [1], [Whether SELinux is available.])],
549+
[AC_MSG_ERROR([Required selinux/selinux.h not found.])])
550+
CFLAGS="$CFLAGS_save"
541551
fi
542552

543553
PHP_SUBST_OLD(php_fpm_systemd)

0 commit comments

Comments
 (0)