From nobody Tue Sep 2 06:44:21 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cGGS53lsqz66b12; Tue, 02 Sep 2025 06:44:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cGGS52mKKz3qYG; Tue, 02 Sep 2025 06:44:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756795461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L8llOjST/t7vT9yUjSLlCzWDRLsMYD3CiClvQrhALUU=; b=XcuKxkYfnOULS/p855K5H8uTA3kfsMUCWCh1+xPyDkLZdIyIxlhE4Oo2UXg28oVCdsgv7o grGoRYTfbfft63qnJfLUi+0bVNttdO9djhOvTaZ1Mqz50zKKgTFIREUbQ0yrCXiVPxGegO 0QfKXKIJ6lNVfd5HzUZAnoZqBULy+A91vrg3v5K/eeQz+/uDbak4tIpn3/vOvWi/gO3C1q Vqt7eXbNTfwTAR9XfpK1SyCtc6B5aJb7qZzb98BJETxEsTk0UFpYT/OrNMAA6ihpsVmqyB QSNx5itee8SCElI0z+DwECWEgdLLAv3fc50TDg/2UT6dK8lWZUIMbbUYfiePBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756795461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L8llOjST/t7vT9yUjSLlCzWDRLsMYD3CiClvQrhALUU=; b=bUqlGA6J656NpDTY1MbO17czTQ9iT+AmoXrO9JLcPLF4goa4iO2/o1BMXTD1o/oGhK6BMY K8kSssyaLfkg6VLcJZtirHOq64UJ5E/q5f1+rLjvASI6imsDjXB1jYukGDeTxWDPffRcgF O0Esn0Gq21SwO/g8v7UGgHpYwq28Dt1VpUKdWkcn7HSlW+M3iWEzAlL2FU1xIMGyxvshGz FwJQTxNIA96N+qskXdgR6smivYssxCo/gnmpUzKAFyFPg9CPFCvcGfgE51fGDnD58xjENl sgTcF/NvSW2lHvMz8TgZ3GsFVF7TmG3Ey6un5mwezZ3fwW/IFLGKjyJR6R+Y2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756795461; a=rsa-sha256; cv=none; b=XWgIlCsmPX2pTlGpogiCPKm0+SbnHdMQWDUNJaZd2lwcV8C/MkVHu16xAH2tGQK7Fd2tT7 McE5D/KOudnxUk6mqkKa4J6jfjbZZ9iNig7Lb9SiLhbfvEn0oVI35TElv1whdSGqPl1YrR cQkJ6JQo/TCSqvh8nmg+RYhgpzlVzBGqA7J1B/D6jizvlKjSp9r6tkFli9ShB3HfXZMdvm 9FsPDOo74cJisQHncBf2HMVj34xXRHIdvm+46MK+qAvvE97HqTGrFAcAsdZr0SwurcYQfv VaMnGCJAatGNzXdqpiK7PTAEJx1ijTON/y5+5MtbbkNR4RMyqGmDwM6LiqWiUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cGGS525FFzbYS; Tue, 02 Sep 2025 06:44:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5826iLXN092721; Tue, 2 Sep 2025 06:44:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5826iLYv092718; Tue, 2 Sep 2025 06:44:21 GMT (envelope-from git) Date: Tue, 2 Sep 2025 06:44:21 GMT Message-Id: <202509020644.5826iLYv092718@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: 39d668f1e09e - main - newsyslog(8): Remove the -c command line option. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 39d668f1e09ebfc678b3c69c19a0ad0391361c56 Auto-Submitted: auto-generated The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=39d668f1e09ebfc678b3c69c19a0ad0391361c56 commit 39d668f1e09ebfc678b3c69c19a0ad0391361c56 Author: Xin LI AuthorDate: 2025-09-02 06:44:12 +0000 Commit: Xin LI CommitDate: 2025-09-02 06:44:12 +0000 newsyslog(8): Remove the -c command line option. The -c command-line option, which allowed setting a global compression method, is removed in favor of the directive in newsyslog.conf. The motivation of this change is to eliminate a source of potential confusion. Since newsyslog(8) is typically invoked by cron(8), having a command line option that can override it could cause inconsistent behavior (specifying in crontab would take precedence). Suggested by: karels Differential Revision: https://reviews.freebsd.org/D43466 --- usr.sbin/newsyslog/newsyslog.8 | 22 +--------- usr.sbin/newsyslog/newsyslog.c | 29 ++----------- usr.sbin/newsyslog/newsyslog.conf.5 | 84 +++++++++++++++++++++++++++---------- 3 files changed, 65 insertions(+), 70 deletions(-) diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8 index 6d4fc378e790..7429e3b8eb01 100644 --- a/usr.sbin/newsyslog/newsyslog.8 +++ b/usr.sbin/newsyslog/newsyslog.8 @@ -14,7 +14,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd December 22, 2023 +.Dd September 1, 2025 .Dt NEWSYSLOG 8 .Os .Sh NAME @@ -24,7 +24,6 @@ .Nm .Op Fl CFNPnrsv .Op Fl a Ar directory -.Op Fl c Ar none Ns | Ns Ar legacy Ns | Ns Ar bzip2 Ns | Ns Ar gzip Ns | Ns Ar xz Ns | Ns Ar zstd .Op Fl d Ar directory .Op Fl f Ar config_file .Op Fl S Ar pidfile @@ -79,25 +78,6 @@ and mode three (above) assumes that this is so. The following options can be used with .Nm : .Bl -tag -width indent -.It Fl c Ar none Ns | Ns Ar legacy Ns | Ns Ar bzip2 Ns | Ns Ar gzip Ns | Ns Ar xz Ns | Ns Ar zstd -Instructs -.Nm -to use the specified compression method when a file is flagged for compression. -The default method is -.Dq legacy , -which interprets the -.Sy J, X, Y, Z -flags in the configuration file according to their historical meanings. -This default setting can be overridden by specifying -.Fl c Ar none , -which causes -.Nm -to ignore all compression flags. -Alternatively, specifying one of the compression methods: -.Sy bzip2 , gzip , xz , -or -.Sy zstd , -will apply the chosen method to all files flagged for compression. .It Fl f Ar config_file Instruct .Nm diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index d07f302fd24f..7ebdd7cbc0dd 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -701,19 +701,12 @@ parse_args(int argc, char **argv) hostname_shortlen = strcspn(hostname, "."); /* Parse command line options. */ - while ((ch = getopt(argc, argv, "a:c:d:f:nrst:vCD:FNPR:S:")) != -1) + while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FNPR:S:")) != -1) switch (ch) { case 'a': archtodir++; archdirname = optarg; break; - case 'c': - if (!parse_compression_type(optarg, &compress_type_override)) { - warnx("Unrecognized compression method '%s'.", optarg); - usage(); - } - compress_type_set = true; - break; case 'd': destdir = optarg; break; @@ -858,26 +851,10 @@ parse_doption(const char *doption) static void usage(void) { - int i; - char *alltypes = NULL, *tmp = NULL; - - for (i = 0; i < COMPRESS_TYPES; i++) { - if (i == COMPRESS_NONE) { - (void)asprintf(&tmp, "%s|legacy", compress_type[i].name); - } else { - (void)asprintf(&tmp, "%s|%s", alltypes, compress_type[i].name); - } - if (alltypes) - free(alltypes); - alltypes = tmp; - tmp = NULL; - } fprintf(stderr, - "usage: newsyslog [-CFNPnrsv] [-a directory] [-c %s]\n" - " [-d directory] [-f config_file]\n" - " [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n", - alltypes); + "usage: newsyslog [-CFNPnrsv] [-a directory] [-d directory] [-f config_file]\n" + " [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n"); exit(1); } diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5 index 2887ecb226aa..d94c39332597 100644 --- a/usr.sbin/newsyslog/newsyslog.conf.5 +++ b/usr.sbin/newsyslog/newsyslog.conf.5 @@ -18,7 +18,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd November 11, 2024 +.Dd September 1, 2025 .Dt NEWSYSLOG.CONF 5 .Os .Sh NAME @@ -44,8 +44,7 @@ reads a configuration file, normally .Pa /etc/newsyslog.conf , to determine which logs may potentially be rotated and archived. -Each line has five mandatory fields and four optional fields, -separated with whitespace. +.Pp Blank lines or lines beginning with .Ql # are ignored. @@ -63,34 +62,73 @@ in this case preceding is removed and .Ql # is treated as an ordinary character. +.Pp +The special +.Dq Ar +and +.Dq Ar +lines are defined as follows: +.Bl -tag -width indent +.It Ar Ns Ar none Ns | Ns Ar legacy Ns | Ns Ar bzip2 Ns | Ns Ar gzip Ns | Ns Ar xz Ns | Ns Ar zstd +This special option sets the global compress method, +it should be placed before all log file entries in +.Nm +configuration file. +The global compress method applies to all log files flagged as +compressible +.Dq Sy J , +.Dq Sy X , +.Dq Sy Y , +.Dq Sy Z +.Ar flags +below. +.Pp +The following compression methods are available: +.Bl -tag -width indent +.It Cm none +No compression is performed, even when a log file is marked as +compressible. This is useful for filesystems that have native +compression support. +.It Cm legacy +Interprets the +.Sy J, X, Y, Z +flags in the configuration file according to their historical meanings. +This is the default method. +.It Cm bzip2 +Use +.Xr bzip2 1 +for all compressible log files. +.It Cm gzip +Use +.Xr gzip 1 +for all compressible log files. +.It Cm xz +Use +.Xr xz 1 +for all compressible log files. +.It Cm zstd +Use +.Xr zstd 1 +for all compressible log files. +.El +.It Ar +The special entry is used to include other configuration +files and supports globbing. +.El +.Pp +Each other line has five mandatory fields and four optional fields, +separated with whitespace. The fields of the configuration file are as follows: .Bl -tag -width indent .It Ar logfile_name Name of the system log file to be archived, -or one of the special strings -.Dq Li , -.Dq Li , -or -.Dq Li . -The entry, -which should be placed at the beginning of the -.Nm -configuration file, -sets the global compress method. -This method is applied when a log file is flagged as -compressible, -which has the same effect of passing a compress method to the -.Fl c -option on the -.Xr newsyslog 8 -command line. +or the special string +.Dq Ar . The special entry will only be used if a log file name is given as a command line argument to .Xr newsyslog 8 , and if that log file name is not matched by any other line in the configuration file. -The include entry is used to include other configuration -files and supports globbing. .It Ar owner : Ns Ar group This optional field specifies the owner and group for the archive file. The @@ -432,7 +470,7 @@ can be the signal number, e.g., 30 for .El .Sh EXAMPLES The following is an example of the -.Dq Aq Li include +.Dq entry: .Dl " /etc/newsyslog-local.conf" .Sh SEE ALSO