0

Ubuntu 20.04.2
ClamAV 0.102.4

I want to use a different value for ClamD's LocalSocket directive but keep getting the following error:

!LOCAL: Socket file /var/run/clamd.scan/clamd.sock could not be bound: Permission denied

The defaults in /etc/clamav/clamd.conf are:

LocalSocket /var/run/clamav/clamd.ctl
FixStaleSocket true
LocalSocketGroup clamav
LocalSocketMode 666
User clamav

I changed the LocalSocket value to:

LocalSocket /var/run/clamd.scan/clamd.sock
FixStaleSocket true
LocalSocketGroup clamav
LocalSocketMode 666
User clamav

Then created the new directory and set perms and ownership. Matching that of /var/run/clamav/ where the socket file is able to be created.

mkdir /var/run/clamd.scan
chown clamav:root /var/run/clamd.scan/
chmod 755 /var/run/clamd.scan/

Restarted clam and getting the Permission Denied error from above

systemctl restart clamav-daemon && systemctl status clamav-daemon.service

Directory ownerships and perms are the same:

drwxr-xr-x  2 clamav   root         40 Feb 26 18:52 clamav/
drwxr-xr-x  2 clamav   root         60 Feb 26 19:12 clamd.scan/

I tried temporarily changing the perms of /var/run/clamd.scan/ to 777 but still get the same error after restarting clamd.

I'm able to create a file in that directory as the clamav user if I try:

su - clamav -s /bin/bash -c "cd /var/run/clamd.scan && touch clamd.sock"

So I don't understand why I would be getting that Permission Denied. Any advice? I must be missing something.

2
  • The obvious advice is: don't do this. Leave the socket as it was. Feb 26, 2021 at 19:52
  • I agree @MichaelHampton This seemed like a simple change so we wouldn't have to make code changes for the new socket location. When migrating from CentOS to Ubuntu. And now I'm just stumped on why it can't be done. Feb 26, 2021 at 20:01

1 Answer 1

0

I had an issue similar to yours : after a fresh install, clamd was not able to fully use its socket and complained when I launched it manually :

$ sudo clamd
!LOCAL: Socket file /var/run/clamav/clamd.ctl could not be removed: Permission denied

(I'm not certain this is the right way to start clamd but still) So I set the permissions as follows :

drwxrwxr-x  2 root   clamav   60 mars  21 09:49 clamav
srw-rw-rw-  1 clamav clamav    0 mars  21 09:51 clamd.ctl

And then sudo clamd returns without any error message, so clamd is started !

I'm uneasy with the idea that others have rw permissions on this socket, but if I remove them, clamd sets them back again when I start it...

I hope that it can help !

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .