Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 662196 - app-antivirus/clamav-0.100.1 systemd: possible duplication of systemd service files
Summary: app-antivirus/clamav-0.100.1 systemd: possible duplication of systemd service...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Antivirus Team
URL:
Whiteboard:
Keywords:
: 670731 (view as bug list)
Depends on:
Blocks: 689942 903299
  Show dependency tree
 
Reported: 2018-07-26 19:08 UTC by Dennis Lamm
Modified: 2024-07-08 04:10 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Lamm gentoo-dev 2018-07-26 19:08:00 UTC
Currently there are the two systemd service files
- clamav-daemon.service
- clamav-freshclam.service
upstream available.
Also are custom service files 
- clamd.service
- freshclamd.service
from the ebuild available.
Comment 1 Thomas Raschbacher gentoo-dev 2018-10-14 11:56:50 UTC
adding the systemd team to it

If someone could have a look and let me know if the upstream files are better/suitable/.. please let me know - if not then I'll try to have a look at some point soon
Comment 2 Wolfram Schlich 2018-11-09 07:23:10 UTC
*** Bug 670731 has been marked as a duplicate of this bug. ***
Comment 3 Wolfram Schlich 2018-11-09 07:23:34 UTC
(In reply to Thomas Raschbacher from comment #1)
> adding the systemd team to it
> 
> If someone could have a look and let me know if the upstream files are
> better/suitable/.. please let me know - if not then I'll try to have a look
> at some point soon

See my comment in my duplicate bug #662196:

(In reply to Wolfram Schlich from comment #0)
> app-antivirus/clamav-0.100.2 installs 2 systemd units for clamd:
> 
> /lib/systemd/system/clamd.service
> /lib/systemd/system/clamav-daemon.service
> 
> clamd.service seems to be the one that should be killed as it forks clamd in
> the background (not systemds philosophy) and it's also not related to
> clamav-daemon.socket (but clamav-daemon.service is).
Comment 4 Thomas Raschbacher gentoo-dev 2019-02-22 20:22:54 UTC
would appreciate if someone who is familiar with systemd could look into this (see the comment on bug #670731)
Comment 5 zshzero 2020-01-14 08:13:07 UTC
Yes, there are duplicate service files

2731 root      20   0   10792   3608   3140 R   0.0   0.1   0:03.32 top
2681 clamav    20   0   16040   4136   3196 S   0.0   0.1   0:00.00 freshclam
2716 clamav    20   0  959828 824544      0 S   0.0  21.4   0:00.00 clamd
2722 clamav    20   0  959824 834112   9576 S   0.0  21.7   0:34.90 clamd
2726 clamav    20   0   16148   8420   7444 S   0.0   0.2   0:00.00 freshclam

And their service files are

-> clamav-daemon.service

[Unit]
Description=Clam AntiVirus userspace daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
Requires=clamav-daemon.socket
# Check for database existence
ConditionPathExistsGlob=/var/lib/clamav/main.{c[vl]d,inc}
ConditionPathExistsGlob=/var/lib/clamav/daily.{c[vl]d,inc}

[Service]
ExecStart=/usr/sbin/clamd --foreground=true
# Reload the database
ExecReload=/bin/kill -USR2 $MAINPID
StandardOutput=syslog

[Install]
WantedBy=multi-user.target
Also=clamav-daemon.socket

-> clamd.service

[Unit]
Description=clamd scanner daemon
After=nss-lookup.target network.target

[Service]
Type=forking
ExecStart=/usr/sbin/clamd
Restart=on-failure
PrivateTmp=true

[Install]
WantedBy=multi-user.target

And

-> clamav-freshclam.service

[Unit]
Description=ClamAV virus database updater
Documentation=man:freshclam(1) man:freshclam.conf(5) https://www.clamav.net/documents
# If user wants it run from cron, don't start the daemon.
ConditionPathExists=!/etc/cron.d/clamav-freshclam

[Service]
ExecStart=/usr/bin/freshclam -d --foreground=true
StandardOutput=syslog

[Install]
WantedBy=multi-user.target

--> freshclamd.service

[Unit]
Description=clamav updater

[Service]
Type=forking
User=clamav
Group=clamav
RuntimeDirectory=clamav
PIDFile=/run/clamav/freshclam.pid
ExecStart=/usr/bin/freshclam -d -p /run/clamav/freshclam.pid

[Install]
WantedBy=multi-user.target
Comment 6 Matt Jolly gentoo-dev 2024-06-24 10:08:18 UTC
With the change to the CMake build system some automagic for systemd was added that configures and installs systemd service files if `-DENABLE_SYSTEMD` is set _and_ the configure automagic finds a copy of systemd on the system.

e.g.: https://github.com/Cisco-Talos/clamav/commit/9e20cdf6eaf545a66f55ce5ba85ef9a98dad3648#diff-ebe8ba56711ee8fb3455fbf541b2930b667ae754b598dc2a2901f9487c6d3dea

I assume that the 'did I find systemd installed' gate is because of SD-notify, but as we found with OpenSSH recently we really shouldn't be linking to systemd _just_ for notify support and should instead use a shim. I'll try and submit a PR that drops the automagic at some point (I hope).

Longer term, once that is in place, we need to unconditionally install the unit files provided upstream, drop our custom versions, and address any fixes there.