<div dir="ltr">Created a new patch as disabling hostame as a configuration option.<br><br># HG changeset patch<br># User Nils Hermansson <<a href="mailto:3tnica@gmail.com">3tnica@gmail.com</a>><br># Date 1445973553 -3600<br># Tue Oct 27 20:19:13 2015 +0100<br># Node ID 7e4f788192183a3053cd9478ee136bad269a2375<br># Parent f1424eef1966c966e5403c44e3d9470e0af5b7e9<br>Syslog configuration for disabling sending of hostname.<br>hostname=(on/off) default on<br><br>diff -r f1424eef1966 -r 7e4f78819218 src/core/ngx_syslog.c<br>--- a/src/core/ngx_syslog.c Tue Oct 27 16:47:30 2015 +0300<br>+++ b/src/core/ngx_syslog.c Tue Oct 27 20:19:13 2015 +0100<br>@@ -42,6 +42,7 @@<br> peer->pool = cf->pool;<br> peer->facility = NGX_CONF_UNSET_UINT;<br> peer->severity = NGX_CONF_UNSET_UINT;<br>+ peer->hostname = NGX_CONF_UNSET_UINT;<br><br> if (ngx_syslog_parse_args(cf, peer) != NGX_CONF_OK) {<br> return NGX_CONF_ERROR;<br>@@ -53,6 +54,10 @@<br> return NGX_CONF_ERROR;<br> }<br><br>+ if (peer->hostname == NGX_CONF_UNSET_UINT) {<br>+ peer->hostname = 1; /* enabled */<br>+ }<br>+<br> if (peer->facility == NGX_CONF_UNSET_UINT) {<br> peer->facility = 23; /* local7 */<br> }<br>@@ -193,6 +198,12 @@<br><br> peer->tag.data = p + 4;<br> peer->tag.len = len - 4;<br>+ } else if (ngx_strncmp(p, "hostname=", 9) == 0) {<br>+ if (ngx_strcmp(p + 9, "off") == 0) {<br>+ peer->hostname = 0;<br>+ } else {<br>+ peer->hostname = 1;<br>+ }<br><br> } else {<br> ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,<br>@@ -220,6 +231,11 @@<br><br> pri = peer->facility * 8 + peer->severity;<br><br>+ if (peer->hostname == 0) {<br>+ return ngx_sprintf(buf, "<%ui>%V %V: ", pri, &ngx_cached_syslog_time,<br>+ &peer->tag);<br>+ }<br>+<br> return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri, &ngx_cached_syslog_time,<br> &ngx_cycle->hostname, &peer->tag);<br> }<br>diff -r f1424eef1966 -r 7e4f78819218 src/core/ngx_syslog.h<br>--- a/src/core/ngx_syslog.h Tue Oct 27 16:47:30 2015 +0300<br>+++ b/src/core/ngx_syslog.h Tue Oct 27 20:19:13 2015 +0100<br>@@ -12,6 +12,7 @@<br> ngx_pool_t *pool;<br> ngx_uint_t facility;<br> ngx_uint_t severity;<br>+ ngx_uint_t hostname;<br> ngx_str_t tag;<br><br> ngx_addr_t server;<div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 27, 2015 at 3:14 PM, Vladimir Homutov <span dir="ltr"><<a href="mailto:vl@nginx.com" target="_blank">vl@nginx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Oct 23, 2015 at 08:51:56PM +0200, Nils Hermansson wrote:<br>
> # HG changeset patch<br>
> # User Nils Hermansson <<a href="mailto:3tnica@gmail.com">3tnica@gmail.com</a>><br>
> # Date 1445625283 -7200<br>
> # Fri Oct 23 20:34:43 2015 +0200<br>
> # Node ID 868fc6b3bf69be611118c597578e749c65698b8c<br>
> # Parent ee16fb0db905cfb858a929374cf623cdf1a0f9d3<br>
> Most standard syslog facilicties do not expect hostname when logging to<br>
> Unix Sockets.<br>
> This patch removes hostname from syslog message when logging to Unix Socket.<br>
> Tested on rsyslog and syslog-ng<br>
><br>
> diff -r ee16fb0db905 -r 868fc6b3bf69 src/core/ngx_syslog.c<br>
> --- a/src/core/ngx_syslog.c Tue Oct 20 21:28:38 2015 +0300<br>
> +++ b/src/core/ngx_syslog.c Fri Oct 23 20:34:43 2015 +0200<br>
> @@ -219,9 +219,17 @@<br>
> ngx_uint_t pri;<br>
><br>
> pri = peer->facility * 8 + peer->severity;<br>
> -<br>
> - return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri,<br>
> &ngx_cached_syslog_time,<br>
> +#if (NGX_HAVE_UNIX_DOMAIN)<br>
> + if (peer->server.sockaddr->sa_family == AF_UNIX) {<br>
> + return ngx_sprintf(buf, "<%ui>%V %V: ", pri,<br>
> &ngx_cached_syslog_time,<br>
> + &peer->tag);<br>
> + } else {<br>
> +#endif<br>
> + return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri,<br>
> &ngx_cached_syslog_time,<br>
> &ngx_cycle->hostname, &peer->tag);<br>
> +#if (NGX_HAVE_UNIX_DOMAIN)<br>
> + }<br>
> +#endif<br>
> }<br>
<br>
</div></div>Hi Nils,<br>
<br>
we agree that there is some inconvenience with local syslog and are<br>
considering adding configuration option to select desired behaviour<br>
at this place.<br>
<br>
Note that there is a simple solution - to setup your syslog daemon<br>
to expect hostname. See <a href="https://trac.nginx.org/nginx/ticket/677" rel="noreferrer" target="_blank">https://trac.nginx.org/nginx/ticket/677</a><br>
and <a href="https://trac.nginx.org/nginx/ticket/783" rel="noreferrer" target="_blank">https://trac.nginx.org/nginx/ticket/783</a>.<br>
<br>
Your suggested patch would breaks existing setups and make message<br>
content depend on transport, what is undesirable.<br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div><br></div></div>