diff options
| author | Ben Fuhrmannek | 2021-11-19 16:47:08 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-11-19 16:47:08 +0100 |
| commit | 0462573a7678468b19bc4865c75f7b82dbedbe03 (patch) | |
| tree | 2300593bcde4ecf2af3ac315270736f9e18ae3fb /src | |
| parent | c447df6ce8964b2863a50f0f8027d9b234b7507f (diff) | |
added old php version check
Diffstat (limited to 'src')
| -rw-r--r-- | src/php_snuffleupagus.h | 1 | ||||
| -rw-r--r-- | src/snuffleupagus.c | 13 | ||||
| -rw-r--r-- | src/sp_config.h | 1 | ||||
| -rw-r--r-- | src/sp_config_keywords.c | 3 | ||||
| -rw-r--r-- | src/tests/broken_configuration/config/broken_conf_enable_disable2.ini | 1 | ||||
| -rw-r--r-- | src/tests/broken_configuration_php8/broken_conf_enable_disable2.phpt | 5 |
6 files changed, 18 insertions, 6 deletions
diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index 03c9bb6..8fcbd58 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h | |||
| @@ -127,6 +127,7 @@ bool config_server_encode; | |||
| 127 | bool config_server_strip; | 127 | bool config_server_strip; |
| 128 | zend_string *config_encryption_key; | 128 | zend_string *config_encryption_key; |
| 129 | zend_string *config_cookies_env_var; | 129 | zend_string *config_cookies_env_var; |
| 130 | bool config_show_old_php_warning; | ||
| 130 | 131 | ||
| 131 | HashTable *config_disabled_functions; | 132 | HashTable *config_disabled_functions; |
| 132 | HashTable *config_disabled_functions_hooked; | 133 | HashTable *config_disabled_functions_hooked; |
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index c96a911..e3ecd72 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c | |||
| @@ -276,6 +276,9 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 276 | return FAILURE; | 276 | return FAILURE; |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | // set some defaults | ||
| 280 | SPCFG(show_old_php_warning) = true; | ||
| 281 | |||
| 279 | char *str = new_value->val; | 282 | char *str = new_value->val; |
| 280 | 283 | ||
| 281 | while (1) { | 284 | while (1) { |
| @@ -365,6 +368,16 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 365 | (SPCFG(disabled_functions) && zend_hash_num_elements(SPCFG(disabled_functions))) || | 368 | (SPCFG(disabled_functions) && zend_hash_num_elements(SPCFG(disabled_functions))) || |
| 366 | (SPCFG(disabled_functions) && zend_hash_num_elements(SPCFG(disabled_functions_ret))); | 369 | (SPCFG(disabled_functions) && zend_hash_num_elements(SPCFG(disabled_functions_ret))); |
| 367 | 370 | ||
| 371 | if (SPCFG(show_old_php_warning)) { | ||
| 372 | time_t ts = time(NULL); | ||
| 373 | sp_log_debug("foo"); | ||
| 374 | if (PHP_VERSION_ID < 70300 || | ||
| 375 | PHP_VERSION_ID < 70400 && ts >= (time_t)1638745200L || | ||
| 376 | PHP_VERSION_ID < 80000 && ts >= (time_t)1669590000L || | ||
| 377 | PHP_VERSION_ID < 80100 && ts >= (time_t)1700953200L) { | ||
| 378 | sp_log_warn("End-of-Life Check", "Your PHP version '" PHP_VERSION "' is not officially mainained anymore. Please upgrade as soon as possible."); | ||
| 379 | } | ||
| 380 | } | ||
| 368 | return SUCCESS; | 381 | return SUCCESS; |
| 369 | } | 382 | } |
| 370 | 383 | ||
diff --git a/src/sp_config.h b/src/sp_config.h index a557105..1a891c1 100644 --- a/src/sp_config.h +++ b/src/sp_config.h | |||
| @@ -262,6 +262,7 @@ typedef struct { | |||
| 262 | #define SP_TOKEN_SERVER_STRIP "server_strip" | 262 | #define SP_TOKEN_SERVER_STRIP "server_strip" |
| 263 | #define SP_TOKEN_SID_MIN_LENGTH "sid_min_length" | 263 | #define SP_TOKEN_SID_MIN_LENGTH "sid_min_length" |
| 264 | #define SP_TOKEN_SID_MAX_LENGTH "sid_max_length" | 264 | #define SP_TOKEN_SID_MAX_LENGTH "sid_max_length" |
| 265 | #define SP_TOKEN_SHOW_OLD_PHP_WARNING "show_old_php_warning" | ||
| 265 | 266 | ||
| 266 | // upload_validator | 267 | // upload_validator |
| 267 | #define SP_TOKEN_UPLOAD_SCRIPT "script" | 268 | #define SP_TOKEN_UPLOAD_SCRIPT "script" |
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index cf44ed9..cbe4966 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | #define SP_SET_ENABLE_DISABLE(enable, disable, varname) \ | 3 | #define SP_SET_ENABLE_DISABLE(enable, disable, varname) \ |
| 4 | if (((varname) || enable) && disable) { \ | 4 | if (enable && disable) { \ |
| 5 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", parsed_rule->lineno); \ | 5 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", parsed_rule->lineno); \ |
| 6 | return SP_PARSER_ERROR; \ | 6 | return SP_PARSER_ERROR; \ |
| 7 | } \ | 7 | } \ |
| @@ -133,6 +133,7 @@ SP_PARSE_FN(parse_global) { | |||
| 133 | {parse_ulong, SP_TOKEN_MAX_EXECUTION_DEPTH, &(SPCFG(max_execution_depth))}, | 133 | {parse_ulong, SP_TOKEN_MAX_EXECUTION_DEPTH, &(SPCFG(max_execution_depth))}, |
| 134 | {parse_enable, SP_TOKEN_SERVER_ENCODE, &(SPCFG(server_encode))}, | 134 | {parse_enable, SP_TOKEN_SERVER_ENCODE, &(SPCFG(server_encode))}, |
| 135 | {parse_enable, SP_TOKEN_SERVER_STRIP, &(SPCFG(server_strip))}, | 135 | {parse_enable, SP_TOKEN_SERVER_STRIP, &(SPCFG(server_strip))}, |
| 136 | {parse_enable, SP_TOKEN_SHOW_OLD_PHP_WARNING, &(SPCFG(show_old_php_warning))}, | ||
| 136 | {0, 0, 0}}; | 137 | {0, 0, 0}}; |
| 137 | 138 | ||
| 138 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); | 139 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
diff --git a/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini b/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini index 39d97cc..7ed0c16 100644 --- a/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini +++ b/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini | |||
| @@ -1,2 +1,3 @@ | |||
| 1 | sp.global_strict.enable(); | 1 | sp.global_strict.enable(); |
| 2 | sp.global_strict.disable(); | 2 | sp.global_strict.disable(); |
| 3 | ;; this is actually not recognised as broken, as there is no internal third state for 'unset' | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_enable_disable2.phpt b/src/tests/broken_configuration_php8/broken_conf_enable_disable2.phpt index efe5538..2446663 100644 --- a/src/tests/broken_configuration_php8/broken_conf_enable_disable2.phpt +++ b/src/tests/broken_configuration_php8/broken_conf_enable_disable2.phpt | |||
| @@ -7,8 +7,3 @@ Global strict mode | |||
| 7 | sp.configuration_file={PWD}/../broken_configuration/config/broken_conf_enable_disable2.ini | 7 | sp.configuration_file={PWD}/../broken_configuration/config/broken_conf_enable_disable2.ini |
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 2 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
