diff options
| author | Ben Fuhrmannek | 2016-02-18 13:35:20 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2016-02-18 13:35:20 +0100 |
| commit | eebffdb4e6fb1d62d64f3de96cfee62f39f8448e (patch) | |
| tree | bdf99f0996528f9266d3a5b84c19ee961bdfeb4a /suhosin7.c | |
| parent | 416f24c6164f6d147fae0d271936292b0ba89ed9 (diff) | |
(some) logging
Diffstat (limited to 'suhosin7.c')
| -rw-r--r-- | suhosin7.c | 61 |
1 files changed, 55 insertions, 6 deletions
| @@ -221,6 +221,28 @@ static ZEND_INI_MH(OnUpdateSuhosin_cookie_plainlist) | |||
| 221 | 221 | ||
| 222 | /* ------------------------------------------------------------------------ */ | 222 | /* ------------------------------------------------------------------------ */ |
| 223 | 223 | ||
| 224 | #define DEF_LOG_UPDATER(fname, varname, inistr) static ZEND_INI_MH(fname) \ | ||
| 225 | { \ | ||
| 226 | LOG_PERDIR_CHECK() \ | ||
| 227 | if (!new_value) { \ | ||
| 228 | SUHOSIN7_G(varname) = S_ALL & ~S_MEMORY; \ | ||
| 229 | } else { \ | ||
| 230 | if (is_numeric_string(ZSTR_VAL(new_value), ZSTR_LEN(new_value), NULL, NULL, 0) != IS_LONG) { \ | ||
| 231 | SUHOSIN7_G(varname) = S_ALL & ~S_MEMORY; \ | ||
| 232 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown constant in %s=%s", inistr, new_value); \ | ||
| 233 | return FAILURE; \ | ||
| 234 | } \ | ||
| 235 | SUHOSIN7_G(varname) = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) & (~S_MEMORY) & (~S_INTERNAL); \ | ||
| 236 | } \ | ||
| 237 | return SUCCESS; \ | ||
| 238 | } | ||
| 239 | |||
| 240 | DEF_LOG_UPDATER(OnUpdateSuhosin_log_file, log_file, "suhosin.log.file") | ||
| 241 | DEF_LOG_UPDATER(OnUpdateSuhosin_log_sapi, log_sapi, "suhosin.log.sapi") | ||
| 242 | DEF_LOG_UPDATER(OnUpdateSuhosin_log_stdout, log_stdout, "suhosin.log.stdout") | ||
| 243 | |||
| 244 | /* ------------------------------------------------------------------------ */ | ||
| 245 | |||
| 224 | #define STD_S7_INI_ENTRY(name, default_value, modifiable, on_modify, property_name) \ | 246 | #define STD_S7_INI_ENTRY(name, default_value, modifiable, on_modify, property_name) \ |
| 225 | STD_PHP_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, zend_suhosin7_globals, suhosin7_globals) | 247 | STD_PHP_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, zend_suhosin7_globals, suhosin7_globals) |
| 226 | #define STD_S7_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name) \ | 248 | #define STD_S7_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name) \ |
| @@ -239,16 +261,16 @@ PHP_INI_BEGIN() | |||
| 239 | // PHP_INI_ENTRY("suhosin.log.syslog", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_syslog) | 261 | // PHP_INI_ENTRY("suhosin.log.syslog", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_syslog) |
| 240 | // PHP_INI_ENTRY("suhosin.log.syslog.facility", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_syslog_facility) | 262 | // PHP_INI_ENTRY("suhosin.log.syslog.facility", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_syslog_facility) |
| 241 | // PHP_INI_ENTRY("suhosin.log.syslog.priority", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_syslog_priority) | 263 | // PHP_INI_ENTRY("suhosin.log.syslog.priority", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_syslog_priority) |
| 242 | // PHP_INI_ENTRY("suhosin.log.sapi", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_sapi) | 264 | PHP_INI_ENTRY("suhosin.log.sapi", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_sapi) |
| 243 | // PHP_INI_ENTRY("suhosin.log.stdout", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_stdout) | 265 | PHP_INI_ENTRY("suhosin.log.stdout", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_stdout) |
| 244 | // PHP_INI_ENTRY("suhosin.log.script", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_script) | 266 | // PHP_INI_ENTRY("suhosin.log.script", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_script) |
| 245 | // PHP_INI_ENTRY("suhosin.log.script.name", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_scriptname) | 267 | // PHP_INI_ENTRY("suhosin.log.script.name", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_scriptname) |
| 246 | // STD_S7_INI_BOOLEAN("suhosin.log.use-x-forwarded-for", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogBool, log_use_x_forwarded_for) | 268 | STD_S7_INI_BOOLEAN("suhosin.log.use-x-forwarded-for", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogBool, log_use_x_forwarded_for) |
| 247 | // PHP_INI_ENTRY("suhosin.log.phpscript", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_phpscript) | 269 | // PHP_INI_ENTRY("suhosin.log.phpscript", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_phpscript) |
| 248 | // STD_S7_INI_ENTRY("suhosin.log.phpscript.name", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogString, log_phpscriptname) | 270 | // STD_S7_INI_ENTRY("suhosin.log.phpscript.name", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogString, log_phpscriptname) |
| 249 | // PHP_INI_ENTRY("suhosin.log.file", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_file) | 271 | PHP_INI_ENTRY("suhosin.log.file", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateSuhosin_log_file) |
| 250 | // STD_S7_INI_ENTRY("suhosin.log.file.name", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogString, log_filename) | 272 | STD_S7_INI_ENTRY("suhosin.log.file.name", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogString, log_filename) |
| 251 | // STD_S7_INI_BOOLEAN("suhosin.log.file.time", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogBool, log_file_time) | 273 | STD_S7_INI_BOOLEAN("suhosin.log.file.time", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogBool, log_file_time) |
| 252 | // STD_S7_INI_BOOLEAN("suhosin.log.phpscript.is_safe", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogBool, log_phpscript_is_safe) | 274 | // STD_S7_INI_BOOLEAN("suhosin.log.phpscript.is_safe", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLogBool, log_phpscript_is_safe) |
| 253 | 275 | ||
| 254 | // STD_S7_INI_ENTRY("suhosin.executor.include.max_traversal", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateExecLong, executor_include_max_traversal) | 276 | // STD_S7_INI_ENTRY("suhosin.executor.include.max_traversal", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateExecLong, executor_include_max_traversal) |
| @@ -375,6 +397,33 @@ PHP_INI_BEGIN() | |||
| 375 | PHP_INI_END() | 397 | PHP_INI_END() |
| 376 | /* }}} */ | 398 | /* }}} */ |
| 377 | 399 | ||
| 400 | /* {{{ suhosin_getenv | ||
| 401 | */ | ||
| 402 | char *suhosin_getenv(char *name, size_t name_len) | ||
| 403 | { | ||
| 404 | if (sapi_module.getenv) { | ||
| 405 | char *value, *tmp = sapi_module.getenv(name, name_len); | ||
| 406 | if (tmp) { | ||
| 407 | value = estrdup(tmp); | ||
| 408 | } else { | ||
| 409 | return NULL; | ||
| 410 | } | ||
| 411 | return value; | ||
| 412 | } else { | ||
| 413 | /* fallback to the system's getenv() function */ | ||
| 414 | char *tmp; | ||
| 415 | |||
| 416 | name = estrndup(name, name_len); | ||
| 417 | tmp = getenv(name); | ||
| 418 | efree(name); | ||
| 419 | if (tmp) { | ||
| 420 | return estrdup(tmp); | ||
| 421 | } | ||
| 422 | } | ||
| 423 | return NULL; | ||
| 424 | } | ||
| 425 | /* }}} */ | ||
| 426 | |||
| 378 | 427 | ||
| 379 | 428 | ||
| 380 | /* {{{ php_suhosin7_init_globals | 429 | /* {{{ php_suhosin7_init_globals |
