From owner-freebsd-current@FreeBSD.ORG Fri Apr 8 15:15:24 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 134E6106567C for ; Fri, 8 Apr 2011 15:15:24 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id A0C528FC18 for ; Fri, 8 Apr 2011 15:15:23 +0000 (UTC) Received: by eyg7 with SMTP id 7so1239921eyg.13 for ; Fri, 08 Apr 2011 08:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=MbbcROi0D+0vUwSQNvM2Za+G+acX3b9yCDQGa8pDnFo=; b=r3f99pYG72WMN48/rIkdjTUiILIqiyCm590x5EDXTtC9s3QhgAGCJc05sWszd4dcuC dbISiOl7p4Ztc9OC+ynRr8tWLZARJi+kIMsXTB+991bfpI6LGdCTGeVMSXJerLmNbu8B cTkYD+Y7wDzzHE6O+xhRM0scGIcPgn6k3YWaM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=J5lnO21+/cvZgTpIJZR4YKpBKQt2kxcPgV61c/zQrBQPZJLySqdxtsiChU1WzOw1tZ cPa2PNPEnRyeONplP+btXuzq9jrBBecPkZFaNDNrlqyAqXLnDD0UQf4PR8mbeVMKbUau G03LlLm+B6t56TyofshWWblohY35bOfoxp18c= MIME-Version: 1.0 Received: by 10.213.21.134 with SMTP id j6mr976585ebb.141.1302275722273; Fri, 08 Apr 2011 08:15:22 -0700 (PDT) Received: by 10.213.31.75 with HTTP; Fri, 8 Apr 2011 08:15:22 -0700 (PDT) Date: Fri, 8 Apr 2011 11:15:22 -0400 Message-ID: From: Ryan Stone To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1 Subject: [PATCH] Add syslogd option that suppresses hostname logging X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2011 15:15:24 -0000 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. */