Issue:
Setting up clamav as a daemon process in mac osx throws some cumbersome errors and warnings while doing the setup and the documentation is good, but not perfect. I ran into some permission issues, file location issues, etc.
Things that are working:
- freshclam daemon via a cronjob(will post below)
- getting the daemon to load via launchd and show via
sudo launchctl list | grep clam
- starting the daemon via launchd*
Things that are not working:
- clamd created from launchd plist does not stay in list after starting
- clamd starts, but returns the error below
Error:
clamdclam.log:
ERROR: LOCAL: Socket file /usr/local/etc/clamav/clamd.socket is in use by another process.
Setup:
CONFIG_DIR="/usr/local/etc"
CLAM_HOME_DIR=~/clamav
# Make dir for configs in home dir
mkdir -p ${CLAM_HOME_DIR}
# Create configs
clamconf -g freshclam.conf > ${CLAM_HOME_DIR}/freshclam.conf
clamconf -g clamd.conf > ${CLAM_HOME_DIR}/clamd.conf
clamconf -g clamav-milter.conf > ${CLAM_HOME_DIR}/clamav-milter.conf
# Link configs
ln -nsf $(pwd)/freshclam.conf /usr/local/etc/clamav/
ln -nsf $(pwd)/clamd.conf /usr/local/etc/clamav/
ln -nsf $(pwd)/clamav-milter.conf /usr/local/etc/clamav/
# Test freshclam is working
# create freshclam a log file
sudo touch /var/log/freshclam.log
sudo chmod 600 /var/log/freshclam.log
sudo chown clamav /var/log/freshclam.log
# create Clamd Log file
sudo touch /var/log/clamdclam.log
sudo chmod 600 /var/log/clamdclam.log
sudo chown clamav /var/log/clamdclam.log
Files:
All configs and functional files
/usr/local/etc/clamav:
ls -l /usr/local/etc/clamav/
total 472256
-rw-r--r-- 1 _clamav admin 293670 Oct 10 17:35 bytecode.cvd
lrwxr-xr-x 1 user admin 37 Oct 10 17:14 clamav-milter.conf -> /Users/user/clamav/clamav-milter.conf
lrwxr-xr-x 1 root admin 29 Oct 10 20:48 clamd.conf -> /Users/user/clamav/clamd.conf
-rwxrwxr-x 1 user admin 26784 Oct 9 16:46 clamd.conf.sample
-rw-r--r-- 1 root wheel 5 Oct 10 21:09 clamd.pid
srw-rw---- 1 root wheel 0 Oct 10 20:59 clamd.socket
lrwxr-xr-x 1 user admin 31 Oct 10 19:25 clamd_run.sh -> /Users/user/clamav/clamd_run.sh
-rw-r--r-- 1 _clamav admin 56261254 Oct 10 17:34 daily.cvd
lrwxr-xr-x 1 user admin 33 Oct 10 17:14 freshclam.conf -> /Users/user/clamav/freshclam.conf
-rwxrwxr-x 1 user admin 7204 Oct 9 16:46 freshclam.conf.sample
-rw-r--r-- 1 _clamav _clamav 69 Oct 10 17:34 freshclam.dat
-rw-r--r-- 1 _clamav admin 170479789 Oct 10 17:35 main.cvd
mac osx plist file /Library/LaunchDaemons/com.clamd.daemon.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.clamav.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/clamav/0.104.0_1/sbin/clamd</string>
<string>-c</string>
<string>/usr/local/etc/clamav/clamd.conf</string>
<string>-l</string>
<string>/var/log/clamdclam.log</string>
</array>
<key>KeepAlive</key>
<dict>
<key>Crashed</key>
<true/>
</dict>
<key>StandardOutPath</key>
<string>/tmp/test.stdout</string>
<key>StandardErrorPath</key>
<string>/tmp/test.stderr</string>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>
Currently Testing:
- changed file ownership: was
user:wheel -> root:wheel -> root:admin
srw-rw---- 1 root wheel 0 Oct 10 20:59 clamd.socket