On 02/01/13 15:30, Gabriel Linder wrote:
> On 02/01/13 11:57, Stuart Henderson wrote:
>> I'm a bit undecided as to whether this is really useful (I suppose
>> having it _in addition_ to the IP address might be useful where
>> there's a NAT between log source and destination) but in any event
>> if it's done, I think it should be optional and off by default; it
>> changes the established format and eats into a limited 1K max line
>> length.
>
> I will submit a new patch implementing this behaviour, then.

And here it is. I tried to configure Thunderbird following git-format-patch(1), 
but just in case the diff is available at 
http://dargor.servebeer.com/~dargor/openbsd/syslogd.diff

Index: syslogd.8
===================================================================
RCS file: /cvs/src/usr.sbin/syslogd/syslogd.8,v
retrieving revision 1.26
diff -u -r1.26 syslogd.8
--- syslogd.8    22 Oct 2009 15:02:13 -0000    1.26
+++ syslogd.8    1 Feb 2013 16:06:53 -0000
@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm syslogd
 .Bk -words
-.Op Fl dnu
+.Op Fl Ndnu
 .Op Fl a Ar path
 .Op Fl f Ar config_file
 .Op Fl m Ar mark_interval
@@ -54,6 +54,8 @@
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl N
+When logging to a remote host, send the local hostname with the log message.
 .It Fl a Pa path
 Specify a location where
 .Nm
Index: syslogd.c
===================================================================
RCS file: /cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.104
diff -u -r1.104 syslogd.c
--- syslogd.c    12 Jul 2011 11:28:31 -0000    1.104
+++ syslogd.c    1 Feb 2013 16:06:54 -0000
@@ -184,6 +184,7 @@
 
 int    nfunix = 1;        /* Number of Unix domain sockets requested */
 char    *funixn[MAXFUNIX] = { _PATH_LOG }; /* Paths to Unix domain sockets */
+int    SendHName = 0;        /* when true, send local hostname with messages */
 int    Debug;            /* debug flag */
 int    Startup = 1;        /* startup flag */
 char    LocalHostName[MAXHOSTNAMELEN];    /* our hostname */
@@ -289,8 +290,11 @@
     struct addrinfo hints, *res, *res0;
     FILE *fp;
 
-    while ((ch = getopt(argc, argv, "dnuf:m:p:a:s:")) != -1)
+    while ((ch = getopt(argc, argv, "Ndnuf:m:p:a:s:")) != -1)
         switch (ch) {
+        case 'N':        /* send local hostname with messages */
+            SendHName = 1;
+            break;
         case 'd':        /* debug */
             Debug++;
             break;
@@ -888,9 +892,15 @@
 
     case F_FORW:
         dprintf(" %s\n", f->f_un.f_forw.f_hname);
-        if ((l = snprintf(line, sizeof(line), "<%d>%.15s %s",
-            f->f_prevpri, (char *)iov[0].iov_base,
-            (char *)iov[4].iov_base)) >= sizeof(line) || l == -1)
+        if (SendHName)
+            l = snprintf(line, sizeof(line), "<%d>%.15s %s %s",
+                f->f_prevpri, (char *)iov[0].iov_base, LocalHostName,
+                (char *)iov[4].iov_base);
+        else
+            l = snprintf(line, sizeof(line), "<%d>%.15s %s",
+                f->f_prevpri, (char *)iov[0].iov_base,
+                (char *)iov[4].iov_base);
+        if (l >= sizeof(line) || l == -1)
             l = strlen(line);
         if (sendto(pfd[PFD_INET].fd, line, l, 0,
             (struct sockaddr *)&f->f_un.f_forw.f_addr,

Reply via email to