NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/40274: newsyslog(8)'s "P" flag stops rotating log files.



The following reply was made to PR bin/40274; it has been noted by GNATS.

From: Takahiro Kambe <taca%back-street.net@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/40274: newsyslog(8)'s "P" flag stops rotating log files.
Date: Fri, 26 Dec 2008 11:53:44 +0900 (JST)

 Oops, I sent to wrong address.
 
 In message <20081226021501.3EF4163BC6A%narn.NetBSD.org@localhost>
        on Fri, 26 Dec 2008 02:15:01 +0000 (UTC),
        taca%back-street.net@localhost wrote:
 > >Fix:
 >      Unknown, just looking for codes.
 * Compress all old log files even if "P" flag is specigied
 * Compress old log files before log rotatation.
 
 Seems to work for me.
 
 Index: newsyslog.c
 ===================================================================
 RCS file: /cvs/src-5/usr.bin/newsyslog/newsyslog.c,v
 retrieving revision 1.1.1.1
 diff -u -r1.1.1.1 newsyslog.c
 --- newsyslog.c        8 Dec 2008 02:03:29 -0000       1.1.1.1
 +++ newsyslog.c        26 Dec 2008 02:26:23 -0000
 @@ -538,6 +538,25 @@
                }
        }
  
 +      /*
 +       * If a historical log file isn't compressed, and 'z' has been
 +       * specified, compress it.  (This is convenient, but is also needed
 +       * if 'p' has been specified.)  It should be noted that gzip(1)
 +       * preserves file ownership and file mode.
 +       */
 +      if (ziptype) {
 +              for (i = 0; i < log->numhist; i++) {
 +                      snprintf(file1, sizeof(file1), "%s.%d", log->logfile, 
i);
 +                      if (lstat(file1, &st) != 0)
 +                              continue;
 +                      snprintf(file2, sizeof(file2), "%s%s", file1,
 +                          compress[ziptype].suffix);
 +                      if (lstat(file2, &st) == 0)
 +                              continue;
 +                      log_compress(log, file1);
 +              }
 +      }
 +
        /* Move down log files. */
        for (i = log->numhist - 1; i > 0; i--) {
                for (j = 0; j < (int)__arraycount(compress); j++) {
 @@ -565,25 +584,6 @@
                                err(EXIT_FAILURE, "%s", file2);
        }
  
 -      /*
 -       * If a historical log file isn't compressed, and 'z' has been
 -       * specified, compress it.  (This is convenient, but is also needed
 -       * if 'p' has been specified.)  It should be noted that gzip(1)
 -       * preserves file ownership and file mode.
 -       */
 -      if (ziptype) {
 -              for (i = (log->flags & CE_PLAIN0) != 0; i < log->numhist; i++) {
 -                      snprintf(file1, sizeof(file1), "%s.%d", log->logfile, 
i);
 -                      if (lstat(file1, &st) != 0)
 -                              continue;
 -                      snprintf(file2, sizeof(file2), "%s%s", file1,
 -                          compress[ziptype].suffix);
 -                      if (lstat(file2, &st) == 0)
 -                              continue;
 -                      log_compress(log, file1);
 -              }
 -      }
 -
        log_trimmed(log);
  
        /* Create the historical log file if we're maintaining history. */
 
 


Home | Main Index | Thread Index | Old Index