[Midnightbsd-cvs] src [8613] trunk/usr.sbin/newsyslog: have -n imply -r and make sure to update the mtime of a logfile after archiving it.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 13:38:53 EDT 2016
Revision: 8613
http://svnweb.midnightbsd.org/src/?rev=8613
Author: laffer1
Date: 2016-09-25 13:38:53 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
have -n imply -r and make sure to update the mtime of a logfile after archiving it.
Modified Paths:
--------------
trunk/usr.sbin/newsyslog/newsyslog.8
trunk/usr.sbin/newsyslog/newsyslog.c
Modified: trunk/usr.sbin/newsyslog/newsyslog.8
===================================================================
--- trunk/usr.sbin/newsyslog/newsyslog.8 2016-09-25 17:36:39 UTC (rev 8612)
+++ trunk/usr.sbin/newsyslog/newsyslog.8 2016-09-25 17:38:53 UTC (rev 8613)
@@ -125,7 +125,9 @@
Cause
.Nm
not to trim the logs, but to print out what it would do if this option
-were not specified.
+were not specified. This option implies the
+.Fl r
+option.
.It Fl r
Remove the restriction that
.Nm
Modified: trunk/usr.sbin/newsyslog/newsyslog.c
===================================================================
--- trunk/usr.sbin/newsyslog/newsyslog.c 2016-09-25 17:36:39 UTC (rev 8612)
+++ trunk/usr.sbin/newsyslog/newsyslog.c 2016-09-25 17:38:53 UTC (rev 8613)
@@ -642,7 +642,7 @@
break;
case 'n':
noaction++;
- break;
+ /* FALLTHROUGH */
case 'r':
needroot = 0;
break;
@@ -1580,7 +1580,7 @@
oldlogs[i].fname);
else if (unlinkat(dirfd, oldlogs[i].fname, 0) != 0) {
snprintf(errbuf, sizeof(errbuf),
- "Could not delet old logfile '%s'",
+ "Could not delete old logfile '%s'",
oldlogs[i].fname);
perror(errbuf);
}
@@ -1812,6 +1812,9 @@
printf("\tcp %s %s\n", ent->log, file1);
else
printf("\tln %s %s\n", ent->log, file1);
+ printf("\ttouch %s\t\t"
+ "# Update mtime for 'when'-interval processing\n",
+ file1);
} else {
if (!(flags & CE_BINARY)) {
/* Report the trimming to the old log */
@@ -1818,6 +1821,12 @@
log_trim(ent->log, ent);
}
savelog(ent->log, file1);
+ /*
+ * Interval-based rotations are done using the mtime of
+ * the most recently archived log, so make sure it gets
+ * updated during a rotation.
+ */
+ utimes(file1, NULL);
}
change_attrs(file1, ent);
}
More information about the Midnightbsd-cvs
mailing list