svn commit: r245359 - stable/8/usr.sbin/newsyslog

Mark Johnston markj at FreeBSD.org
Sun Jan 13 04:14:31 UTC 2013


Author: markj
Date: Sun Jan 13 04:14:30 2013
New Revision: 245359
URL: http://svnweb.freebsd.org/changeset/base/245359

Log:
  MFC r244995 r244996 r244997.
  
  MFC r244995:
    Fix a typo in an error message.
  
  MFC r244996:
    Have -n imply -r, since dry-run mode obviously doesn't require root
    privileges.
  
  MFC r244997:
    Make sure to update the mtime of a logfile after archiving it. This
    ensures that the next rotation happens at the correct time when using
    interval-based rotations.
  
  Approved by:	rstone (co-mentor)

Modified:
  stable/8/usr.sbin/newsyslog/newsyslog.8
  stable/8/usr.sbin/newsyslog/newsyslog.c
Directory Properties:
  stable/8/usr.sbin/newsyslog/   (props changed)

Modified: stable/8/usr.sbin/newsyslog/newsyslog.8
==============================================================================
--- stable/8/usr.sbin/newsyslog/newsyslog.8	Sun Jan 13 04:13:45 2013	(r245358)
+++ stable/8/usr.sbin/newsyslog/newsyslog.8	Sun Jan 13 04:14:30 2013	(r245359)
@@ -126,7 +126,9 @@ reasons for either trimming that log or 
 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: stable/8/usr.sbin/newsyslog/newsyslog.c
==============================================================================
--- stable/8/usr.sbin/newsyslog/newsyslog.c	Sun Jan 13 04:13:45 2013	(r245358)
+++ stable/8/usr.sbin/newsyslog/newsyslog.c	Sun Jan 13 04:14:30 2013	(r245359)
@@ -639,7 +639,7 @@ parse_args(int argc, char **argv)
 			break;
 		case 'n':
 			noaction++;
-			break;
+			/* FALLTHROUGH */
 		case 'r':
 			needroot = 0;
 			break;
@@ -1576,7 +1576,7 @@ delete_oldest_timelog(const struct conf_
 				    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);
 			}
@@ -1778,12 +1778,21 @@ do_rotate(const struct conf_entry *ent)
 				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 */
 				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 svn-src-stable-8 mailing list