this is a combined update for security/clamav and mail/smtp-vilter.
based on an idea by davidy gwynne, it implements virus scanning by just
passing an open filedescriptor between the clamav clamd process and the
smtp-vilter sendmail milter.
this makes setting up a mail scanning gateway a lot easier as you now
longer need to configure quite complex permissions on tempfiles and such
to ensure clamd is able to access the tempfiles created by smtp-vilter.
i sent the clamd diffs to the clamav developers so they can consider if
the want to put this directly in their code.
comments? ok?
Index: security/clamav/Makefile
===================================================================
RCS file: /cvs/ports/security/clamav/Makefile,v
retrieving revision 1.22
diff -u -r1.22 Makefile
--- security/clamav/Makefile 13 Jan 2007 13:13:11 -0000 1.22
+++ security/clamav/Makefile 16 Jan 2007 15:12:51 -0000
@@ -2,7 +2,7 @@
COMMENT= "virus scanner"
DISTNAME= clamav-0.88.7
-PKGNAME= ${DISTNAME}p0
+PKGNAME= ${DISTNAME}p1
CATEGORIES= security
SHARED_LIBS= clamav 2.0
Index: security/clamav/patches/patch-clamd_session_c
===================================================================
RCS file: security/clamav/patches/patch-clamd_session_c
diff -N security/clamav/patches/patch-clamd_session_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ security/clamav/patches/patch-clamd_session_c 16 Jan 2007 15:12:51
-0000
@@ -0,0 +1,42 @@
+$OpenBSD$
+--- clamd/session.c.orig Sun Oct 30 17:00:52 2005
++++ clamd/session.c Tue Jan 16 15:51:05 2007
+@@ -51,6 +51,9 @@ int command(int desc, const struct cl_no
+ char buff[1025];
+ int bread, opt, retval;
+ struct cfgstruct *cpt;
++ struct msghdr msg;
++ struct cmsghdr *cmsg;
++ unsigned char buf[CMSG_SPACE(sizeof(int))];
+
+
+ retval = poll_fd(desc, timeout);
+@@ -155,7 +158,28 @@ int command(int desc, const struct cl_no
+
+ scanfd(fd, NULL, root, limits, options, copt, desc, 0);
+ close(fd); /* FIXME: should we close it here? */
++ } else if(!strncmp(buff, CMD13, strlen(CMD13))) { /* FILDES */
++ memset(&msg, 0, sizeof(msg));
++ msg.msg_control = buf;
++ msg.msg_controllen = sizeof(buf);
+
++ if (recvmsg(desc, &msg, 0) == -1) {
++ logg("recvmsg failed!");
++ return -1;
++ }
++ if ((msg.msg_flags & MSG_TRUNC) || (msg.msg_flags & MSG_CTRUNC)) {
++ logg("control message truncated");
++ return -1;
++ }
++ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
++ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
++ if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)) &&
++ cmsg->cmsg_level == SOL_SOCKET &&
++ cmsg->cmsg_type == SCM_RIGHTS) {
++ int fd = *(int *)CMSG_DATA(cmsg);
++ scanfd(fd, NULL, root, limits, options, copt, desc, 0);
++ }
++ }
+ } else {
+ mdprintf(desc, "UNKNOWN COMMAND\n");
+ }
Index: security/clamav/patches/patch-clamd_session_h
===================================================================
RCS file: security/clamav/patches/patch-clamd_session_h
diff -N security/clamav/patches/patch-clamd_session_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ security/clamav/patches/patch-clamd_session_h 16 Jan 2007 15:12:51
-0000
@@ -0,0 +1,11 @@
+$OpenBSD$
+--- clamd/session.h.orig Sun Oct 30 17:00:43 2005
++++ clamd/session.h Tue Jan 16 15:50:43 2007
+@@ -36,6 +36,7 @@
+ #define CMD10 "END"
+ #define CMD11 "SHUTDOWN"
+ #define CMD12 "FD"
++#define CMD13 "FILDES"
+
+ #include <clamav.h>
+ #include "cfgparser.h"
Index: mail/smtp-vilter/Makefile
===================================================================
RCS file: /cvs/ports/mail/smtp-vilter/Makefile,v
retrieving revision 1.25
diff -u -r1.25 Makefile
--- mail/smtp-vilter/Makefile 12 Nov 2006 12:21:21 -0000 1.25
+++ mail/smtp-vilter/Makefile 16 Jan 2007 15:12:51 -0000
@@ -2,8 +2,7 @@
COMMENT= "sendmail milter to scan messages for viruses and spam"
-DISTNAME= smtp-vilter-1.3.4
-PKGNAME= ${DISTNAME}p0
+DISTNAME= smtp-vilter-1.3.5
CATEGORIES= mail
Index: mail/smtp-vilter/distinfo
===================================================================
RCS file: /cvs/ports/mail/smtp-vilter/distinfo,v
retrieving revision 1.16
diff -u -r1.16 distinfo
--- mail/smtp-vilter/distinfo 12 Nov 2006 12:21:21 -0000 1.16
+++ mail/smtp-vilter/distinfo 16 Jan 2007 15:12:51 -0000
@@ -1,4 +1,4 @@
-MD5 (smtp-vilter-1.3.4.tgz) = 2a39fd2ae70356ac3dfce9e0f9eb01ee
-RMD160 (smtp-vilter-1.3.4.tgz) = a46272c97e46cd3cb5681063a69575a4c41d03e6
-SHA1 (smtp-vilter-1.3.4.tgz) = 883c9b523e425ee412c5facf226e2849a7b56a57
-SIZE (smtp-vilter-1.3.4.tgz) = 69651
+MD5 (smtp-vilter-1.3.5.tgz) = c99fd02182bc5a61a32f611082829938
+RMD160 (smtp-vilter-1.3.5.tgz) = e74215f08e5328bccfead23655e56aa668a0b2bf
+SHA1 (smtp-vilter-1.3.5.tgz) = 4218cbe7b946bd4d431eeef898012f85094b53a7
+SIZE (smtp-vilter-1.3.5.tgz) = 70240