NetBSD-Bugs archive

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

bin/40635: newsyslog(8) overwrites logs too early if `p' flag is set (patch supplied)



>Number:         40635
>Category:       bin
>Synopsis:       newsyslog(8) overwrites logs too early if `p' flag is set 
>(patch supplied)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 14 01:00:01 +0000 2009
>Originator:     Jukka Salmi
>Release:        NetBSD 5.99.5
>Organization:
>Environment:
System: NetBSD moray.salmi.ch 5.99.5 NetBSD 5.99.5 (GENERIC) #0: Fri Jan 2 
17:20:03 CET 2009 
root%moray.salmi.ch@localhost:/b/build/nbsd/c/i386/sys/arch/i386/compile/GENERIC
 i386
Architecture: i386
Machine: i386
>Description:
If in newsyslog.conf(5) the `p' flag ("don't compress the .0 file") is
specified, the logfile in question is not archived correctly:  only the current
version and the .0 file are kept, no matter what the `ngen' field is set to.
This means that one migh loose log files earlier than expected.
>How-To-Repeat:
$ cd /tmp
$ echo '/tmp/testlog 640 7 0 * PZ' >newsyslog.conf # keep 7 archived versions
$ touch testlog
$ ls -l testlog*
-rw-r--r--  1 jukka  wheel  0 Feb 14 01:55 testlog
$ newsyslog -f newsyslog.conf -rs
$ ls -l testlog*
-rw-r-----  1 jukka  jukka  69 Feb 14 01:55 testlog
-rw-r--r--  1 jukka  wheel  69 Feb 14 01:55 testlog.0
$ newsyslog -f newsyslog.conf -rs
$ ls -l testlog*
-rw-r-----  1 jukka  jukka   70 Feb 14 01:55 testlog
-rw-r-----  1 jukka  jukka  139 Feb 14 01:55 testlog.0

During the second newsyslog(8) run, `testlog.0' should have been moved and
compressed to `testlog.1.gz'.  This didn't happen and the file was overwritten
by the file `testlog'.

>Fix:
Seems to be just a typo:

Index: usr.bin/newsyslog/newsyslog.c
===================================================================
RCS file: /cvsroot/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.56
diff -u -p -r1.56 newsyslog.c
--- usr.bin/newsyslog/newsyslog.c       29 Dec 2008 01:35:09 -0000      1.56
+++ usr.bin/newsyslog/newsyslog.c       14 Feb 2009 00:32:12 -0000
@@ -540,9 +540,9 @@ log_trim(struct conf_entry *log)
        for (i = log->numhist - 1; i > 0; i--) {
                for (j = 0; j < (int)__arraycount(compress); j++) {
                        snprintf(file1, sizeof(file1), "%s.%d%s", log->logfile,
-                           i - 1, compress[ziptype].suffix);
+                           i - 1, compress[j].suffix);
                        snprintf(file2, sizeof(file2), "%s.%d%s", log->logfile,
-                           i, compress[ziptype].suffix);
+                           i, compress[j].suffix);
                        k = lstat(file1, &st);
                        if (!k) break;
                }



Home | Main Index | Thread Index | Old Index