Log file size is limited to 4G

Bug #685311 reported by Stepan Koltsov
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
logrotate (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: logrotate

logrotate internally stores threshhold as unsigned int. Thus file rotation cannot be setup to value greater than 4G. Worst thing is that logrotate quietly rounds file size, and it size is specified as 9G, effective size will be 1G.

Patch is:

===
Index: logrotate-3.7.8/logrotate.c
===================================================================
--- logrotate-3.7.8.orig/logrotate.c 2010-12-05 00:22:38.000000000 +0300
+++ logrotate-3.7.8/logrotate.c 2010-12-05 00:30:58.000000000 +0300
@@ -1253,7 +1253,7 @@
     message(MESS_DEBUG, "\nrotating pattern: %s ", log->pattern);
     switch (log->criterium) {
     case ROT_DAYS:
- message(MESS_DEBUG, "after %d days ", log->threshhold);
+ message(MESS_DEBUG, "after %lld days ", (long long) log->threshhold);
        break;
     case ROT_WEEKLY:
        message(MESS_DEBUG, "weekly ");
@@ -1265,7 +1265,7 @@
        message(MESS_DEBUG, "yearly ");
        break;
     case ROT_SIZE:
- message(MESS_DEBUG, "%d bytes ", log->threshhold);
+ message(MESS_DEBUG, "%lld bytes ", (long long) log->threshhold);
        break;
     case ROT_FORCE:
        message(MESS_DEBUG, "forced from command line ");
@@ -1286,7 +1286,7 @@
        message(MESS_DEBUG, "empty log files are not rotated, ");

     if (log->minsize)
- message(MESS_DEBUG, "only log files >= %d bytes are rotated, ", log->minsize);
+ message(MESS_DEBUG, "only log files >= %lld bytes are rotated, ", (long long) log->minsize);

     if (log->logAddress) {
        message(MESS_DEBUG, "old logs mailed to %s\n", log->logAddress);
Index: logrotate-3.7.8/logrotate.h
===================================================================
--- logrotate-3.7.8.orig/logrotate.h 2010-12-05 00:21:24.000000000 +0300
+++ logrotate-3.7.8/logrotate.h 2010-12-05 00:22:00.000000000 +0300
@@ -33,8 +33,8 @@
     char *oldDir;
     enum { ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_YEARLY, ROT_SIZE,
            ROT_FORCE } criterium;
- unsigned int threshhold;
- unsigned int minsize;
+ off_t threshhold;
+ off_t minsize;
     int rotateCount;
     int rotateAge;
     int logStart;
Index: logrotate-3.7.8/config.c
===================================================================
--- logrotate-3.7.8.orig/config.c 2010-12-05 00:31:32.000000000 +0300
+++ logrotate-3.7.8/config.c 2010-12-05 00:32:57.000000000 +0300
@@ -484,7 +484,7 @@
     char oldchar, foo;
     off_t length;
     int lineNum = 1;
- int multiplier;
+ off_t multiplier;
     int i, k;
     char *scriptStart = NULL;
     char **scriptDest = NULL;
@@ -792,7 +792,7 @@

                *endtag = oldchar, start = endtag;
            } else if (!strcmp(start, "size") || !strcmp(start, "minsize")) {
- unsigned int size = 0;
+ off_t size = 0;
                char *opt = start;
                *endtag = oldchar, start = endtag;
 ===

Tags: patch
Revision history for this message
Stepan Koltsov (yozh) wrote :

Is anybody there? Bug is easy to understand and easy to fix, patch provided. What are you waiting for?

Sergey Svishchev (svs)
tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in logrotate (Ubuntu):
status: New → Confirmed
Revision history for this message
Kevin A. V. (kevinava) wrote :

This bug seems to start at size setting over 2000M.

When size is set to 2000M logrotate works as intended, rotates the log.

However if size is set to 2100M, 2G or higher logrotate will fail rotating logs.
Eg. Logs get rotated at wrong size.

File size during tests are approx 2.3GB and should therefore not need rotation.

Debug log from size is set to 4G

rotating pattern: /monitoring/logs/dir/filename.log
 0 bytes (7 rotations)
empty log files are not rotated, old logs are removed
considering log /monitoring/logs/dir/filename.log
  log needs rotating

 When size is set to 4000M.

rotating pattern: /monitoring/logs/dir/filename.log
 -100663296 bytes (7 rotations)
empty log files are not rotated, old logs are removed
considering log /monitoring/logs/dir/filename.log
  log needs rotating

Revision history for this message
Kevin A. V. (kevinava) wrote :

Hi, all the bugs for my part was resolved by installing the latest version of logrotate from srouce.

Ref. http://pkgs.fedoraproject.org/repo/pkgs/logrotate/logrotate-3.8.3.tar.gz/df67c8bda9139131d919931da443794d/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.