mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
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 <compress> 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
This commit is contained in:
parent
e88b7dcac8
commit
39d668f1e0
3 changed files with 65 additions and 70 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <compress>
|
||||
and
|
||||
.Dq Ar <include>
|
||||
lines are defined as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Ar <compress> 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 <include>
|
||||
The special <include> 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 <compress> ,
|
||||
.Dq Li <default> ,
|
||||
or
|
||||
.Dq Li <include> .
|
||||
The <compress> 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 <default> .
|
||||
The special <default> 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 <include>
|
||||
entry:
|
||||
.Dl "<include> /etc/newsyslog-local.conf"
|
||||
.Sh SEE ALSO
|
||||
|
|
|
|||
Loading…
Reference in a new issue