diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8 --- 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 January 20, 2024 .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 @@ 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 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -700,19 +700,12 @@ 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; @@ -857,26 +850,10 @@ 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 b/usr.sbin/newsyslog/newsyslog.conf --- a/usr.sbin/newsyslog/newsyslog.conf +++ b/usr.sbin/newsyslog/newsyslog.conf @@ -1,5 +1,8 @@ # configuration file for newsyslog # +# Global compress method for files tagged as compressible (J, X, Y, Z). + legacy +# # Entries which do not specify the '/pid_file' field will cause the # syslogd process to be signalled when that log file is rotated. This # action is only appropriate for log files which are written to by the diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5 --- 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 December 25, 2023 +.Dd January 20, 2024 .Dt NEWSYSLOG.CONF 5 .Os .Sh NAME @@ -44,8 +44,7 @@ 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,70 @@ 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 +Do not do any compression even when requested. +.It Cm legacy +Interpret the +.Sy J, X, Y, Z +flags in the configuration file according to their historical meanings. +.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 @@ -430,7 +465,7 @@ .El .Sh EXAMPLES The following is an example of the -.Dq Aq Li include +.Dq entry: .Dl " /etc/newsyslog-local.conf" .Sh SEE ALSO