[Pkg-clamav-devel] Bug#592322: Bug#592322: freshclam.conf: update moves DatabaseMirror line

Török Edwin edwintorok at gmail.com
Wed Aug 11 09:45:20 UTC 2010


On Mon, 9 Aug 2010 23:10:33 +0100
Stephen Gran <sgran at debian.org> wrote:

> This one time, at band camp, Török Edwin said:
> > On Mon, 9 Aug 2010 12:55:32 +0100
> > Stephen Gran <sgran at debian.org> wrote:
> > 
> > > This one time, at band camp, Török Edwin said:
> > > > After updating clamav-freshclam I got this diff:
> > > > --- /etc/clamav/freshclam.conf 2010-06-10 15:40:04.624888178
> > > > +0300 +++ /var/lib/clamav/freshclam.conf 2010-08-09
> > > > 12:03:46.265177327 +0300
> > > 
> > > I agree this is most likely a bug - we're probably not popping
> > > off the list in the same order we push onto it or something.
> > > 
> > > However:
> > > 
> > > > -- Package-specific info:
> > > > --- configuration ---
> > > > Checking configuration files in /usr/local/etc
> > > 
> > > Can you try without local versions installed, just to make sure
> > > nothing funny is happening as a result?
> > 
> > Well I can't reproduce this with an apt-get --reinstall
> > clamav-freshclam.
> > 
> > What should I do to try and reproduce this bug? Revert to older
> > clamav-freshclam then upgrade again?
> 
> Just eliminating the local version, and running
> dpkg-reconfigure -phigh clamav-freshclam
> once or twice should do it.

OK, so testcase:
Make /etc/clamav/freshclam.conf have these entries:
DatabaseMirror db.local.clamav.net
DatabaseMirror database.clamav.net

dpkg-reconfigure -phigh clamav-freshclam
dpkg-reconfigure -phigh clamav-freshclam

Now add db.ro.clamav.net as first like this:
DatabaseMirror db.ro.clamav.net
DatabaseMirror db.local.clamav.net
DatabaseMirror database.clamav.net

dpkg-reconfigure -phigh clamav-freshclam

Popup with diff showing it in wrong place.

> 
> Although, looking at the way the list is set up, I can see that we are
> in fact setting it up wrong:
> 
> We set up the variable:
> 
>   if [ -e "$CLAMAVCONF" ]; then
>     for variable in `egrep -v '^[[:space:]]*(#|$)' "$CLAMAVCONF" |
> awk '{print $1}'`; do case "$variable" in
>         DatabaseMirror)
>         if [ -z "$DatabaseMirror" ]; then
>           for i in `grep ^$variable $CLAMAVCONF | awk '{print $2}'`;
> do value="$i $value"
>           done
>         else
>           continue
>         fi
>         ;;
> 
> Then store that in debconf:
> 
> if [ -n "$DatabaseMirror" ]; then
>   if [ -e /usr/share/doc/clamav-freshclam/mirror-list.gz ]; then
>     if zgrep -q
> "$DatabaseMirror" /usr/share/doc/clamav-freshclam/mirror-list.gz;then
> db_set clamav-freshclam/local_mirror `zgrep
> "$DatabaseMirror" /usr/share/doc/clamav-freshclam/mirror-list.gz` ||
> true else db_set clamav-freshclam/local_mirror "$DatabaseMirror" ||
> true fi fi
> fi
> 
> Then pull it out to construct the config file:
> 
>   db_metaget clamav-freshclam/local_mirror value || true
>   [ "$RET" = "" ] || rawmirrors="$RET"
>   if echo "$rawmirrors" | egrep -q '(\(|\))'; then
>     mirrors=`echo "$rawmirrors" | awk '{print $1}'`
>   else
>     mirrors="$rawmirrors"
>   fi
> 
> And then finally write out the temporary copy of the config file:
>   if [ -n "$mirrors" ]; then
>     for i in $mirrors; do
>       echo "DatabaseMirror $i" >> $DEBCONFILE
>     done
>   fi
>   if ! echo "$mirrors" | grep -q database.clamav.net; then
>     echo "DatabaseMirror database.clamav.net" >> $DEBCONFILE
>   fi
>   if [ -n "$DatabaseMirror" ]; then
>     for m in $DatabaseMirror; do
>       grep -q "$m" "$DEBCONFILE" || echo "DatabaseMirror $m" >>
> $DEBCONFILE done
>   fi
> 
> So it looks like the simple fix will be to change:
> value="$i $value"
> to
> value="$value $i"
> 
> in /var/lib/dpkg/info/clamav-freshclam.config and 
> /var/lib/dpkg/info/clamav-freshclam.postinst

Changing order here does something wrong with newlines, I get:
DatabaseMirror db.ro.clamav.net
< │ DatabaseMirror db.local.clamav.net DatabaseMirror
db.local.clamav.net │ DatabaseMirror database.clamav.net DatabaseMirror
database.clamav.net │  > DatabaseMirror db.ro.clamav.net 





More information about the Pkg-clamav-devel mailing list