diff options
| author | Ben Fuhrmannek | 2016-10-12 14:57:47 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2016-10-12 14:57:47 +0200 |
| commit | 1a3fd5eeb9a5859aefedb9302adb6ecd6a1873a7 (patch) | |
| tree | a8925768de344632ec89e051a3c71a3c7c61ffd3 /log.c | |
| parent | 2e4fbdbdd8ff3b1d1a0edb579392506ef3ed98e2 (diff) | |
comments and whitespace cleanup
Diffstat (limited to 'log.c')
| -rw-r--r-- | log.c | 73 |
1 files changed, 35 insertions, 38 deletions
| @@ -17,9 +17,6 @@ | |||
| 17 | | Ben Fuhrmannek <ben.fuhrmannek@sektioneins.de> | | 17 | | Ben Fuhrmannek <ben.fuhrmannek@sektioneins.de> | |
| 18 | +----------------------------------------------------------------------+ | 18 | +----------------------------------------------------------------------+ |
| 19 | */ | 19 | */ |
| 20 | /* | ||
| 21 | $Id: log.c,v 1.1.1.1 2007-11-28 01:15:35 sesser Exp $ | ||
| 22 | */ | ||
| 23 | 20 | ||
| 24 | #ifdef HAVE_CONFIG_H | 21 | #ifdef HAVE_CONFIG_H |
| 25 | #include "config.h" | 22 | #include "config.h" |
| @@ -82,7 +79,7 @@ static HANDLE log_source = 0; | |||
| 82 | // case S_VARS: | 79 | // case S_VARS: |
| 83 | // return "VARS"; | 80 | // return "VARS"; |
| 84 | // default: | 81 | // default: |
| 85 | // return "UNKNOWN"; | 82 | // return "UNKNOWN"; |
| 86 | // } | 83 | // } |
| 87 | // } | 84 | // } |
| 88 | 85 | ||
| @@ -129,7 +126,7 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) | |||
| 129 | volatile unsigned int *x = 0; | 126 | volatile unsigned int *x = 0; |
| 130 | volatile int y = *x; | 127 | volatile int y = *x; |
| 131 | } | 128 | } |
| 132 | 129 | ||
| 133 | if (SUHOSIN7_G(log_use_x_forwarded_for)) { | 130 | if (SUHOSIN7_G(log_use_x_forwarded_for)) { |
| 134 | ip_address = suhosin_getenv("HTTP_X_FORWARDED_FOR", 20); | 131 | ip_address = suhosin_getenv("HTTP_X_FORWARDED_FOR", 20); |
| 135 | if (ip_address == NULL) { | 132 | if (ip_address == NULL) { |
| @@ -141,8 +138,8 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) | |||
| 141 | ip_address = "REMOTE_ADDR not set"; | 138 | ip_address = "REMOTE_ADDR not set"; |
| 142 | } | 139 | } |
| 143 | } | 140 | } |
| 144 | 141 | ||
| 145 | 142 | ||
| 146 | va_start(ap, fmt); | 143 | va_start(ap, fmt); |
| 147 | ap_php_vsnprintf(error, sizeof(error), fmt, ap); | 144 | ap_php_vsnprintf(error, sizeof(error), fmt, ap); |
| 148 | va_end(ap); | 145 | va_end(ap); |
| @@ -150,13 +147,13 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) | |||
| 150 | if (error[i] < 32) error[i] = '.'; | 147 | if (error[i] < 32) error[i] = '.'; |
| 151 | i++; | 148 | i++; |
| 152 | } | 149 | } |
| 153 | 150 | ||
| 154 | if (SUHOSIN7_G(simulation)) { | 151 | if (SUHOSIN7_G(simulation)) { |
| 155 | alertstring = "ALERT-SIMULATION"; | 152 | alertstring = "ALERT-SIMULATION"; |
| 156 | } else { | 153 | } else { |
| 157 | alertstring = "ALERT"; | 154 | alertstring = "ALERT"; |
| 158 | } | 155 | } |
| 159 | 156 | ||
| 160 | if (zend_is_executing()) { | 157 | if (zend_is_executing()) { |
| 161 | // zend_execute_data *exdata = EG(current_execute_data); | 158 | // zend_execute_data *exdata = EG(current_execute_data); |
| 162 | // if (exdata) { | 159 | // if (exdata) { |
| @@ -182,25 +179,25 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) | |||
| 182 | } | 179 | } |
| 183 | ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s')", alertstring, error, ip_address, fname); | 180 | ap_php_snprintf(buf, sizeof(buf), "%s - %s (attacker '%s', file '%s')", alertstring, error, ip_address, fname); |
| 184 | } | 181 | } |
| 185 | 182 | ||
| 186 | /* Syslog-Logging disabled? */ | 183 | /* Syslog-Logging disabled? */ |
| 187 | // if (((SUHOSIN7_G(log_syslog)|S_INTERNAL) & loglevel)==0) { | 184 | // if (((SUHOSIN7_G(log_syslog)|S_INTERNAL) & loglevel)==0) { |
| 188 | // goto log_file; | 185 | // goto log_file; |
| 189 | // } | 186 | // } |
| 190 | // | 187 | // |
| 191 | // #if defined(AF_UNIX) | 188 | // #if defined(AF_UNIX) |
| 192 | // ap_php_snprintf(error, sizeof(error), "<%u>suhosin[%u]: %s\n", (unsigned int)(SUHOSIN7_G(log_syslog_facility)|SUHOSIN7_G(log_syslog_priority)),getpid(),buf); | 189 | // ap_php_snprintf(error, sizeof(error), "<%u>suhosin[%u]: %s\n", (unsigned int)(SUHOSIN7_G(log_syslog_facility)|SUHOSIN7_G(log_syslog_priority)),getpid(),buf); |
| 193 | // | 190 | // |
| 194 | // s = socket(AF_UNIX, SOCK_DGRAM, 0); | 191 | // s = socket(AF_UNIX, SOCK_DGRAM, 0); |
| 195 | // if (s == -1) { | 192 | // if (s == -1) { |
| 196 | // goto log_file; | 193 | // goto log_file; |
| 197 | // } | 194 | // } |
| 198 | // | 195 | // |
| 199 | // memset(&saun, 0, sizeof(saun)); | 196 | // memset(&saun, 0, sizeof(saun)); |
| 200 | // saun.sun_family = AF_UNIX; | 197 | // saun.sun_family = AF_UNIX; |
| 201 | // strcpy(saun.sun_path, SYSLOG_PATH); | 198 | // strcpy(saun.sun_path, SYSLOG_PATH); |
| 202 | // /*saun.sun_len = sizeof(saun);*/ | 199 | // /*saun.sun_len = sizeof(saun);*/ |
| 203 | // | 200 | // |
| 204 | // r = connect(s, (struct sockaddr *)&saun, sizeof(saun)); | 201 | // r = connect(s, (struct sockaddr *)&saun, sizeof(saun)); |
| 205 | // if (r) { | 202 | // if (r) { |
| 206 | // close(s); | 203 | // close(s); |
| @@ -208,25 +205,25 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) | |||
| 208 | // if (s == -1) { | 205 | // if (s == -1) { |
| 209 | // goto log_file; | 206 | // goto log_file; |
| 210 | // } | 207 | // } |
| 211 | // | 208 | // |
| 212 | // memset(&saun, 0, sizeof(saun)); | 209 | // memset(&saun, 0, sizeof(saun)); |
| 213 | // saun.sun_family = AF_UNIX; | 210 | // saun.sun_family = AF_UNIX; |
| 214 | // strcpy(saun.sun_path, SYSLOG_PATH); | 211 | // strcpy(saun.sun_path, SYSLOG_PATH); |
| 215 | // /*saun.sun_len = sizeof(saun);*/ | 212 | // /*saun.sun_len = sizeof(saun);*/ |
| 216 | // | 213 | // |
| 217 | // r = connect(s, (struct sockaddr *)&saun, sizeof(saun)); | 214 | // r = connect(s, (struct sockaddr *)&saun, sizeof(saun)); |
| 218 | // if (r) { | 215 | // if (r) { |
| 219 | // close(s); | 216 | // close(s); |
| 220 | // goto log_file; | 217 | // goto log_file; |
| 221 | // } | 218 | // } |
| 222 | // } | 219 | // } |
| 223 | // send(s, error, strlen(error), 0); | 220 | // send(s, error, strlen(error), 0); |
| 224 | // | 221 | // |
| 225 | // close(s); | 222 | // close(s); |
| 226 | // #endif | 223 | // #endif |
| 227 | // #ifdef PHP_WIN32 | 224 | // #ifdef PHP_WIN32 |
| 228 | // ap_php_snprintf(error, sizeof(error), "suhosin[%u]: %s", getpid(),buf); | 225 | // ap_php_snprintf(error, sizeof(error), "suhosin[%u]: %s", getpid(),buf); |
| 229 | // | 226 | // |
| 230 | // switch (SUHOSIN7_G(log_syslog_priority)) { /* translate UNIX type into NT type */ | 227 | // switch (SUHOSIN7_G(log_syslog_priority)) { /* translate UNIX type into NT type */ |
| 231 | // case 1: /*LOG_ALERT:*/ | 228 | // case 1: /*LOG_ALERT:*/ |
| 232 | // etype = EVENTLOG_ERROR_TYPE; | 229 | // etype = EVENTLOG_ERROR_TYPE; |
| @@ -244,14 +241,14 @@ SUHOSIN7_API void suhosin_log(int loglevel, char *fmt, ...) | |||
| 244 | // log_source = RegisterEventSource(NULL, "Suhosin-" SUHOSIN_EXT_VERSION); | 241 | // log_source = RegisterEventSource(NULL, "Suhosin-" SUHOSIN_EXT_VERSION); |
| 245 | // } | 242 | // } |
| 246 | // ReportEvent(log_source, etype, (unsigned short) SUHOSIN7_G(log_syslog_priority), evid, NULL, 1, 0, strs, NULL); | 243 | // ReportEvent(log_source, etype, (unsigned short) SUHOSIN7_G(log_syslog_priority), evid, NULL, 1, 0, strs, NULL); |
| 247 | // | 244 | // |
| 248 | // #endif | 245 | // #endif |
| 249 | log_file: | 246 | log_file: |
| 250 | /* File-Logging disabled? */ | 247 | /* File-Logging disabled? */ |
| 251 | if ((SUHOSIN7_G(log_file) & loglevel)==0) { | 248 | if ((SUHOSIN7_G(log_file) & loglevel)==0) { |
| 252 | goto log_sapi; | 249 | goto log_sapi; |
| 253 | } | 250 | } |
| 254 | 251 | ||
| 255 | if (!SUHOSIN7_G(log_filename) || !SUHOSIN7_G(log_filename)[0]) { | 252 | if (!SUHOSIN7_G(log_filename) || !SUHOSIN7_G(log_filename)[0]) { |
| 256 | goto log_sapi; | 253 | goto log_sapi; |
| 257 | } | 254 | } |
| @@ -300,20 +297,20 @@ log_sapi: | |||
| 300 | // FILE *in; | 297 | // FILE *in; |
| 301 | // int space; | 298 | // int space; |
| 302 | // struct stat st; | 299 | // struct stat st; |
| 303 | // | 300 | // |
| 304 | // char *sname = SUHOSIN7_G(log_scriptname); | 301 | // char *sname = SUHOSIN7_G(log_scriptname); |
| 305 | // while (isspace(*sname)) ++sname; | 302 | // while (isspace(*sname)) ++sname; |
| 306 | // if (*sname == 0) goto log_phpscript; | 303 | // if (*sname == 0) goto log_phpscript; |
| 307 | // | 304 | // |
| 308 | // if (VCWD_STAT(sname, &st) < 0) { | 305 | // if (VCWD_STAT(sname, &st) < 0) { |
| 309 | // suhosin_log(S_INTERNAL, "unable to find logging shell script %s - file dropped", sname); | 306 | // suhosin_log(S_INTERNAL, "unable to find logging shell script %s - file dropped", sname); |
| 310 | // goto log_phpscript; | 307 | // goto log_phpscript; |
| 311 | // } | 308 | // } |
| 312 | // if (access(sname, X_OK|R_OK) < 0) { | 309 | // if (access(sname, X_OK|R_OK) < 0) { |
| 313 | // suhosin_log(S_INTERNAL, "logging shell script %s is not executable - file dropped", sname); | 310 | // suhosin_log(S_INTERNAL, "logging shell script %s is not executable - file dropped", sname); |
| 314 | // goto log_phpscript; | 311 | // goto log_phpscript; |
| 315 | // } | 312 | // } |
| 316 | // | 313 | // |
| 317 | // /* TODO: clean up this code to calculate size of output dynamically */ | 314 | // /* TODO: clean up this code to calculate size of output dynamically */ |
| 318 | // ap_php_snprintf(cmd, sizeof(cmd) - 20, "%s %s \'", sname, loglevel2string(loglevel)); | 315 | // ap_php_snprintf(cmd, sizeof(cmd) - 20, "%s %s \'", sname, loglevel2string(loglevel)); |
| 319 | // space = sizeof(cmd) - strlen(cmd) - 20; | 316 | // space = sizeof(cmd) - strlen(cmd) - 20; |
| @@ -341,7 +338,7 @@ log_sapi: | |||
| 341 | // *cmdpos++ = '&'; | 338 | // *cmdpos++ = '&'; |
| 342 | // *cmdpos++ = '1'; | 339 | // *cmdpos++ = '1'; |
| 343 | // *cmdpos = 0; | 340 | // *cmdpos = 0; |
| 344 | // | 341 | // |
| 345 | // if ((in=VCWD_POPEN(cmd, "r"))==NULL) { | 342 | // if ((in=VCWD_POPEN(cmd, "r"))==NULL) { |
| 346 | // suhosin_log(S_INTERNAL, "Unable to execute logging shell script: %s", sname); | 343 | // suhosin_log(S_INTERNAL, "Unable to execute logging shell script: %s", sname); |
| 347 | // goto log_phpscript; | 344 | // goto log_phpscript; |
| @@ -366,10 +363,10 @@ log_sapi: | |||
| 366 | // zend_file_handle file_handle; | 363 | // zend_file_handle file_handle; |
| 367 | // zend_op_array *new_op_array; | 364 | // zend_op_array *new_op_array; |
| 368 | // zval *result = NULL; | 365 | // zval *result = NULL; |
| 369 | // | 366 | // |
| 370 | // long orig_execution_depth = SUHOSIN7_G(execution_depth); | 367 | // long orig_execution_depth = SUHOSIN7_G(execution_depth); |
| 371 | // char *orig_basedir = PG(open_basedir); | 368 | // char *orig_basedir = PG(open_basedir); |
| 372 | // | 369 | // |
| 373 | // char *phpscript = SUHOSIN7_G(log_phpscriptname); | 370 | // char *phpscript = SUHOSIN7_G(log_phpscriptname); |
| 374 | // SDEBUG("scriptname %s", SUHOSIN7_G(log_phpscriptname)); | 371 | // SDEBUG("scriptname %s", SUHOSIN7_G(log_phpscriptname)); |
| 375 | // if (zend_stream_open(phpscript, &file_handle) == SUCCESS) { | 372 | // if (zend_stream_open(phpscript, &file_handle) == SUCCESS) { |
| @@ -381,34 +378,34 @@ log_sapi: | |||
| 381 | // if (new_op_array) { | 378 | // if (new_op_array) { |
| 382 | // HashTable *active_symbol_table = EG(active_symbol_table); | 379 | // HashTable *active_symbol_table = EG(active_symbol_table); |
| 383 | // zval *zerror, *zerror_class; | 380 | // zval *zerror, *zerror_class; |
| 384 | // | 381 | // |
| 385 | // if (active_symbol_table == NULL) { | 382 | // if (active_symbol_table == NULL) { |
| 386 | // active_symbol_table = &EG(symbol_table); | 383 | // active_symbol_table = &EG(symbol_table); |
| 387 | // } | 384 | // } |
| 388 | // EG(return_value_ptr_ptr) = &result; | 385 | // EG(return_value_ptr_ptr) = &result; |
| 389 | // EG(active_op_array) = new_op_array; | 386 | // EG(active_op_array) = new_op_array; |
| 390 | // | 387 | // |
| 391 | // MAKE_STD_ZVAL(zerror); | 388 | // MAKE_STD_ZVAL(zerror); |
| 392 | // MAKE_STD_ZVAL(zerror_class); | 389 | // MAKE_STD_ZVAL(zerror_class); |
| 393 | // ZVAL_STRING(zerror, buf, 1); | 390 | // ZVAL_STRING(zerror, buf, 1); |
| 394 | // ZVAL_LONG(zerror_class, loglevel); | 391 | // ZVAL_LONG(zerror_class, loglevel); |
| 395 | // | 392 | // |
| 396 | // zend_hash_update(active_symbol_table, "SUHOSIN_ERROR", sizeof("SUHOSIN_ERROR"), (void **)&zerror, sizeof(zval *), NULL); | 393 | // zend_hash_update(active_symbol_table, "SUHOSIN_ERROR", sizeof("SUHOSIN_ERROR"), (void **)&zerror, sizeof(zval *), NULL); |
| 397 | // zend_hash_update(active_symbol_table, "SUHOSIN_ERRORCLASS", sizeof("SUHOSIN_ERRORCLASS"), (void **)&zerror_class, sizeof(zval *), NULL); | 394 | // zend_hash_update(active_symbol_table, "SUHOSIN_ERRORCLASS", sizeof("SUHOSIN_ERRORCLASS"), (void **)&zerror_class, sizeof(zval *), NULL); |
| 398 | // | 395 | // |
| 399 | // SUHOSIN7_G(execution_depth) = 0; | 396 | // SUHOSIN7_G(execution_depth) = 0; |
| 400 | // if (SUHOSIN7_G(log_phpscript_is_safe)) { | 397 | // if (SUHOSIN7_G(log_phpscript_is_safe)) { |
| 401 | // PG(open_basedir) = NULL; | 398 | // PG(open_basedir) = NULL; |
| 402 | // } | 399 | // } |
| 403 | // | 400 | // |
| 404 | // zend_execute(new_op_array); | 401 | // zend_execute(new_op_array); |
| 405 | // | 402 | // |
| 406 | // SUHOSIN7_G(execution_depth) = orig_execution_depth; | 403 | // SUHOSIN7_G(execution_depth) = orig_execution_depth; |
| 407 | // PG(open_basedir) = orig_basedir; | 404 | // PG(open_basedir) = orig_basedir; |
| 408 | // | 405 | // |
| 409 | // destroy_op_array(new_op_array); | 406 | // destroy_op_array(new_op_array); |
| 410 | // efree(new_op_array); | 407 | // efree(new_op_array); |
| 411 | // | 408 | // |
| 412 | // if (!EG(exception)) | 409 | // if (!EG(exception)) |
| 413 | // { | 410 | // { |
| 414 | // if (EG(return_value_ptr_ptr)) { | 411 | // if (EG(return_value_ptr_ptr)) { |
| @@ -425,7 +422,7 @@ log_sapi: | |||
| 425 | // return; | 422 | // return; |
| 426 | // } | 423 | // } |
| 427 | // } | 424 | // } |
| 428 | // | 425 | // |
| 429 | } | 426 | } |
| 430 | 427 | ||
| 431 | 428 | ||
