bin/162798: add p flag to newsyslog.conf
heasley
heas at shrubbery.net
Wed Nov 23 19:50:08 UTC 2011
>Number: 162798
>Category: bin
>Synopsis: add p flag to newsyslog.conf
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 23 19:50:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: heasley
>Release: 10
>Organization:
ntt
>Environment:
>Description:
NetBSD's newsyslog.conf p flag is useful. here's a patch to add it to freebsd.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
--- newsyslog.conf.5.orig 2011-05-14 03:00:55.000000000 +0000
+++ newsyslog.conf.5 2011-11-22 21:38:58.871719491 +0000
@@ -21,7 +21,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd February 25, 2011
+.Dd November 22, 2011
.Dt NEWSYSLOG.CONF 5
.Os
.Sh NAME
@@ -301,6 +301,8 @@
.It Cm N
indicates that there is no process which needs to be signaled
when this log file is rotated.
+.It Cm p
+indicates that the zero-th rotated file should not be compressed.
.It Cm R
if this flag is set the
.Xr newsyslog 8
--- newsyslog.c.orig 2011-05-14 03:00:55.000000000 +0000
+++ newsyslog.c 2011-11-23 19:35:49.689720461 +0000
@@ -126,6 +126,7 @@
#define CE_CREATE 0x0100 /* Create the log file if it does not exist. */
#define CE_NODUMP 0x0200 /* Set 'nodump' on newly created log file. */
#define CE_PID2CMD 0x0400 /* Replace PID file with a shell command.*/
+#define CE_PLAIN0 0x0800 /* Do not compress zero'th history file */
#define MIN_PID 5 /* Don't touch pids lower than this */
#define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */
@@ -1293,6 +1294,9 @@
case 'n':
working->flags |= CE_NOSIGNAL;
break;
+ case 'p':
+ working->flags |= CE_PLAIN0;
+ break;
case 'r':
working->flags |= CE_PID2CMD;
break;
@@ -1312,7 +1316,6 @@
break;
case 'f': /* Used by OpenBSD for "CE_FOLLOW" */
case 'm': /* Used by OpenBSD for "CE_MONITOR" */
- case 'p': /* Used by NetBSD for "CE_PLAIN0" */
default:
errx(1, "illegal flag in config file -- %c",
*q);
@@ -1793,8 +1796,18 @@
else {
/* XXX - Ought to be checking for failure! */
(void)rename(zfile1, zfile2);
+ change_attrs(zfile2, ent);
+ if (ent->compress && !strlen(logfile_suffix)) {
+ /* compress old rotation */
+ struct zipwork_entry zwork;
+
+ memset(&zwork, 0, sizeof(zwork));
+ zwork.zw_conf = ent;
+ zwork.zw_fsize = sizefile(zfile2);
+ strcpy(zwork.zw_fname, zfile2);
+ do_zipwork(&zwork);
+ }
}
- change_attrs(zfile2, ent);
}
if (ent->numlogs > 0) {
@@ -1834,12 +1847,15 @@
if (ent->pid_cmd_file != NULL)
swork = save_sigwork(ent);
if (ent->numlogs > 0 && ent->compress > COMPRESS_NONE) {
- /*
- * The zipwork_entry will include a pointer to this
- * conf_entry, so the conf_entry should not be freed.
- */
- free_or_keep = KEEP_ENT;
- save_zipwork(ent, swork, ent->fsize, file1);
+ if (!(ent->flags & CE_PLAIN0) ||
+ strcmp(&file1[strlen(file1) - 2], ".0") != 0) {
+ /*
+ * The zipwork_entry will include a pointer to this
+ * conf_entry, so the conf_entry should not be freed.
+ */
+ free_or_keep = KEEP_ENT;
+ save_zipwork(ent, swork, ent->fsize, file1);
+ }
}
return (free_or_keep);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list