From owner-svn-src-all@freebsd.org Thu Mar 14 23:10:07 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BED831532E3D for ; Thu, 14 Mar 2019 23:10:07 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-yw1-xc2e.google.com (mail-yw1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 43AC5728F9 for ; Thu, 14 Mar 2019 23:10:05 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-yw1-xc2e.google.com with SMTP id j66so5814435ywc.10 for ; Thu, 14 Mar 2019 16:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sFZqCyrC197WtdiLngm2zOe83AfAzzee3UoI/KKMGGk=; b=fjuZtmjVD2Ymy84k+xiJ4tU5woxA1K6/DSGjzpbXTkSnL6R+NyPDV6tziXsi8Ku7+r uk9ZD4W9MpQpK29JD2fdapEpRcYxsFyfDixQQgexzDQYFcZondYGQHx9231kjyxJWSse A87kyAjWqSE1hfmYj59HmkOLMU+MA9UnZ126XXfPxyP56ITl9+Ya+guicCOyBKQyGQzG 3C9LrRv+45yoQ3IPeYqIhVx9rpU7mOrwFRXfV9rH0xNLoyXWpHekvJaPPhJq3JjcvJ1R RUdfPkqme1ebCqycg4YeqUn8LTqI0/nOTc84OGhZDNnE2bqTG6eZC6+n5tfBOkP8yxAU Dk7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sFZqCyrC197WtdiLngm2zOe83AfAzzee3UoI/KKMGGk=; b=FBHs/BqGyht58ETnPqSbjqNZQXUV22zRnpsyUuiFnDz3EENsM7o2HhWCsjab3dDdZv Vke7HEr5fVBNBjbYNuR/6KVoTma4b81iB2Op1ADXpCiwN6YM3zKnaT30NBp9WHVbV17+ p3UNn3gDznyiE6zw/ioQLqW7GlI5Xzf0BgWYCPIZ2KVptAHDNoKsrBfKaEIwuVMJZnaE YDu1ZXNS0mLhiPRMR0cDwEGJbcbD2x4yVZe9gThc2i7Rff6Se8nNqRgi2+N1T0b8NTPW SmjaQ4nuHv/CvWTyGkKpYAR1o39WhL+QWRzGSB4do8eRCgiyBLkfAu5gZfrFMAvn+QsR 4Q/A== X-Gm-Message-State: APjAAAUNsLOHAikqGlz+h4UOM6zh/2/V9Tf144Mii/0smU10UNi06mSH 101QxbNjvwij56/EuSRpmAa4ICI9TJE6Qf8ReKsZHjGf X-Google-Smtp-Source: APXvYqxTlV4bK2o+syoommf9/MuZN8dLj717QR2be7Jld6jPBE+sivfxLVKGD1Kiwu37e5OYCbHq+DomaZnv7xbVwGA= X-Received: by 2002:a25:a027:: with SMTP id x36mr594688ybh.158.1552605005110; Thu, 14 Mar 2019 16:10:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5b:b0e:0:0:0:0:0 with HTTP; Thu, 14 Mar 2019 16:10:04 -0700 (PDT) In-Reply-To: <201804061300.w36D0jTT025330@repo.freebsd.org> References: <201804061300.w36D0jTT025330@repo.freebsd.org> From: Oliver Pinter Date: Fri, 15 Mar 2019 00:10:04 +0100 Message-ID: Subject: Re: svn commit: r332100 - in head: . lib/libc/gen sys/sys To: Ed Schouten Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" X-Rspamd-Queue-Id: 43AC5728F9 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=hardenedbsd.org header.s=google header.b=fjuZtmjV; spf=pass (mx1.freebsd.org: domain of oliver.pinter@hardenedbsd.org designates 2607:f8b0:4864:20::c2e as permitted sender) smtp.mailfrom=oliver.pinter@hardenedbsd.org X-Spamd-Result: default: False [-6.17 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[hardenedbsd.org:s=google]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; DMARC_NA(0.00)[hardenedbsd.org]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[hardenedbsd.org:+]; MX_GOOD(-0.01)[alt1.aspmx.l.google.com,aspmx.l.google.com,aspmx2.googlemail.com,alt2.aspmx.l.google.com,aspmx3.googlemail.com]; RCVD_IN_DNSWL_NONE(0.00)[e.2.c.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.89)[-0.885,0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; IP_SCORE(-2.77)[ip: (-8.99), ipnet: 2607:f8b0::/32(-2.73), asn: 15169(-2.08), country: US(-0.07)] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Thu, 14 Mar 2019 23:10:08 -0000 On Friday, April 6, 2018, Ed Schouten wrote: > Author: ed > Date: Fri Apr 6 13:00:45 2018 > New Revision: 332100 > URL: https://svnweb.freebsd.org/changeset/base/332100 > > Log: > Let syslog(3) use RFC 5424. > > With r332099 changing syslogd(8) to parse RFC 5424 formatted syslog > messages, go ahead and also change the syslog(3) libc function to > generate them. Compared to RFC 3164, RFC 5424 has various advantages, > such as sub-second precision for log entry timestamps. > > As this change could have adverse effects when not updating syslogd(8) > or using a different system logging daemon, add a notice to UPDATING and > increase __FreeBSD_version. > > Differential Revision: https://reviews.freebsd.org/D14926 += relnotes = yes > > Modified: > head/UPDATING > head/lib/libc/gen/syslog.3 > head/lib/libc/gen/syslog.c > head/sys/sys/param.h > > Modified: head/UPDATING > ============================================================ > ================== > --- head/UPDATING Fri Apr 6 12:57:01 2018 (r332099) > +++ head/UPDATING Fri Apr 6 13:00:45 2018 (r332100) > @@ -51,6 +51,45 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: > > ****************************** SPECIAL WARNING: > ****************************** > > +20180406: > + In addition to supporting RFC 3164 formatted messages, the > + syslogd(8) service is now capable of parsing RFC 5424 formatted > + log messages. The main benefit of using RFC 5424 is that clients > + may now send log messages with timestamps containing year numbers, > + microseconds and time zone offsets. > + > + Similarly, the syslog(3) C library function has been altered to > + send RFC 5424 formatted messages to the local system logging > + daemon. On systems using syslogd(8), this change should have no > + negative impact, as long as syslogd(8) and the C library are > + updated at the same time. On systems using a different system > + logging daemon, it may be necessary to make configuration > + adjustments, depending on the software used. > + > + When using syslog-ng, add the 'syslog-protocol' flag to local > + input sources to enable parsing of RFC 5424 formatted messages: > + > + source src { > + unix-dgram("/var/run/log" flags(syslog-protocol)); > + } > + > + When using rsyslog, disable the 'SysSock.UseSpecialParser' option > + of the 'imuxsock' module to let messages be processed by the > + regular RFC 3164/5424 parsing pipeline: > + > + module(load="imuxsock" SysSock.UseSpecialParser="off") > + > + Do note that these changes only affect communication between local > + applications and syslogd(8). The format that syslogd(8) uses to > + store messages on disk or forward messages to other systems > + remains unchanged. syslogd(8) still uses RFC 3164 for these > + purposes. Options to customize this behaviour will be added in the > + future. Utilities that process log files stored in /var/log are > + thus expected to continue to function as before. > + > + __FreeBSD_version has been incremented to 1200061 to denote this > + change. > + > 20180328: > Support for token ring networks has been removed. If you > have "device token" in your kernel config you should remove > > Modified: head/lib/libc/gen/syslog.3 > ============================================================ > ================== > --- head/lib/libc/gen/syslog.3 Fri Apr 6 12:57:01 2018 (r332099) > +++ head/lib/libc/gen/syslog.3 Fri Apr 6 13:00:45 2018 (r332100) > @@ -28,7 +28,7 @@ > .\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 > .\" $FreeBSD$ > .\" > -.Dd November 5, 2017 > +.Dd April 6, 2018 > .Dt SYSLOG 3 > .Os > .Sh NAME > @@ -156,6 +156,9 @@ Write the message to standard error output as well to > .It Dv LOG_PID > Log the process id with each message: useful for identifying > instantiations of daemons. > +On > +.Fx , > +this option is enabled by default. > .El > .Pp > The > > Modified: head/lib/libc/gen/syslog.c > ============================================================ > ================== > --- head/lib/libc/gen/syslog.c Fri Apr 6 12:57:01 2018 (r332099) > +++ head/lib/libc/gen/syslog.c Fri Apr 6 13:00:45 2018 (r332100) > @@ -36,9 +36,10 @@ static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/ > __FBSDID("$FreeBSD$"); > > #include "namespace.h" > -#include > +#include > #include > #include > +#include > #include > #include > #include > @@ -134,11 +135,13 @@ syslog(int pri, const char *fmt, ...) > static void > vsyslog1(int pri, const char *fmt, va_list ap) > { > - int cnt; > + struct timeval now; > + struct tm tm; > char ch, *p; > - time_t now; > - int fd, saved_errno; > - char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26], errstr[64]; > + long tz_offset; > + int cnt, fd, saved_errno; > + char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024], > + errstr[64], tz_sign; > FILE *fp, *fmt_fp; > struct bufcookie tbuf_cookie; > struct bufcookie fmt_cookie; > @@ -168,24 +171,46 @@ vsyslog1(int pri, const char *fmt, va_list ap) > if (fp == NULL) > return; > > - /* Build the message. */ > - (void)time(&now); > - (void)fprintf(fp, "<%d>", pri); > - (void)fprintf(fp, "%.15s ", ctime_r(&now, timbuf) + 4); > + /* Build the message according to RFC 5424. Tag and version. */ > + (void)fprintf(fp, "<%d>1 ", pri); > + /* Timestamp similar to RFC 3339. */ > + if (gettimeofday(&now, NULL) == 0 && > + localtime_r(&now.tv_sec, &tm) != NULL) { > + if (tm.tm_gmtoff < 0) { > + tz_sign = '-'; > + tz_offset = -tm.tm_gmtoff; > + } else { > + tz_sign = '+'; > + tz_offset = tm.tm_gmtoff; > + } > + > + (void)fprintf(fp, > + "%04d-%02d-%02d" /* Date. */ > + "T%02d:%02d:%02d.%06ld" /* Time. */ > + "%c%02ld:%02ld ", /* Time zone offset. */ > + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, > + tm.tm_hour, tm.tm_min, tm.tm_sec, now.tv_usec, > + tz_sign, tz_offset / 3600, (tz_offset % 3600) / 60); > + } else > + (void)fprintf(fp, "- "); > + /* Hostname. */ > + (void)gethostname(hostname, sizeof(hostname)); > + (void)fprintf(fp, "%s ", hostname); > if (LogStat & LOG_PERROR) { > /* Transfer to string buffer */ > (void)fflush(fp); > stdp = tbuf + (sizeof(tbuf) - tbuf_cookie.left); > } > + /* > + * Application name, process ID, message ID and structured data. > + * Provide the process ID regardless of whether LOG_PID has been > + * specified, as it provides valuable information. Many > + * applications tend not to use this, even though they should. > + */ > if (LogTag == NULL) > LogTag = _getprogname(); > - if (LogTag != NULL) > - (void)fprintf(fp, "%s", LogTag); > - if (LogStat & LOG_PID) > - (void)fprintf(fp, "[%d]", getpid()); > - if (LogTag != NULL) { > - (void)fprintf(fp, ": "); > - } > + (void)fprintf(fp, "%s %d - - ", > + LogTag == NULL ? "-" : LogTag, getpid()); > > /* Check to see if we can skip expanding the %m */ > if (strstr(fmt, "%m")) { > @@ -313,7 +338,7 @@ vsyslog1(int pri, const char *fmt, va_list ap) > struct iovec iov[2]; > struct iovec *v = iov; > > - p = strchr(tbuf, '>') + 1; > + p = strchr(tbuf, '>') + 3; > v->iov_base = p; > v->iov_len = cnt - (p - tbuf); > ++v; > > Modified: head/sys/sys/param.h > ============================================================ > ================== > --- head/sys/sys/param.h Fri Apr 6 12:57:01 2018 (r332099) > +++ head/sys/sys/param.h Fri Apr 6 13:00:45 2018 (r332100) > @@ -60,7 +60,7 @@ > * in the range 5 to 9. > */ > #undef __FreeBSD_version > -#define __FreeBSD_version 1200060 /* Master, propagated to newvers */ > +#define __FreeBSD_version 1200061 /* Master, propagated to newvers */ > > /* > * __FreeBSD_kernel__ indicates that this system uses the kernel of > FreeBSD, > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >