问题:
在 mac osx 中将 clamav 设置为守护进程时,设置过程中会出现一些繁琐的错误和警告,文档虽然不错,但并不完美。我遇到了一些权限问题、文件位置问题等。
正在起作用的事情:
- 通过 cronjob 运行 freshclam 守护进程(将在下面发布)
- 通过 launchd 加载守护进程并通过 show
sudo launchctl list | grep clam
- 通过 launchd* 启动守护进程
不起作用的事情:
- 从 launchd plist 创建的 clamd 在启动后不留在列表中
- clamd 启动,但返回以下错误
错误:
clamdclam.log:
ERROR: LOCAL: Socket file /usr/local/etc/clamav/clamd.socket is in use by another process.
设置:
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
文件:
所有配置和功能文件
/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 文件/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>
目前正在测试:
- 更改文件所有权:原
user:wheel -> root:wheel -> root:admin
srw-rw---- 1 root wheel 0 Oct 10 20:59 clamd.socket
答案1
目前,通过上述设置和配置以及文件所有权的更改,出现错误:
ERROR: LOCAL: Socket file /usr/local/etc/clamav/clamd.socket is in use by another process.
已通过对文件和目录的适当权限解决。