# --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: package/.../nginx/nginx_syslog_patch-1.2.7-update.diff # Copyright (C) 2013 The OpenSDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- SDE-COPYRIGHT-NOTE-END --- Patch for the nginx syslog patch to apply on top of nginx 1.2.7 --- a/syslog_1.2.0.patch 2013-02-19 13:11:40.181033986 +0100 +++ b/syslog_1.2.0.patch 2013-02-19 13:37:24.432836273 +0100 @@ -1,5 +1,5 @@ diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c -index 2da0bf9..5d2c77a 100644 +index dc4dc89..46c4b4f 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -85,6 +85,12 @@ ngx_init_cycle(ngx_cycle_t *old_cycle) @@ -16,7 +16,7 @@ cycle->conf_prefix.len = old_cycle->conf_prefix.len; diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c -index d7830fb..b0a9733 100644 +index d7830fb..39bfa91 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -10,6 +10,15 @@ @@ -169,12 +169,10 @@ { return; } -@@ -365,6 +454,50 @@ ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name) - +@@ -366,6 +455,49 @@ ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name) return log; } -+ -+ + +#if (NGX_ENABLE_SYSLOG) +ngx_int_t +ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority) @@ -183,7 +181,7 @@ + ngx_uint_t n, match = 0; + + for (n = 0; ngx_syslog_priorities[n].name.len != 0; n++) { -+ if (ngx_strncmp(priority->data, ngx_syslog_priorities[n].name.data, ++ if (ngx_strncmp(priority->data, ngx_syslog_priorities[n].name.data, + ngx_syslog_priorities[n].name.len) == 0) { + p = ngx_syslog_priorities[n].macro; + match = 1; @@ -217,10 +215,11 @@ + return NGX_CONF_OK; +} +#endif - ++ char * -@@ -429,6 +562,13 @@ static char * + ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) +@@ -429,6 +561,13 @@ static char * ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value, name; @@ -234,7 +233,7 @@ if (cf->cycle->new_log.file) { return "is duplicate"; -@@ -436,7 +576,44 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -436,7 +575,44 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) value = cf->args->elts; @@ -279,7 +278,7 @@ ngx_str_null(&name); } else { -@@ -457,3 +634,63 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -457,3 +633,62 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return ngx_log_set_levels(cf, &cf->cycle->new_log); } @@ -306,7 +305,7 @@ + cf->cycle->new_log.syslog_set = 1; + + for (n = 0; ngx_syslog_facilities[n].name.len != 0; n++) { -+ if (ngx_strncmp(value[1].data, ngx_syslog_facilities[n].name.data, ++ if (ngx_strncmp(value[1].data, ngx_syslog_facilities[n].name.data, + ngx_syslog_facilities[n].name.len) == 0) { + facility = ngx_syslog_facilities[n].macro; + match = 1; @@ -324,7 +323,7 @@ + return NGX_CONF_ERROR; + } + -+ program = SYSLOG_IDENT_NAME; ++ program = SYSLOG_IDENT_NAME; + if (cf->args->nelts > 2) { + program = (char *) value[2].data; + } @@ -342,7 +341,6 @@ + } +} +#endif -+ diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index 3233647..5e7fdbf 100644 --- a/src/core/ngx_log.h @@ -387,12 +385,12 @@ void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...); void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...); diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c -index 2d41285..fd3ce30 100644 +index aa6a3fc..1fc3a91 100644 --- a/src/http/modules/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c -@@ -9,6 +9,11 @@ - #include - #include +@@ -13,6 +13,11 @@ + #include + #endif +#if (NGX_ENABLE_SYSLOG) +#include @@ -402,7 +400,7 @@ typedef struct ngx_http_log_op_s ngx_http_log_op_t; -@@ -52,6 +57,11 @@ typedef struct { +@@ -67,6 +72,11 @@ typedef struct { time_t disk_full_time; time_t error_log_time; ngx_http_log_fmt_t *format; @@ -414,36 +412,40 @@ } ngx_http_log_t; -@@ -323,11 +333,27 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf, - time_t now; - ssize_t n; - ngx_err_t err; -- -+ +@@ -352,9 +362,19 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf, + ngx_http_log_buf_t *buffer; + #endif + +#if (NGX_ENABLE_SYSLOG) + n = 0; + if (log->syslog_on) { + syslog(log->priority, "%.*s", (int)len, buf); + } +#endif -+ ++ if (log->script == NULL) { name = log->file->name.data; + +#if (NGX_ENABLE_SYSLOG) + if (name != NULL) { -+ n = ngx_write_fd(log->file->fd, buf, len); -+ } -+ else { ++#endif + #if (NGX_ZLIB) + buffer = log->file->data; + +@@ -367,7 +387,11 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf, + #else + n = ngx_write_fd(log->file->fd, buf, len); + #endif +- ++#if (NGX_ENABLE_SYSLOG) ++ } else { + n = len; + } -+#else - n = ngx_write_fd(log->file->fd, buf, len); - +#endif } else { name = NULL; n = ngx_http_log_script_write(r, log->script, &name, buf, len); -@@ -859,6 +885,10 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) +@@ -1068,6 +1092,10 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) log->script = NULL; log->disk_full_time = 0; log->error_log_time = 0; @@ -454,7 +456,7 @@ lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); fmt = lmcf->formats.elts; -@@ -884,6 +914,13 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -1096,6 +1124,13 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_http_log_main_conf_t *lmcf; ngx_http_script_compile_t sc; @@ -468,7 +470,7 @@ value = cf->args->elts; if (ngx_strcmp(value[1].data, "off") == 0) { -@@ -896,6 +933,38 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -1108,6 +1143,38 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) "invalid parameter \"%V\"", &value[2]); return NGX_CONF_ERROR; } @@ -485,10 +487,10 @@ + priority.len = value[1].len - sizeof("syslog"); + priority.data = value[1].data + sizeof("syslog"); + -+ off = (u_char*) ngx_strchr(priority.data, '|'); ++ off = (u_char*) ngx_strchr(priority.data, '|'); + if (off != NULL) { + priority.len = off - priority.data; -+ ++ + off++; + name.len = value[1].data + value[1].len - off; + name.data = off; @@ -507,7 +509,7 @@ if (llcf->logs == NULL) { llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); -@@ -913,6 +982,52 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -1125,6 +1192,52 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_memzero(log, sizeof(ngx_http_log_t)); @@ -560,16 +562,7 @@ n = ngx_http_script_variables_count(&value[1]); if (n == 0) { -@@ -920,7 +1035,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) - if (log->file == NULL) { - return NGX_CONF_ERROR; - } -- -+ - } else { - if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) { - return NGX_CONF_ERROR; -@@ -945,6 +1060,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -1157,6 +1270,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } } @@ -578,10 +571,10 @@ if (cf->args->nelts >= 3) { name = value[2]; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c -index 42dd664..a46c60d 100644 +index 61439a1..b592a39 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c -@@ -1450,6 +1450,9 @@ ngx_http_update_location_config(ngx_http_request_t *r) +@@ -1451,6 +1451,9 @@ ngx_http_update_location_config(ngx_http_request_t *r) if (r == r->main) { r->connection->log->file = clcf->error_log->file; @@ -591,7 +584,7 @@ if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { r->connection->log->log_level = clcf->error_log->log_level; -@@ -4657,6 +4660,15 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -4764,6 +4767,15 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_str_t *value, name; @@ -607,7 +600,7 @@ if (clcf->error_log) { return "is duplicate"; } -@@ -4666,6 +4678,36 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -4773,6 +4785,36 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) if (ngx_strcmp(value[1].data, "stderr") == 0) { ngx_str_null(&name); @@ -625,7 +618,7 @@ + priority.len = value[1].len - sizeof("syslog"); + priority.data = value[1].data + sizeof("syslog"); + -+ off = (u_char*) ngx_strchr(priority.data, '|'); ++ off = (u_char*) ngx_strchr(priority.data, '|'); + if (off != NULL) { + priority.len = off - priority.data; + @@ -644,7 +637,7 @@ } else { name = value[1]; } -@@ -4675,6 +4717,17 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +@@ -4782,6 +4824,17 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } @@ -663,7 +656,7 @@ clcf->error_log->log_level = NGX_LOG_ERR; return NGX_CONF_OK; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c -index 052f379..1d799d5 100644 +index ee00fd3..e15e157 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -433,6 +433,9 @@ ngx_http_init_request(ngx_event_t *rev) @@ -676,7 +669,7 @@ if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { c->log->log_level = clcf->error_log->log_level; } -@@ -1819,6 +1822,9 @@ found: +@@ -1834,6 +1837,9 @@ found: clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); r->connection->log->file = clcf->error_log->file;