diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index a4e5a38f90d89..140b900a3c89d 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -19,6 +19,7 @@ #include "zend_extensions.h" #include "zend_system_id.h" +#include "SAPI.h" ZEND_API zend_llist zend_extensions; ZEND_API uint32_t zend_extension_flags = 0; diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 3b2278d545637..ec461a029ff3a 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -165,7 +165,11 @@ # if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT) # define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT) # elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer) -# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND) +# if defined(LM_ID_NEWLM) +# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | ((sapi_module.flags & SAPI_MODULE_FLAG_ISOLATE_SYMBOLS) != 0 ? RTLD_DEEPBIND : 0)) +# else +# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND) +# endif # else # define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL) # endif diff --git a/main/SAPI.h b/main/SAPI.h index 284f4cb96f1fa..0ff632738c8bd 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -234,6 +234,8 @@ SAPI_API double sapi_get_request_time(void); SAPI_API void sapi_terminate_process(void); END_EXTERN_C() +#define SAPI_MODULE_FLAG_ISOLATE_SYMBOLS (1<<0) + struct _sapi_module_struct { char *name; char *pretty_name; @@ -287,6 +289,8 @@ struct _sapi_module_struct { const char *ini_entries; const zend_function_entry *additional_functions; unsigned int (*input_filter_init)(void); + + unsigned int flags; }; struct _sapi_post_entry { @@ -321,22 +325,25 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data); SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter); END_EXTERN_C() -#define STANDARD_SAPI_MODULE_PROPERTIES \ - NULL, /* php_ini_path_override */ \ - NULL, /* default_post_reader */ \ - NULL, /* treat_data */ \ - NULL, /* executable_location */ \ - 0, /* php_ini_ignore */ \ - 0, /* php_ini_ignore_cwd */ \ - NULL, /* get_fd */ \ - NULL, /* force_http_10 */ \ - NULL, /* get_target_uid */ \ - NULL, /* get_target_gid */ \ - NULL, /* input_filter */ \ - NULL, /* ini_defaults */ \ - 0, /* phpinfo_as_text; */ \ - NULL, /* ini_entries; */ \ - NULL, /* additional_functions */ \ - NULL /* input_filter_init */ +#define STANDARD_SAPI_MODULE_PROPERTIES STANDARD_SAPI_MODULE_PROPERTIES_WITH_FLAGS(0) + +#define STANDARD_SAPI_MODULE_PROPERTIES_WITH_FLAGS(_flags) \ + NULL, /* php_ini_path_override */ \ + NULL, /* default_post_reader */ \ + NULL, /* treat_data */ \ + NULL, /* executable_location */ \ + 0, /* php_ini_ignore */ \ + 0, /* php_ini_ignore_cwd */ \ + NULL, /* get_fd */ \ + NULL, /* force_http_10 */ \ + NULL, /* get_target_uid */ \ + NULL, /* get_target_gid */ \ + NULL, /* input_filter */ \ + NULL, /* ini_defaults */ \ + 0, /* phpinfo_as_text; */ \ + NULL, /* ini_entries; */ \ + NULL, /* additional_functions */ \ + NULL, /* input_filter_init */ \ + (_flags) /* flags */ #endif /* SAPI_H */ diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 1d85a92ebf4d8..73c10b8f792a6 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -415,7 +415,7 @@ static sapi_module_struct apache2_sapi_module = { php_apache_sapi_get_request_time, /* Request Time */ NULL, /* Child Terminate */ - STANDARD_SAPI_MODULE_PROPERTIES + STANDARD_SAPI_MODULE_PROPERTIES_WITH_FLAGS(SAPI_MODULE_FLAG_ISOLATE_SYMBOLS) }; static apr_status_t php_apache_server_shutdown(void *tmp) diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index ce97f0bbe9dc7..eec81507de3ea 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -93,6 +93,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #include +#include "main/SAPI.h" struct lsapi_MD5Context { uint32 buf[4]; diff --git a/sapi/litespeed/lscriu.c b/sapi/litespeed/lscriu.c index 409fe989b5551..05b122cc57633 100644 --- a/sapi/litespeed/lscriu.c +++ b/sapi/litespeed/lscriu.c @@ -85,6 +85,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "lscriu.h" #include +#include "main/SAPI.h" #define LSCRIU_PATH 256 diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 92c139fa52abe..88ea4b65858a8 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -19,6 +19,7 @@ #include #include #include "zend.h" +#include "main/SAPI.h" #include "zend_compile.h" #include "zend_exceptions.h" #include "zend_vm.h"