diff options
| author | xXx-caillou-xXx | 2018-08-30 15:02:22 +0200 |
|---|---|---|
| committer | jvoisin | 2018-08-30 13:02:22 +0000 |
| commit | b3f67a16094168cc334f5da93a86f09476e01601 (patch) | |
| tree | de533b00c850ba1b64173a1d777f366a12f098df /src/snuffleupagus.c | |
| parent | f61a4772bfc33e08e7b06250e2f0f640bcae875f (diff) | |
Change how we're handling invalid configurations
Since our configuration format is a bit more complex than php's one,
we have a `sp.allow_broken_configuration` parameter (`false` by default),
that you can set to `true` if you want PHP to carry on if your Snuffleupagus'
configuration contains syntax errors. You'll still get a big scary message in
your logs of course. We do **not** recommend to use it of course, but sometimes
it might be useful to be able to "debug in production" without breaking your
website.
Diffstat (limited to 'src/snuffleupagus.c')
| -rw-r--r-- | src/snuffleupagus.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index 5ef8323..4fee81a 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c | |||
| @@ -34,9 +34,21 @@ static inline void sp_op_array_handler(zend_op_array *op) { | |||
| 34 | 34 | ||
| 35 | ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) | 35 | ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) |
| 36 | 36 | ||
| 37 | static PHP_INI_MH(StrictMode) { | ||
| 38 | TSRMLS_FETCH(); | ||
| 39 | |||
| 40 | SNUFFLEUPAGUS_G(allow_broken_configuration) = false; | ||
| 41 | if (new_value && zend_string_equals_literal(new_value, "1")) { | ||
| 42 | SNUFFLEUPAGUS_G(allow_broken_configuration) = true; | ||
| 43 | } | ||
| 44 | return SUCCESS; | ||
| 45 | } | ||
| 46 | |||
| 37 | PHP_INI_BEGIN() | 47 | PHP_INI_BEGIN() |
| 38 | PHP_INI_ENTRY("sp.configuration_file", "", PHP_INI_SYSTEM, | 48 | PHP_INI_ENTRY("sp.configuration_file", "", PHP_INI_SYSTEM, |
| 39 | OnUpdateConfiguration) | 49 | OnUpdateConfiguration) |
| 50 | PHP_INI_ENTRY("sp.allow_broken_configuration", "0", PHP_INI_SYSTEM, | ||
| 51 | StrictMode) | ||
| 40 | PHP_INI_END() | 52 | PHP_INI_END() |
| 41 | 53 | ||
| 42 | void free_disabled_functions_hashtable(HashTable *ht) { | 54 | void free_disabled_functions_hashtable(HashTable *ht) { |
| @@ -181,6 +193,10 @@ PHP_RINIT_FUNCTION(snuffleupagus) { | |||
| 181 | ZEND_TSRMLS_CACHE_UPDATE(); | 193 | ZEND_TSRMLS_CACHE_UPDATE(); |
| 182 | #endif | 194 | #endif |
| 183 | 195 | ||
| 196 | if (!SNUFFLEUPAGUS_G(allow_broken_configuration) && !SNUFFLEUPAGUS_G(is_config_valid)) { | ||
| 197 | sp_log_err("config", "Invalid configuration file"); | ||
| 198 | } | ||
| 199 | |||
| 184 | // We need to disable wrappers loaded by extensions loaded after SNUFFLEUPAGUS. | 200 | // We need to disable wrappers loaded by extensions loaded after SNUFFLEUPAGUS. |
| 185 | if (SNUFFLEUPAGUS_G(config).config_wrapper->enabled && | 201 | if (SNUFFLEUPAGUS_G(config).config_wrapper->enabled && |
| 186 | zend_hash_num_elements(php_stream_get_url_stream_wrappers_hash()) != | 202 | zend_hash_num_elements(php_stream_get_url_stream_wrappers_hash()) != |
