11import argparse
2+ import os
23import pathlib
34
45from nilrt_snac ._configs ._base_config import _BaseConfig
@@ -16,6 +17,7 @@ def __init__(self):
1617 self .clamd_config_path = "/etc/clamav/clamd.conf"
1718 self .freshclam_config_path = "/etc/clamav/freshclam.conf"
1819 self .virus_db_path = "/var/lib/clamav/"
20+ self .resolv_conf_path = "/var/run/resolv.conf"
1921 self .package_names = ["clamav" , "clamav-daemon" , "clamav-freshclam" ]
2022 self ._opkg_helper = opkg_helper
2123
@@ -34,15 +36,21 @@ def verify(self, args: argparse.Namespace) -> bool:
3436 if installed_packages :
3537 print ("Verifying clamav configuration..." )
3638 valid = True
39+
40+ if self ._opkg_helper .is_installed ("clamav-freshclam" ):
41+ # Check DNS configuration (critical for freshclam)
42+ if not os .path .exists (self .resolv_conf_path ) or os .path .getsize (self .resolv_conf_path ) == 0 :
43+ logger .error (f"DNS not configured: { self .resolv_conf_path } is empty or missing" )
44+ logger .error ("freshclam will fail without DNS. Configure network/DNS before running freshclam." )
45+ valid = False
3746
38- # Check clamd configuration file
39- clamd_config = _ConfigFile (self .clamd_config_path )
40- if not clamd_config .exists ():
41- logger .error (f"ClamAV daemon config file missing: { self .clamd_config_path } " )
42- valid = False
43- elif pathlib .Path (self .clamd_config_path ).stat ().st_size == 0 :
44- logger .error (f"ClamAV daemon config file is empty: { self .clamd_config_path } " )
45- valid = False
47+ # Check clamd configuration file (only if daemon package is installed)
48+ if self ._opkg_helper .is_installed ("clamav-daemon" ):
49+ clamd_config = _ConfigFile (self .clamd_config_path )
50+ if not clamd_config .exists ():
51+ logger .info (f"ClamAV daemon config file missing: { self .clamd_config_path } " )
52+ elif pathlib .Path (self .clamd_config_path ).stat ().st_size == 0 :
53+ logger .info (f"ClamAV daemon config file is empty: { self .clamd_config_path } " )
4654
4755 # Check freshclam configuration file
4856 freshclam_config = _ConfigFile (self .freshclam_config_path )
0 commit comments