<?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>170739</bug_id>
          
          <creation_ts>2007-03-13 14:44 0000</creation_ts>
          <short_desc>app-antivirus/clamav with logrotate = broken perm for log files</short_desc>
          <delta_ts>2007-04-10 20:04:56 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>Ebuilds</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>TEST-REQUEST</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>bor@univ.kiev.ua</reporter>
          <assigned_to>antivirus@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>bor@univ.kiev.ua</who>
            <bug_when>2007-03-13 14:44:15 0000</bug_when>
            <thetext>Yesterday my mail don&apos;t received
and I see in log

Mar 13 09:01:45 gameinside X-Qmail-Scanner-1.25st: [gameinside.ua117376930571811663] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2
Mar 13 09:03:04 gameinside X-Qmail-Scanner-1.25st: [gameinside.ua117376938371811829] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

After discover the problem I found that clamav logrotate file contain
create 640 clamav clamav
and after this
-rw-r-----  1 clamav clamav     0 2007-03-13 14:46 clamd.log
before I have
-rw-r-----  1 qscand qscand  1813 2007-03-13 14:28 clamd.log

# /etc/init.d/clamd start
 * Starting clamd ...
Running as user qscand (UID 210, GID 210)
ERROR: Can&apos;t open /var/log/clamav/clamd.log in append mode (check permissions!).
ERROR: Problem with internal logger. Please check the permissions on the /var/log/clamav/clamd.log file.
 * Failed to start clamd                                                                                               [ !! ]
 * Starting freshclam ...
ERROR: Can&apos;t open /var/log/clamav/freshclam.log in append mode (check permissions!).
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
 * Failed to start freshclam                                                                                           [ !! ]
and strange status set
# /etc/init.d/clamd start
 * WARNING:  clamd has already been started.


clamav init.d script try chown log file only in milter mode (why not for all ?)

so in logrotate file put code like
local clamav_user=`awk &apos;$1 == &quot;User&quot; { print $2 }&apos; /etc/clamd.conf`
from init.d script
or
in this init.d script try fix perms always</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ticho@gentoo.org</who>
            <bug_when>2007-03-15 13:27:10 0000</bug_when>
            <thetext>You&apos;re right. In the past, the initscript changed owner of both log files to user clamav (hardcoded). Then the code was removed. I guess I never thought of that because I never hit the bug you describe.

Anyway, the initscript now changes ownership of both logs to correct user (parsed from config files). Thanks for suggestion!</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bor@univ.kiev.ua</who>
            <bug_when>2007-03-16 12:04:37 0000</bug_when>
            <thetext>I also suggest

in logrotate file change

    postrotate
         /bin/kill -HUP `cat /var/run/clamav/clamd.pid 2&gt; /dev/null` 2&gt;/dev/null || true

to

    postrotate
         /etc/init.d/clamd restart 2&gt;/dev/null || true

because before it
 create 640 clamav clamav

and log files create under clamav clamav

or remove this string anywhere</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bor@univ.kiev.ua</who>
            <bug_when>2007-03-21 20:36:41 0000</bug_when>
            <thetext>I think - I must reopen bug for pay attention my previous comment
problem still exists unless fix logrotate file</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ticho@gentoo.org</who>
            <bug_when>2007-03-25 19:26:39 0000</bug_when>
            <thetext>Ok, I moved permission/ownership fix to a separate logfix() function in the initscript, which is called from start(), as well as from the logrotate script. How does that sound?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bor@univ.kiev.ua</who>
            <bug_when>2007-03-26 11:26:36 0000</bug_when>
            <thetext>permission now ok
but you not reload clamav :(
so clamd use old open pipe
lsof show
clamd     16701   qscand    3w      REG        8,3     30511     267443 /var/log/clamav/clamd.log.1 (deleted)

please change (in clamav.logrotate)
/etc/init.d/clamd logfix
to
/etc/init.d/clamd restart</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ticho@gentoo.org</who>
            <bug_when>2007-03-27 10:03:11 0000</bug_when>
            <thetext>A better idea is to reload clamd/freshclam using SIGHUP, just like before. This time, however it is after permissions are fixed, so all should be peachy.

Changes committed.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bor@univ.kiev.ua</who>
            <bug_when>2007-03-30 12:31:55 0000</bug_when>
            <thetext>now all ok
thanks</thetext>
          </long_desc>
      
    </bug>

</bugzilla>