From a64b7cd4eb3ef036416b5cf6fa784d3ad1a538e3 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Wed, 6 Mar 2024 06:18:12 +0100 Subject: [PATCH 1/2] Simplify FPM ACL check 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 | 50 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 51de63df75a80..592a77b3f9704 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -489,50 +489,24 @@ 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) - { - acl_t acl; + 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); 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; - } - ]])], [ - 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_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 + acl_free(acl);])], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_FPM_ACL], [1], [Whether FPM has acl support])], + [AC_MSG_RESULT([no]) + LIBS="$LIBS_save"])], + [LIBS="$LIBS_save"]) fi if test "x$PHP_FPM_APPARMOR" != "xno" ; then From 3a23f7221d4e422574c22f52b3bd83c1256a008c Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 7 Mar 2024 06:40:34 +0100 Subject: [PATCH 2/2] Fix CS and remove redundant LIBS variable restore --- sapi/fpm/config.m4 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 592a77b3f9704..f1c02727ca124 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -491,22 +491,25 @@ if test "$PHP_FPM" != "no"; then 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; + 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); 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);])], - [AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_FPM_ACL], [1], [Whether FPM has acl support])], - [AC_MSG_RESULT([no]) - LIBS="$LIBS_save"])], - [LIBS="$LIBS_save"]) + acl_free(acl); + ])], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_FPM_ACL], [1], [Whether FPM has acl support]) + ], [ + AC_MSG_RESULT([no]) + LIBS="$LIBS_save" + ]) + ]) fi if test "x$PHP_FPM_APPARMOR" != "xno" ; then