~ubuntu-branches/ubuntu/hardy/logrotate/hardy-updates

« back to all changes in this revision

Viewing changes to debian/patches/rh-maxage.patch

  • Committer: Bazaar Package Importer
  • Author(s): Paul Martin
  • Date: 2006-04-08 23:02:19 UTC
  • mfrom: (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20060408230219-7moi9qw2g42w1nye
Tags: 3.7.1-3
* Patch debian/control to fix FTBFS on kfreebsd-amd64. Perhaps we need
  a build-depends macro for !kfreebsd. (Closes: #361465)
* Use and depend on debhelper version 5.
* Switch from dpatch to quilt.
* cpp-crossbuild.patch: change from using $(CPP) to $(CC) -E.
  Thanks to NIIBE Yutaka. (Closes: #284040)
* dst.patch: fix mktime initialisation so that daylight savings is
  taken into account. Thanks to Holger Weiss. (Closes: #278591)
* man-333996.patch: fix typos in logrotate.8 where "then" should be
  "than". Thanks to Adrian Knoth. (Closes: #333996)
* manpage.patch: Apply missed fixes from #101272. Thanks to J S Bygott.
  (Closes: #335060)
* script-argument.patch: Allow the use of $1 in scripts again.
  (Closes: #330783)
* README.Debian: Document that sysklogd does its own log rotation.
  (Closes: #308963)
* README.Debian: Document how scripts are called. (Closes: #308920)
* Update the copyright file.
* debian/control: remove versioned dependency on cron. The version of
  cron forbidden pre-dates woody (currently "oldstable") by several
  years. This versioned dependency is preventing logrotate being
  installed with bcron. (Closes: #304038, #349150)
* debian/rules: Fix backports, allowing them to use selinux.
  (Closes: #340363)
* uncompressChild-warning.patch: Fix a "might be used uninitialised" 
  warning from gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Enhance logrotate with "maxage".
 
2
From upstream RedHat patch.
 
3
 
 
4
Index: logrotate-3.7.1/logrotate.c
 
5
===================================================================
 
6
--- logrotate-3.7.1.orig/logrotate.c    2006-04-08 20:38:58.277761983 +0100
 
7
+++ logrotate-3.7.1/logrotate.c 2006-04-08 20:38:58.314755223 +0100
 
8
@@ -640,7 +640,10 @@
 
9
             * the date in their name */
 
10
            for (i = 0; i < globResult.gl_pathc; i++) {
 
11
                if( !stat((globResult.gl_pathv)[i],&fst_buf) ) {
 
12
-                   if (i <= ((int)globResult.gl_pathc - rotateCount)) {
 
13
+                   if ((i <= ((int)globResult.gl_pathc - rotateCount)) 
 
14
+                       || ((log->rotateAge > 0)
 
15
+                           && (((nowSecs - fst_buf.st_mtime)/60/60/24)
 
16
+                               > log->rotateAge))) {
 
17
                        if ( mail_out != -1 ) {
 
18
                            if (!hasErrors && log->logAddress) {
 
19
                                char * mailFilename = (globResult.gl_pathv)[mail_out];
 
20
@@ -670,6 +673,22 @@
 
21
        globfree(&globResult);
 
22
        free(glob_pattern);
 
23
     } else {
 
24
+       if ( log->rotateAge ) {
 
25
+           struct stat fst_buf;
 
26
+           for (i=1; i <= rotateCount; i++) {
 
27
+               sprintf(oldName, "%s/%s.%d%s%s", dirName, baseName,
 
28
+                       rotateCount + 1, fileext, compext);
 
29
+               if(!stat(oldName,&fst_buf)
 
30
+                   && (((nowSecs - fst_buf.st_mtime)/60/60/24)
 
31
+                       > log->rotateAge)) {
 
32
+                   char * mailFilename = (globResult.gl_pathv)[i];
 
33
+                   if (!hasErrors && log->logAddress)
 
34
+                       hasErrors = mailLogWrapper(mailFilename, mailCommand, logNum, log);
 
35
+                   if (!hasErrors)
 
36
+                       hasErrors = removeLogFile(mailFilename);
 
37
+               }
 
38
+           }
 
39
+       }
 
40
 
 
41
     sprintf(oldName, "%s/%s.%d%s%s", dirName, baseName,
 
42
             logStart + rotateCount, fileext, compext);
 
43
@@ -1188,7 +1207,9 @@
 
44
 
 
45
 int main(int argc, const char ** argv) {
 
46
     logInfo defConfig = { NULL, NULL, 0, NULL, ROT_SIZE, 
 
47
-                         /* threshHold */ 1024 * 1024, 0,
 
48
+                         /* threshHold */ 1024 * 1024,
 
49
+                         /* rotateCount */ 0,
 
50
+                         /* rotateAge */ 0,
 
51
                          /* log start */ -1,
 
52
                          /* pre, post */ NULL, NULL,
 
53
                          /* first, last */ NULL, NULL,
 
54
Index: logrotate-3.7.1/logrotate.h
 
55
===================================================================
 
56
--- logrotate-3.7.1.orig/logrotate.h    2006-04-08 20:38:58.274762531 +0100
 
57
+++ logrotate-3.7.1/logrotate.h 2006-04-08 20:38:58.315755040 +0100
 
58
@@ -35,6 +35,7 @@
 
59
     enum { ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_SIZE, ROT_FORCE } criterium;
 
60
     unsigned int threshhold;
 
61
     int rotateCount;
 
62
+    int rotateAge;
 
63
     int logStart;
 
64
     char * pre, * post, * first, * last;
 
65
     char * logAddress;
 
66
Index: logrotate-3.7.1/config.c
 
67
===================================================================
 
68
--- logrotate-3.7.1.orig/config.c       2006-04-08 20:38:58.279761617 +0100
 
69
+++ logrotate-3.7.1/config.c    2006-04-08 20:38:58.317754675 +0100
 
70
@@ -678,6 +678,21 @@
 
71
                    }
 
72
                    *endtag = oldchar, start = endtag;
 
73
                }
 
74
+           } else if (!strcmp(start, "maxage")) {
 
75
+               *endtag = oldchar, start = endtag;
 
76
+
 
77
+               if (!isolateValue(configFile, lineNum, "maxage count", &start,
 
78
+                                 &endtag)) {
 
79
+                   oldchar = *endtag, *endtag = '\0';
 
80
+
 
81
+                   newlog->rotateAge = strtoul(start, &chptr, 0);
 
82
+                   if (*chptr || newlog->rotateAge < 0) {
 
83
+                       message(MESS_ERROR, "%s:%d bad maximum age '%s'\n",
 
84
+                               configFile, lineNum, start);
 
85
+                       return 1;
 
86
+                   }
 
87
+                   *endtag = oldchar, start = endtag;
 
88
+               }
 
89
            } else if (!strcmp(start, "errors")) {
 
90
                message(MESS_DEBUG, "%s: %d: the errors directive is deprecated and no longer used.\n",
 
91
                        configFile, lineNum);
 
92
Index: logrotate-3.7.1/logrotate.8
 
93
===================================================================
 
94
--- logrotate-3.7.1.orig/logrotate.8    2006-04-08 20:38:58.280761435 +0100
 
95
+++ logrotate-3.7.1/logrotate.8 2006-04-08 20:38:58.318754492 +0100
 
96
@@ -251,6 +251,12 @@
 
97
 instead of the just-rotated file (this is the default).
 
98
 
 
99
 .TP
 
100
+\fBmaxage\fR \fIcount\fR
 
101
+Remove rotated logs older than <count> days. The age is only checked
 
102
+if the logfile is to be rotated. The files are mailed to the
 
103
+configured address if \fBmaillast\fR and \fBmail\fR are configured.
 
104
+
 
105
+.TP
 
106
 \fBmissingok\fR
 
107
 If the log file is missing, go on to the next one without issuing an error
 
108
 message. See also \fBnomissingok\fR.