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

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/9/usr.sbin/newsyslog/newsyslog.8
  stable/9/usr.sbin/newsyslog/newsyslog.c
Directory Properties:
  stable/9/usr.sbin/newsyslog/   (props changed)

Modified: stable/9/usr.sbin/newsyslog/newsyslog.8
==============================================================================
--- stable/9/usr.sbin/newsyslog/newsyslog.8     Sun Jan 13 04:14:30 2013        
(r245359)
+++ stable/9/usr.sbin/newsyslog/newsyslog.8     Sun Jan 13 04:14:46 2013        
(r245360)
@@ -125,7 +125,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/9/usr.sbin/newsyslog/newsyslog.c
==============================================================================
--- stable/9/usr.sbin/newsyslog/newsyslog.c     Sun Jan 13 04:14:30 2013        
(r245359)
+++ stable/9/usr.sbin/newsyslog/newsyslog.c     Sun Jan 13 04:14:46 2013        
(r245360)
@@ -642,7 +642,7 @@ parse_args(int argc, char **argv)
                        break;
                case 'n':
                        noaction++;
-                       break;
+                       /* FALLTHROUGH */
                case 'r':
                        needroot = 0;
                        break;
@@ -1580,7 +1580,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);
                        }
@@ -1812,12 +1812,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);
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to