diff options
| author | Ben Fuhrmannek | 2021-02-16 11:16:59 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-02-16 11:16:59 +0100 |
| commit | 5484bcb5eb2714e7438927e2566c86a74d7c51af (patch) | |
| tree | b78326d2999397be4c08e06b23209981f82a4ea9 /src/snuffleupagus.c | |
| parent | 7ac1e3866ef4f146c6c93a5ca13b9aebb14e936a (diff) | |
| parent | cecfdd808da67be908dbe7144cc8c74dfb3f855e (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/snuffleupagus.c')
| -rw-r--r-- | src/snuffleupagus.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index d62069c..9a5ac90 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c | |||
| @@ -22,10 +22,13 @@ ZEND_DLEXPORT int sp_zend_startup(zend_extension *extension) { | |||
| 22 | // LCOV_EXCL_END | 22 | // LCOV_EXCL_END |
| 23 | 23 | ||
| 24 | static inline void sp_op_array_handler(zend_op_array *op) { | 24 | static inline void sp_op_array_handler(zend_op_array *op) { |
| 25 | if (NULL == op->filename) { | 25 | // We need a filename, and strict mode not already enabled on this op |
| 26 | if (NULL == op->filename || op->fn_flags & ZEND_ACC_STRICT_TYPES) { | ||
| 26 | return; | 27 | return; |
| 27 | } else { | 28 | } else { |
| 28 | op->fn_flags |= ZEND_ACC_STRICT_TYPES; | 29 | if (true == SNUFFLEUPAGUS_G(config).config_global_strict->enable) { |
| 30 | op->fn_flags |= ZEND_ACC_STRICT_TYPES; | ||
| 31 | } | ||
| 29 | } | 32 | } |
| 30 | } | 33 | } |
| 31 | 34 | ||
| @@ -59,7 +62,7 @@ ZEND_DLEXPORT zend_extension zend_extension_entry = { | |||
| 59 | NULL, /* activate_func_t */ | 62 | NULL, /* activate_func_t */ |
| 60 | NULL, /* deactivate_func_t */ | 63 | NULL, /* deactivate_func_t */ |
| 61 | NULL, /* message_handler_func_t */ | 64 | NULL, /* message_handler_func_t */ |
| 62 | sp_op_array_handler, // zend_global_strict, /* op_array_handler_func_t */ | 65 | sp_op_array_handler, /* op_array_handler_func_t */ |
| 63 | NULL, /* statement_handler_func_t */ | 66 | NULL, /* statement_handler_func_t */ |
| 64 | NULL, /* fcall_begin_handler_func_t */ | 67 | NULL, /* fcall_begin_handler_func_t */ |
| 65 | NULL, /* fcall_end_handler_func_t */ | 68 | NULL, /* fcall_end_handler_func_t */ |
| @@ -68,6 +71,7 @@ ZEND_DLEXPORT zend_extension zend_extension_entry = { | |||
| 68 | STANDARD_ZEND_EXTENSION_PROPERTIES}; | 71 | STANDARD_ZEND_EXTENSION_PROPERTIES}; |
| 69 | 72 | ||
| 70 | PHP_GINIT_FUNCTION(snuffleupagus) { | 73 | PHP_GINIT_FUNCTION(snuffleupagus) { |
| 74 | snuffleupagus_globals->is_config_valid = SP_CONFIG_NONE; | ||
| 71 | snuffleupagus_globals->in_eval = 0; | 75 | snuffleupagus_globals->in_eval = 0; |
| 72 | 76 | ||
| 73 | #define SP_INIT_HT(F) snuffleupagus_globals->F = \ | 77 | #define SP_INIT_HT(F) snuffleupagus_globals->F = \ |
| @@ -186,8 +190,12 @@ PHP_RINIT_FUNCTION(snuffleupagus) { | |||
| 186 | ZEND_TSRMLS_CACHE_UPDATE(); | 190 | ZEND_TSRMLS_CACHE_UPDATE(); |
| 187 | #endif | 191 | #endif |
| 188 | 192 | ||
| 189 | if (!SNUFFLEUPAGUS_G(allow_broken_configuration) && !SNUFFLEUPAGUS_G(is_config_valid)) { | 193 | if (!SNUFFLEUPAGUS_G(allow_broken_configuration)) { |
| 190 | sp_log_err("config", "Invalid configuration file"); | 194 | if (SNUFFLEUPAGUS_G(is_config_valid) == SP_CONFIG_INVALID ) { |
| 195 | sp_log_err("config", "Invalid configuration file"); | ||
| 196 | } else if (SNUFFLEUPAGUS_G(is_config_valid) == SP_CONFIG_NONE) { | ||
| 197 | sp_log_warn("config", "No configuration specificed via sp.configuration_file"); | ||
| 198 | } | ||
| 191 | } | 199 | } |
| 192 | 200 | ||
| 193 | // We need to disable wrappers loaded by extensions loaded after SNUFFLEUPAGUS. | 201 | // We need to disable wrappers loaded by extensions loaded after SNUFFLEUPAGUS. |
| @@ -209,12 +217,23 @@ PHP_RINIT_FUNCTION(snuffleupagus) { | |||
| 209 | PHP_RSHUTDOWN_FUNCTION(snuffleupagus) { return SUCCESS; } | 217 | PHP_RSHUTDOWN_FUNCTION(snuffleupagus) { return SUCCESS; } |
| 210 | 218 | ||
| 211 | PHP_MINFO_FUNCTION(snuffleupagus) { | 219 | PHP_MINFO_FUNCTION(snuffleupagus) { |
| 220 | const char *valid_config; | ||
| 221 | switch(SNUFFLEUPAGUS_G(is_config_valid)) { | ||
| 222 | case SP_CONFIG_VALID: | ||
| 223 | valid_config = "yes"; | ||
| 224 | break; | ||
| 225 | case SP_CONFIG_INVALID: | ||
| 226 | valid_config = "invalid"; | ||
| 227 | break; | ||
| 228 | case SP_CONFIG_NONE: | ||
| 229 | default: | ||
| 230 | valid_config = "no"; | ||
| 231 | } | ||
| 212 | php_info_print_table_start(); | 232 | php_info_print_table_start(); |
| 213 | php_info_print_table_row(2, "snuffleupagus support", "enabled"); | 233 | php_info_print_table_row(2, "snuffleupagus support", |
| 234 | SNUFFLEUPAGUS_G(is_config_valid)?"enabled":"disabled"); | ||
| 214 | php_info_print_table_row(2, "Version", PHP_SNUFFLEUPAGUS_VERSION); | 235 | php_info_print_table_row(2, "Version", PHP_SNUFFLEUPAGUS_VERSION); |
| 215 | php_info_print_table_row( | 236 | php_info_print_table_row( 2, "Valid config", valid_config); |
| 216 | 2, "Valid config", | ||
| 217 | (SNUFFLEUPAGUS_G(is_config_valid) == true) ? "yes" : "no"); | ||
| 218 | php_info_print_table_end(); | 237 | php_info_print_table_end(); |
| 219 | DISPLAY_INI_ENTRIES(); | 238 | DISPLAY_INI_ENTRIES(); |
| 220 | } | 239 | } |
| @@ -234,14 +253,14 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 234 | int ret = glob(config_file, GLOB_NOCHECK, NULL, &globbuf); | 253 | int ret = glob(config_file, GLOB_NOCHECK, NULL, &globbuf); |
| 235 | 254 | ||
| 236 | if (ret != 0) { | 255 | if (ret != 0) { |
| 237 | SNUFFLEUPAGUS_G(is_config_valid) = false; | 256 | SNUFFLEUPAGUS_G(is_config_valid) = SP_CONFIG_INVALID; |
| 238 | globfree(&globbuf); | 257 | globfree(&globbuf); |
| 239 | return FAILURE; | 258 | return FAILURE; |
| 240 | } | 259 | } |
| 241 | 260 | ||
| 242 | for (size_t i = 0; globbuf.gl_pathv[i]; i++) { | 261 | for (size_t i = 0; globbuf.gl_pathv[i]; i++) { |
| 243 | if (sp_parse_config(globbuf.gl_pathv[i]) != SUCCESS) { | 262 | if (sp_parse_config(globbuf.gl_pathv[i]) != SUCCESS) { |
| 244 | SNUFFLEUPAGUS_G(is_config_valid) = false; | 263 | SNUFFLEUPAGUS_G(is_config_valid) = SP_CONFIG_INVALID; |
| 245 | globfree(&globbuf); | 264 | globfree(&globbuf); |
| 246 | return FAILURE; | 265 | return FAILURE; |
| 247 | } | 266 | } |
| @@ -249,7 +268,7 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 249 | globfree(&globbuf); | 268 | globfree(&globbuf); |
| 250 | } | 269 | } |
| 251 | 270 | ||
| 252 | SNUFFLEUPAGUS_G(is_config_valid) = true; | 271 | SNUFFLEUPAGUS_G(is_config_valid) = SP_CONFIG_VALID; |
| 253 | 272 | ||
| 254 | if ((SNUFFLEUPAGUS_G(config).config_sloppy->enable)) { | 273 | if ((SNUFFLEUPAGUS_G(config).config_sloppy->enable)) { |
| 255 | hook_sloppy(); | 274 | hook_sloppy(); |
