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. */
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to