<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>107906</bug_id>
          
          <creation_ts>2005-10-02 09:04 0000</creation_ts>
          <short_desc>[PATCH] Logrotate-3.7.1 weekly rotation is not working</short_desc>
          <delta_ts>2005-10-15 15:10:36 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <keywords>Inclusion</keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>boriz@home.nl</reporter>
          <assigned_to>dang@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>boriz@home.nl</who>
            <bug_when>2005-10-02 09:04:00 0000</bug_when>
            <thetext>http://forums.gentoo.org/viewtopic-p-2769131.html    
    
The bug is lenghtily outlined there.    
    
Short version: Logrotate does not rotate weekly items correctly.   
   
I made a patch which applies cleanly against logrotate.3.7.1-r1. I made a  
revised ebuild which installed no problems on my system. I haven&apos;t tested the  
changes for correctness yet, as that requires some time.  
  
Here&apos;s the patch  
 
--- logrotate-3.7.1-old/logrotate.c     2004-10-19 23:41:24.000000000 +0200  
 +++ logrotate-3.7.1-new/logrotate.c     2005-10-02 17:29:22.380767321 +0200  
 @@ -424,12 +424,15 @@ int findNeedRotating(logInfo * log, int  
          switch (log-&gt;criterium) {  
            case ROT_WEEKLY:  
              /* rotate if:  
 -                  1) the current weekday is before the weekday of the  
 -                     last rotation  
 +                  1) the day of the week is the same as the day of the week 
of  
 +                     the previous rotation but not the same day of the year  
 +                     this will rotate it on the same day every week, but not  
 +                     twice a day.  
                    2) more then a week has passed since the last  
                       rotation */  
 -            state-&gt;doRotate = ((now.tm_wday &lt; state-&gt;lastRotated.tm_wday) ||  
 -                              ((mktime(&amp;now) - mktime(&amp;state-&gt;lastRotated)) 
&gt;  
 +            state-&gt;doRotate = ((now.tm_wday == state-&gt;lastRotated.tm_wday &amp;&amp;  
 +                               now.tm_yday != state-&gt;lastRotated.tm_yday) ||  
 +                               ((mktime(&amp;now) - mktime(&amp;state-&gt;lastRotated)) 
&gt;  
                                 (7 * 24 * 3600)));  
              break;  
            case ROT_MONTHLY:</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>boriz@home.nl</who>
            <bug_when>2005-10-02 09:05:48 0000</bug_when>
            <thetext>Created an attachment (id=69735)
patch for the problem.

Please review changes for correctness.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>boriz@home.nl</who>
            <bug_when>2005-10-09 00:24:30 0000</bug_when>
            <thetext>It works:

-rw-------  1 root    root      57996 Oct  9 09:19 messages
-rw-------  1 root    root     155760 Oct  9 00:10 messages.1.gz
-rw-------  1 root    root     197750 Oct  2 18:53 messages.2.gz

logrotate -d shows this right now (9:20):

rotating pattern: /var/log/messages  weekly (52 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/messages
  log does not need rotating</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dang@gentoo.org</who>
            <bug_when>2005-10-10 12:30:51 0000</bug_when>
            <thetext>Thanks.  I&apos;ll add the patch hopefully tonight.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dang@gentoo.org</who>
            <bug_when>2005-10-15 15:10:36 0000</bug_when>
            <thetext>fixed in 3.7.1-r2.  Sorry for the delay.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>69735</attachid>
            <date>2005-10-02 09:05 0000</date>
            <desc>patch for the problem.</desc>
            <filename>logrotate-3.7.1-weekly.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGxvZ3JvdGF0ZS0zLjcuMS1vbGQvbG9ncm90YXRlLmMJMjAwNC0xMC0xOSAyMzo0MToyNC4w
MDAwMDAwMDAgKzAyMDAKKysrIGxvZ3JvdGF0ZS0zLjcuMS1uZXcvbG9ncm90YXRlLmMJMjAwNS0x
MC0wMiAxNzoyOToyMi4zODA3NjczMjEgKzAyMDAKQEAgLTQyNCwxMiArNDI0LDE1IEBAIGludCBm
aW5kTmVlZFJvdGF0aW5nKGxvZ0luZm8gKiBsb2csIGludCAKICAgICAgICAgc3dpdGNoIChsb2ct
PmNyaXRlcml1bSkgewogICAgICAgICAgIGNhc2UgUk9UX1dFRUtMWToKICAgICAgICAgICAgIC8q
IHJvdGF0ZSBpZjoKLSAgICAgICAgICAgICAgICAgIDEpIHRoZSBjdXJyZW50IHdlZWtkYXkgaXMg
YmVmb3JlIHRoZSB3ZWVrZGF5IG9mIHRoZQotICAgICAgICAgICAgICAgICAgICAgbGFzdCByb3Rh
dGlvbgorICAgICAgICAgICAgICAgICAgMSkgdGhlIGRheSBvZiB0aGUgd2VlayBpcyB0aGUgc2Ft
ZSBhcyB0aGUgZGF5IG9mIHRoZSB3ZWVrIG9mCisgICAgICAgICAgICAgICAgICAgICB0aGUgcHJl
dmlvdXMgcm90YXRpb24gYnV0IG5vdCB0aGUgc2FtZSBkYXkgb2YgdGhlIHllYXIKKyAgICAgICAg
ICAgICAgICAgICAgIHRoaXMgd2lsbCByb3RhdGUgaXQgb24gdGhlIHNhbWUgZGF5IGV2ZXJ5IHdl
ZWssIGJ1dCBub3QKKyAgICAgICAgICAgICAgICAgICAgIHR3aWNlIGEgZGF5LgogICAgICAgICAg
ICAgICAgICAgMikgbW9yZSB0aGVuIGEgd2VlayBoYXMgcGFzc2VkIHNpbmNlIHRoZSBsYXN0CiAg
ICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiAqLwotICAgICAgICAgICAgc3RhdGUtPmRvUm90
YXRlID0gKChub3cudG1fd2RheSA8IHN0YXRlLT5sYXN0Um90YXRlZC50bV93ZGF5KSB8fAotCQkJ
ICAgICAgICgobWt0aW1lKCZub3cpIC0gbWt0aW1lKCZzdGF0ZS0+bGFzdFJvdGF0ZWQpKSA+Cisg
ICAgICAgICAgICBzdGF0ZS0+ZG9Sb3RhdGUgPSAoKG5vdy50bV93ZGF5ID09IHN0YXRlLT5sYXN0
Um90YXRlZC50bV93ZGF5ICYmCisJCQkJbm93LnRtX3lkYXkgIT0gc3RhdGUtPmxhc3RSb3RhdGVk
LnRtX3lkYXkpIHx8CisJCQkJKChta3RpbWUoJm5vdykgLSBta3RpbWUoJnN0YXRlLT5sYXN0Um90
YXRlZCkpID4KIAkJCQkoNyAqIDI0ICogMzYwMCkpKTsKICAgICAgICAgICAgIGJyZWFrOwogICAg
ICAgICAgIGNhc2UgUk9UX01PTlRITFk6Cg==
</data>        

          </attachment>
    </bug>

</bugzilla>