From owner-svn-src-all@FreeBSD.ORG Fri Apr 8 12:33:07 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E185106566C; Fri, 8 Apr 2011 12:33:07 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 741688FC0C; Fri, 8 Apr 2011 12:33:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p38CX7RN080134; Fri, 8 Apr 2011 12:33:07 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p38CX7YD080131; Fri, 8 Apr 2011 12:33:07 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201104081233.p38CX7YD080131@svn.freebsd.org> From: Edwin Groothuis Date: Fri, 8 Apr 2011 12:33:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220448 - head/usr.bin/logger X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2011 12:33:07 -0000 Author: edwin Date: Fri Apr 8 12:33:07 2011 New Revision: 220448 URL: http://svn.freebsd.org/changeset/base/220448 Log: When specifying the -t option (send tag in front of message), this tag should also be forwarded to the remote logging host, not only when the logging is done locally. PR: bin/154324 Submitted by: Callum Gibson MFC after: 1 week Modified: head/usr.bin/logger/logger.1 head/usr.bin/logger/logger.c Modified: head/usr.bin/logger/logger.1 ============================================================================== --- head/usr.bin/logger/logger.1 Fri Apr 8 11:08:26 2011 (r220447) +++ head/usr.bin/logger/logger.1 Fri Apr 8 12:33:07 2011 (r220448) @@ -102,7 +102,8 @@ facility. The default is ``user.notice.'' .It Fl t Ar tag Mark every line in the log with the specified -.Ar tag . +.Ar tag +rather than the default of current login name. .It Ar message Write the message to log; if not specified, and the .Fl f Modified: head/usr.bin/logger/logger.c ============================================================================== --- head/usr.bin/logger/logger.c Fri Apr 8 11:08:26 2011 (r220447) +++ head/usr.bin/logger/logger.c Fri Apr 8 12:33:07 2011 (r220448) @@ -59,7 +59,8 @@ __FBSDID("$FreeBSD$"); int decode(char *, CODE *); int pencode(char *); -static void logmessage(int, const char *, const char *, const char *); +static void logmessage(int, const char *, const char *, const char *, + const char *); static void usage(void); struct socks { @@ -137,8 +138,11 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (tag == NULL) + tag = getlogin(); /* setup for logging */ - openlog(tag ? tag : getlogin(), logflags, 0); + if (host == NULL) + openlog(tag, logflags, 0); (void) fclose(stdout); /* log input line if appropriate */ @@ -149,11 +153,11 @@ main(int argc, char *argv[]) for (p = buf, endp = buf + sizeof(buf) - 2; *argv;) { len = strlen(*argv); if (p + len > endp && p > buf) { - logmessage(pri, host, svcname, buf); + logmessage(pri, tag, host, svcname, buf); p = buf; } if (len > sizeof(buf) - 1) - logmessage(pri, host, svcname, *argv++); + logmessage(pri, tag, host, svcname, *argv++); else { if (p != buf) *p++ = ' '; @@ -162,10 +166,10 @@ main(int argc, char *argv[]) } } if (p != buf) - logmessage(pri, host, svcname, buf); + logmessage(pri, tag, host, svcname, buf); } else while (fgets(buf, sizeof(buf), stdin) != NULL) - logmessage(pri, host, svcname, buf); + logmessage(pri, tag, host, svcname, buf); exit(0); } @@ -173,7 +177,8 @@ main(int argc, char *argv[]) * Send the message to syslog, either on the local host, or on a remote host */ void -logmessage(int pri, const char *host, const char *svcname, const char *buf) +logmessage(int pri, const char *tag, const char *host, const char *svcname, + const char *buf) { static struct socks *socks; static int nsock = 0; @@ -217,7 +222,7 @@ logmessage(int pri, const char *host, co errx(1, "socket"); } - if ((len = asprintf(&line, "<%d>%s", pri, buf)) == -1) + if ((len = asprintf(&line, "<%d>%s: %s", pri, tag, buf)) == -1) errx(1, "asprintf"); lsent = -1;