Date: Fri, 8 Apr 2011 11:15:22 -0400 From: Ryan Stone <rysto32@gmail.com> To: FreeBSD Current <freebsd-current@freebsd.org> Subject: [PATCH] Add syslogd option that suppresses hostname logging Message-ID: <BANLkTi=huoB5N-d5YRzkTkzvZMKB8QyarQ@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
I've written a short patch for syslogd that adds a -H option. Setting that option will prevent syslogd from logging the hostname with every log messages. If there are no objections I'm going to commit this in the next couple of days. Index: syslogd.c =================================================================== --- syslogd.c (revision 220452) +++ syslogd.c (working copy) @@ -301,6 +301,7 @@ /* 0=no, 1=numeric, 2=names */ static int KeepKernFac; /* Keep remotely logged kernel facility */ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ +static int LogHost = 1; static struct pidfh *pfh; volatile sig_atomic_t MarkSet, WantDie; @@ -358,7 +359,7 @@ dprintf("madvise() failed: %s\n", strerror(errno)); bindhostname = NULL; - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nop:P:sS:Tuv")) + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Hkl:m:nop:P:sS:Tuv")) != -1) switch (ch) { case '4': @@ -394,6 +395,9 @@ case 'f': /* configuration file */ ConfFile = optarg; break; + case 'H': /* don't log the origin hostname */ + LogHost = 0; + break; case 'k': /* keep remote kern fac */ KeepKernFac = 1; break; @@ -1150,12 +1154,20 @@ } v++; - v->iov_base = f->f_prevhost; - v->iov_len = strlen(v->iov_base); + if (LogHost) { + v->iov_base = f->f_prevhost; + v->iov_len = strlen(v->iov_base); + v++; + v->iov_base = space; + v->iov_len = 1; + } else { + v->iov_base = nul; + v->iov_len = 0; + v++; + v->iov_base = nul; + v->iov_len = 0; + } v++; - v->iov_base = space; - v->iov_len = 1; - v++; if (msg) { wmsg = strdup(msg); /* XXX iov_base needs a `const' sibling. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTi=huoB5N-d5YRzkTkzvZMKB8QyarQ>