Page MenuHomeFreeBSD

D43169.1787802649.diff
No OneTemporary

Size
8 KB
Referenced Files
None
Subscribers
None

D43169.1787802649.diff

diff --git a/UPDATING b/UPDATING
--- a/UPDATING
+++ b/UPDATING
@@ -27,6 +27,18 @@
world, or to merely disable the most expensive debugging functionality
at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+20231225:
+ newsyslog(8) will no longer compress rotated files by default.
+ The J, X, Y, Z flags in newsyslog.conf(5) configuration files now
+ signify "treat the file as compressible" instead of "compress the
+ file with the specified method." A new command line option, -c, has
+ been introduced to allow specification of a new compression type
+ or to restore historical behavior.
+
+ To reinstate the historical behavior, modify the newsyslog entry
+ in your /etc/crontab to include "-c legacy". For more details,
+ consult the newsyslog(8) manual page.
+
20231120:
If you have an arm64 system that uses ACPI, you will need to update your
loader.efi in the ESP when you update past this point. Detection of ACPI
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 December 25, 2023
.Dt NEWSYSLOG 8
.Os
.Sh NAME
@@ -84,15 +84,15 @@
.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 ,
+.Dq none ,
which causes
.Nm
to ignore all compression flags.
+This default can be overridden by specifying
+.Fl c Ar legacy
+which interprets the
+.Sy J , X , Y , Z ,
+flags in the configuration file according to their historical meanings.
Alternatively, specifying one of the compression methods:
.Sy bzip2 , gzip , xz ,
or
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
@@ -74,6 +74,7 @@
#include <paths.h>
#include <pwd.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <libgen.h>
#include <stdlib.h>
@@ -124,6 +125,7 @@
#define DEFAULT_MARKER "<default>"
#define DEBUG_MARKER "<debug>"
#define INCLUDE_MARKER "<include>"
+#define COMPRESS_MARKER "<compress>"
#define DEFAULT_TIMEFNAME_FMT "%Y%m%dT%H%M%S"
#define MAX_OLDLOGS 65536 /* Default maximum number of old logfiles */
@@ -247,7 +249,9 @@
static char *archdirname; /* Directory path to old logfiles archive */
static char *destdir = NULL; /* Directory to treat at root for logs */
static const char *conf; /* Configuration file to use */
-static enum compress_types_enum compress_type_override = COMPRESS_LEGACY; /* Compression type */
+static enum compress_types_enum compress_type_override = COMPRESS_NONE; /* Compression type */
+static bool compress_type_set = false;
+static bool compress_type_seen = false;
struct ptime_data *dbg_timenow; /* A "timenow" value set via -D option */
static struct ptime_data *timenow; /* The time to use for checking at-fields */
@@ -505,6 +509,37 @@
list = NULL;
}
+static bool
+parse_compression_type(const char *str, enum compress_types_enum *type)
+{
+ int i;
+
+ for (i = 0; i < COMPRESS_TYPES; i++) {
+ if (strcasecmp(str, compress_type[i].name) == 0) {
+ *type = i;
+ break;
+ }
+ }
+ if (i == COMPRESS_TYPES) {
+ if (strcasecmp(str, "legacy") == 0)
+ compress_type_override = COMPRESS_LEGACY;
+ else {
+ return (false);
+ }
+ }
+ return (true);
+}
+
+static const char *
+compression_type_name(enum compress_types_enum type)
+{
+
+ if (type == COMPRESS_LEGACY)
+ return ("legacy");
+ else
+ return (compress_type[type].name);
+}
+
static fk_entry
do_entry(struct conf_entry * ent)
{
@@ -628,8 +663,13 @@
if (ent->rotate && !norotate) {
if (temp_reason[0] != '\0')
ent->r_reason = strdup(temp_reason);
- if (verbose)
- printf("--> trimming log....\n");
+ if (verbose) {
+ if (ent->compress == COMPRESS_NONE)
+ printf("--> trimming log....\n");
+ else
+ printf("--> trimming log and compressing with %s....\n",
+ compression_type_name(ent->compress));
+ }
if (noaction && !verbose)
printf("%s <%d%s>: trimming\n", ent->log,
ent->numlogs,
@@ -647,7 +687,7 @@
static void
parse_args(int argc, char **argv)
{
- int ch, i;
+ int ch;
char *p;
timenow = ptime_init(NULL);
@@ -667,20 +707,11 @@
archdirname = optarg;
break;
case 'c':
- for (i = 0; i < COMPRESS_TYPES; i++) {
- if (strcmp(optarg, compress_type[i].name) == 0) {
- compress_type_override = i;
- break;
- }
- }
- if (i == COMPRESS_TYPES) {
- if (strcmp(optarg, "legacy") == 0)
- compress_type_override = COMPRESS_LEGACY;
- else {
- warnx("Unrecognized compression method '%s'.", optarg);
- usage();
- }
+ if (!parse_compression_type(optarg, &compress_type_override)) {
+ warnx("Unrecognized compression method '%s'.", optarg);
+ usage();
}
+ compress_type_set = true;
break;
case 'd':
destdir = optarg;
@@ -1187,6 +1218,36 @@
} else
add_to_queue(q, inclist);
continue;
+ } else if (strcasecmp(COMPRESS_MARKER, q) == 0) {
+ enum compress_types_enum result;
+
+ if (verbose)
+ printf("Found: %s", errline);
+ q = parse = missing_field(sob(parse + 1), errline);
+ parse = son(parse);
+ if (!*parse)
+ warnx("compress line specifies no option:\n%s",
+ errline);
+ else {
+ *parse = '\0';
+ if (parse_compression_type(q, &result)) {
+ if (compress_type_set) {
+ warnx("Ignoring compress line "
+ "option '%s', using '%s' instead",
+ q,
+ compression_type_name(compress_type_override));
+ } else {
+ if (compress_type_seen)
+ warnx("Compress type should appear before all log files:\n%s",
+ errline);
+ compress_type_override = result;
+ compress_type_set = true;
+ }
+ } else {
+ warnx("Bad compress option '%s'", q);
+ };
+ }
+ continue;
}
#define badline(msg, ...) do { \
@@ -1357,6 +1418,7 @@
working->compress = COMPRESS_BZIP2;
else
working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case 'n':
working->flags |= CE_NOSIGNAL;
@@ -1381,18 +1443,21 @@
working->compress = COMPRESS_XZ;
else
working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case 'y':
if (compress_type_override == COMPRESS_LEGACY)
working->compress = COMPRESS_ZSTD;
else
working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case 'z':
if (compress_type_override == COMPRESS_LEGACY)
working->compress = COMPRESS_GZIP;
else
working->compress = compress_type_override;
+ compress_type_seen = true;
break;
case '-':
break;
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,7 @@
# configuration file for newsyslog
#
+# Global compress method for files tagged as compressible.
+<compress> none
# 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 22, 2023
+.Dd December 25, 2023
.Dt NEWSYSLOG.CONF 5
.Os
.Sh NAME
@@ -67,11 +67,24 @@
.Bl -tag -width indent
.It Ar logfile_name
Name of the system log file to be archived,
-or one of the literal strings
-.Dq Aq Li default ,
+or one of the special strings
+.Dq Li <compress> ,
+.Dq Li <default> ,
or
-.Dq Aq Li include .
-The special default entry will only be used if a log file
+.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.
+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
diff --git a/usr.sbin/newsyslog/tests/legacy_test.sh b/usr.sbin/newsyslog/tests/legacy_test.sh
--- a/usr.sbin/newsyslog/tests/legacy_test.sh
+++ b/usr.sbin/newsyslog/tests/legacy_test.sh
@@ -206,7 +206,7 @@
run_newsyslog()
{
- newsyslog -f ../newsyslog.conf -F -r "$@"
+ newsyslog -f ../newsyslog.conf -F -r -c legacy "$@"
}
tests_normal_rotate() {

File Metadata

Mime Type
text/plain
Expires
Thu, Aug 27, 3:50 AM (5 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29471065
Default Alt Text
D43169.1787802649.diff (8 KB)

Event Timeline