Keine Beschreibung

Dmitriev Roman 43f4daf57d fixed readme.md vor 3 Monaten
LICENSE 43e28294cc Initial commit vor 3 Monaten
README.md 43f4daf57d fixed readme.md vor 3 Monaten
clamavdownloader.pl 323bfcd3f1 First upload vor 3 Monaten

README.md

ClamAV Database Downloader with CDIFF Fallback

Overview

This is not an official ClamAV tool. Use at your own risk.

clamdownloader.pl is an enhanced version of the original ClamAV database downloader
script by Frederic Vanden Poel.

The script maintains a local mirror of ClamAV databases (main.cvd, daily.cvd,
bytecode.cvd) with support for incremental updates, mirror fallback, and persistent
handling of missing CDIFF files.

It is designed for local or internal mirrors


Key Features

  • DNS TXT based version detection (current.cvd.clamav.net)
  • Incremental updates using .cdiff files
  • Automatic fallback to full .cvd download if incremental update is not possible
  • Multiple HTTP mirrors with failover
  • If-Modified-Since support to reduce bandwidth usage
  • Persistent cache of missing CDIFF files
  • Optional skipping of the daily database update
  • Safe updates using temporary files and validation


Differences from the Original Script

This script is based on the original clamdownloader.pl from Frederic Vanden Poel:

The following enhancements and behavioral differences were introduced:

1. Persistent CDIFF Missing Cache

  • Missing CDIFF files are permanently recorded in cdiff_history.txt
  • Once a CDIFF is known to be unavailable, it is never retried
  • Prevents repeated failed HTTP requests on every run

2. Multi-Mirror Fallback

  • Multiple mirrors are defined for both .cvd and .cdiff downloads
  • Mirrors are tried sequentially until a successful download occurs

3. Robust Incremental Update Logic

  • Sequential CDIFF download verification
  • If any required CDIFF is missing:
    • All partial CDIFFs are discarded
    • Full CVD download is triggered automatically

4. If-Modified-Since Optimization

  • Uses If-Modified-Since HTTP header when downloading full CVD files
  • Avoids unnecessary downloads if the file has not changed

5. Temporary File Safety

  • All downloads are written to a temporary directory first
  • Files are only moved into place if:
    • They exist
    • They are non-empty
    • They are newer than the current version

6. Command-Line Control

  • --skip-daily option allows skipping daily.cvd updates

7. Intended Use Case

This script:

  • Local or internal ClamAV mirrors

Requirements

System tools

  • sigtool (from ClamAV)

Perl modules

  • Getopt::Long
  • Net::DNS
  • LWP::UserAgent
  • HTTP::Request
  • File::Copy
  • File::Compare

Directory Layout

clamav/
├── main.cvd
├── daily.cvd
├── bytecode.cvd
├── main-XXXX.cdiff
├── daily-XXXX.cdiff
├── temp/
│ └── *.cvd
├── dns.txt
└── cdiff_history.txt

Usage

Normal run

perl clamdownloader.pl

Skip daily database update

perl clamdownloader.pl --skip-daily

Notes

This script does not apply CDIFFs — ClamAV handles that internally

The script only manages downloads and file replacement

Invalid or zero-sized downloads are discarded automatically