Skip to content

Commit db5d733

Browse files
clamav: Update SNAC config for optional daemon and improved verification
- Make clamav-daemon optional in verification: - Update verify() to handle optional daemon package gracefully - Updated the c*.conf file path for verification. Signed-off-by: Hemant Jadhav <hemant.jadhav@emerson.com>
1 parent 8d3a488 commit db5d733

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

nilrt_snac/_configs/_clamav_config.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import os
23
import pathlib
34

45
from nilrt_snac._configs._base_config import _BaseConfig
@@ -13,8 +14,8 @@ class _ClamAVConfig(_BaseConfig):
1314

1415
def __init__(self):
1516
super().__init__("clamav")
16-
self.clamd_config_path = "/etc/clamav/clamd.conf"
17-
self.freshclam_config_path = "/etc/clamav/freshclam.conf"
17+
self.clamd_config_path = "/etc/clamd.conf"
18+
self.freshclam_config_path = "/etc/freshclam.conf"
1819
self.virus_db_path = "/var/lib/clamav/"
1920
self.package_names = ["clamav", "clamav-daemon", "clamav-freshclam"]
2021
self._opkg_helper = opkg_helper
@@ -34,15 +35,20 @@ def verify(self, args: argparse.Namespace) -> bool:
3435
if installed_packages:
3536
print("Verifying clamav configuration...")
3637
valid = True
38+
39+
# Check DNS configuration (critical for freshclam)
40+
resolv_conf_path = "/var/run/resolv.conf"
41+
if not os.path.exists(resolv_conf_path) or os.path.getsize(resolv_conf_path) == 0:
42+
logger.warning(f"DNS not configured: {resolv_conf_path} is empty or missing")
43+
logger.warning("freshclam will fail without DNS. Configure network/DNS before running freshclam.")
3744

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
45+
# Check clamd configuration file (only if daemon package is installed)
46+
if self._opkg_helper.is_installed("clamav-daemon"):
47+
clamd_config = _ConfigFile(self.clamd_config_path)
48+
if not clamd_config.exists():
49+
logger.warning(f"ClamAV daemon config file missing: {self.clamd_config_path}")
50+
elif pathlib.Path(self.clamd_config_path).stat().st_size == 0:
51+
logger.warning(f"ClamAV daemon config file is empty: {self.clamd_config_path}")
4652

4753
# Check freshclam configuration file
4854
freshclam_config = _ConfigFile(self.freshclam_config_path)

0 commit comments

Comments
 (0)