From 1dfba4273f7e6230477882764bd95038b16c458b Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 8 Mar 2024 20:38:31 +0100 Subject: [PATCH] Simplify FPM ACL check (#13604) Instead of running the user/group permissions check (unknown when cross-compiling), check with linking (AC_LINK_IFELSE) can be sufficient to test if ACL_USER and ACL_GROUP are available (missing on macOS). The AC_SEARCH_LIBS is used to test the ACL availability in c or acl library. --- sapi/fpm/config.m4 | 47 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 1173fdb1e69..de3b72120e0 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -491,9 +491,11 @@ if test "$PHP_FPM" != "no"; then if test "$PHP_FPM_ACL" != "no" ; then AC_CHECK_HEADERS([sys/acl.h]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include - int main(void) - { + dnl *BSD has acl_* built into libc, macOS doesn't have user/group support. + LIBS_save="$LIBS" + AC_SEARCH_LIBS([acl_free], [acl], [ + AC_MSG_CHECKING([for acl user/group permissions support]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [ acl_t acl; acl_entry_t user, group; acl = acl_init(1); @@ -502,39 +504,14 @@ if test "$PHP_FPM" != "no"; then acl_create_entry(&acl, &group); acl_set_tag_type(user, ACL_GROUP); acl_free(acl); - return 0; - } - ]])], [ - AC_CHECK_LIB(acl, acl_free, - [PHP_ADD_LIBRARY(acl) - have_fpm_acl=yes - ],[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[#include - int main(void) - { - acl_t acl; - acl_entry_t user, group; - acl = acl_init(1); - acl_create_entry(&acl, &user); - acl_set_tag_type(user, ACL_USER); - acl_create_entry(&acl, &group); - acl_set_tag_type(user, ACL_GROUP); - acl_free(acl); - return 0; - } - ]])],[have_fpm_acl=yes],[have_fpm_acl=no],[have_fpm_acl=no]) - ]) - ], [ - have_fpm_acl=no + ])], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_FPM_ACL], [1], [Whether FPM has acl support]) + ], [ + AC_MSG_RESULT([no]) + LIBS="$LIBS_save" + ]) ]) - - AC_MSG_CHECKING([for acl user/group permissions support]) - if test "$have_fpm_acl" = "yes"; then - AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_FPM_ACL], 1, [do we have acl support?]) - else - AC_MSG_RESULT([no]) - fi fi if test "x$PHP_FPM_APPARMOR" != "xno" ; then