clamav: allow configuration to use TCP socket

Something having to do with passing a file descriptor over spamd's
Unix socket causes the ClamAV milter to fail. The milter says "ERROR:
Unknown reply from clamd," and running strace on spamd reveals "No file
descriptor received. ERROR."

Some work by others can be found on the Internet that suggests using
a TCP socket for the communication between the milter and spamd fixes
this. Lucian Cristian confirmed this on OpenWrt.

I am not sure why the Unix socket does not work. I suspect it is something
related to musl, but I have not yet found evidence of this.

This merge request adds the option to configure spamd to use a TCP
socket, and it uses this as the default. The merge request also adds an
init script for clamav-milter.

Signed-off-by: W. Michael Petullo <mike@flyn.org>
This commit is contained in:
W. Michael Petullo
2021-01-08 13:33:34 -06:00
parent f95f280a46
commit 54016ddaf4
5 changed files with 144 additions and 3 deletions
+11 -1
View File
@@ -41,6 +41,8 @@ validate_clamav_section() {
'AlertEncrypted:string' \
'MaxFileSize:string' \
'LocalSocket:string' \
'TCPSocket:port' \
'TCPAddr:ipaddr' \
'User:string' \
'ExitOnOOM:string' \
'DatabaseDirectory:string'
@@ -90,12 +92,20 @@ start_clamav_instance() {
echo "TemporaryDirectory " "$TemporaryDirectory"
echo "AlertEncrypted " "$AlertEncrypted"
echo "MaxFileSize " "$MaxFileSize"
echo "LocalSocket " "$LocalSocket"
echo "User " "$User"
echo "ExitOnOOM " "$ExitOnOOM"
echo "DatabaseDirectory " "$DatabaseDirectory"
} > "$CLAMD_CONFIGFILE"
if [ -n "$LocalSocket" ]; then
echo "LocalSocket " "$LocalSocket" >>"$CLAMD_CONFIGFILE"
fi
if [ -n "$TCPSocket" ]; then
echo "TCPAddr" "$TCPAddr" >>"$CLAMD_CONFIGFILE"
echo "TCPSocket " "$TCPSocket" >>"$CLAMD_CONFIGFILE"
fi
procd_open_instance
procd_set_param command $PROG -c $CLAMD_CONFIGFILE
procd_set_param file $CLAMD_CONFIGFILE