From 525c4b2b27485292aefe06fb6a9e40054208fe29 Mon Sep 17 00:00:00 2001 From: Edwin Groothuis Date: Fri, 29 Jul 2005 00:42:28 +0000 Subject: [PATCH] update mail/p3scan from 1.0.2 to 2.1 PR: ports/84137 Submitted by: dawnshade --- mail/p3scan/Makefile | 5 +- mail/p3scan/distinfo | 4 +- mail/p3scan/files/patch-Makefile | 49 ++++---- mail/p3scan/files/patch-getline.c | 12 +- mail/p3scan/files/patch-p3scan.c | 109 ++++++++++-------- mail/p3scan/files/patch-parsefile.c | 12 +- mail/p3scan/files/patch-ripmime::build_ripOLE | 4 +- mail/p3scan/files/patch-ripmime::build_tnef | 4 +- .../files/patch-ripmime::tnef::Makefile | 18 +-- mail/p3scan/files/patch-scanner_avpd.c | 13 +-- mail/p3scan/files/patch-scanner_basic.c | 9 +- mail/p3scan/files/patch-scanner_sample.c | 11 +- mail/p3scan/files/patch-scanner_trophie.c | 16 +-- mail/p3scan/pkg-message | 4 + 14 files changed, 139 insertions(+), 131 deletions(-) diff --git a/mail/p3scan/Makefile b/mail/p3scan/Makefile index 34a2c180f9e4..14042f17ecef 100644 --- a/mail/p3scan/Makefile +++ b/mail/p3scan/Makefile @@ -6,8 +6,7 @@ # PORTNAME= p3scan -PORTVERSION= 1.0 -PORTREVISION= 2 +PORTVERSION= 2.1 CATEGORIES= mail net MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME} @@ -38,7 +37,7 @@ RUN_DEPENDS+= uvscan:${PORTSDIR}/security/vscan do-install: ${INSTALL_PROGRAM} ${WRKSRC}/p3scan ${PREFIX}/sbin/ ${INSTALL_DATA} ${WRKSRC}/p3scan.conf ${PREFIX}/etc/p3scan.conf.sample - ${INSTALL_DATA} ${WRKSRC}/p3scan.mail ${PREFIX}/etc/p3scan.mail.sample + ${INSTALL_DATA} ${WRKSRC}/p3scan-en.mail ${PREFIX}/etc/p3scan.mail.sample ${INSTALL_SCRIPT} ${FILESDIR}/p3scan.sh ${PREFIX}/etc/rc.d/ .for f in ${MAN8} ${INSTALL_MAN} ${WRKSRC}/${f}.gz ${MAN8PREFIX}/man/man8/ diff --git a/mail/p3scan/distinfo b/mail/p3scan/distinfo index eaaf7b05415b..f2d84206f13f 100644 --- a/mail/p3scan/distinfo +++ b/mail/p3scan/distinfo @@ -1,2 +1,2 @@ -MD5 (p3scan-1.0.tar.gz) = d5d354f85727667e781bc5e05e4ffb4d -SIZE (p3scan-1.0.tar.gz) = 180274 +MD5 (p3scan-2.1.tar.gz) = 5e261548e522f3ac2583870b6e02aecd +SIZE (p3scan-2.1.tar.gz) = 348717 diff --git a/mail/p3scan/files/patch-Makefile b/mail/p3scan/files/patch-Makefile index de944936c2d4..fc51af4a8fd9 100644 --- a/mail/p3scan/files/patch-Makefile +++ b/mail/p3scan/files/patch-Makefile @@ -1,25 +1,34 @@ ---- Makefile.orig Wed Jan 21 11:33:02 2004 -+++ Makefile Wed Feb 18 10:43:15 2004 -@@ -26,12 +26,12 @@ - # along with this program; if not, write to the Free Software - # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - --PREFIX=/usr --MANDIR=$(PREFIX)/man/man8 +--- Makefile.orig Tue Jul 26 13:25:59 2005 ++++ Makefile Tue Jul 26 15:00:51 2005 +@@ -34,20 +34,20 @@ + LOGFAC="LOG_DAEMON" + LOGSET=-DLOGOPT=${LOGOPT} -DLOGFAC=${LOGFAC} + LANG=en -CC=gcc --#CFLAGS=-Wall -ggdb --CFLAGS=-Wall -O2 ++CC?=gcc + SYSINS=ginstall +-CFLAGS=-Wall -O2 ${LOGSET} -LDFLAGS=-L. -lripmime -lpcre #-static -+PREFIX?= /usr -+MANDIR?= $(PREFIX)/man/man8 -+CC?= gcc -+#CFLAGS= -Wall -ggdb -+CFLAGS+= -Wall -O2 -I${PREFIX}/include -+LDFLAGS+= -L. -lripmime -lpcre ${_LDFLAGS} ++CFLAGS+=-Wall -O2 ${LOGSET} -I${PREFIX}/include -I/usr/local/include ++LDFLAGS+=-L. -lripmime -lpcre ${_LDFLAGS} #-static + + PREFIX=/usr + #MANDIR=$(PREFIX)/share/man/man8 +-MANDIR=$(PREFIX)/man/man8 ++MANDIR?=$(PREFIX)/man/man8 + piddir=/var/run/$(PROGS) + datadir=/var/spool/$(PROGS) + notify=/var/spool/$(PROGS)/notify +-user=mail.mail +-userdir=/etc/$(PROGS) +-docdir=/usr/doc/$(DISTNAME) ++user=mail:mail ++userdir=/usr/local/etc/$(PROGS) ++docdir=/usr/local/doc/$(DISTNAME) + # End user options OBJECTS=getline.o parsefile.o p3scan.o \ - scanner_basic.o scanner_avpd.o scanner_trophie.o -@@ -62,8 +62,8 @@ +@@ -71,8 +71,8 @@ dep depend .dep: @echo "creating depencies" @@ -28,9 +37,9 @@ + rm -f .tmp.dep + @find . -name "*.c" -maxdepth 1 -print0 | xargs -n 1 -0t $(CC) -M $(CFLAGS) >>.tmp.dep mv .tmp.dep .dep - + install: p3scan -@@ -143,9 +143,9 @@ +@@ -148,9 +148,9 @@ fulltags: @#VIM Users know why! *g* diff --git a/mail/p3scan/files/patch-getline.c b/mail/p3scan/files/patch-getline.c index b0517ae95d3e..441003f03a13 100644 --- a/mail/p3scan/files/patch-getline.c +++ b/mail/p3scan/files/patch-getline.c @@ -1,11 +1,15 @@ ---- getline.c.orig Tue Feb 17 21:58:12 2004 -+++ getline.c Tue Feb 17 21:58:17 2004 -@@ -30,7 +30,7 @@ +--- getline.c.orig Tue Jul 26 13:29:05 2005 ++++ getline.c Tue Jul 26 11:10:51 2005 +@@ -33,11 +33,11 @@ #include #include #include -#include -+#include #include #include #include + #include ++#include + + #include "getline.h" + diff --git a/mail/p3scan/files/patch-p3scan.c b/mail/p3scan/files/patch-p3scan.c index 08cd4fdc9db0..fae28f2ce0c9 100644 --- a/mail/p3scan/files/patch-p3scan.c +++ b/mail/p3scan/files/patch-p3scan.c @@ -1,9 +1,9 @@ ---- p3scan.c.orig Wed Jan 21 01:26:48 2004 -+++ p3scan.c Wed Feb 18 13:32:33 2004 -@@ -30,34 +30,39 @@ - * - */ - +--- p3scan.c.orig Thu Jan 6 04:53:04 2005 ++++ p3scan.c Fri Jul 29 10:10:15 2005 +@@ -36,36 +36,38 @@ + TODO: Wanted: white-list support + TODO: Wanted: no iptables support + */ -#include -#include -#include @@ -18,6 +18,7 @@ +#include +#include #include ++#include +#include +#include +#include @@ -43,17 +44,16 @@ #include #include #include -+#ifdef __FreeBSD__ +-#include + #include + #include +#include +#include -+#else -+#include - #include -+#endif ++ #include "p3scan.h" #include "getline.h" -@@ -81,8 +86,8 @@ +@@ -94,13 +96,13 @@ #define VIRUS_SCANNER_VIRUSCODE 1 #define PID_FILE "/var/run/p3scan/p3scan.pid" #define SYSLOG_NAME "p3scan" @@ -63,18 +63,22 @@ +#define VIRUS_TEMPLATE "/usr/local/etc/p3scan/p3scan.mail" #define DEBUG 0 #define QUIET 0 - #define OVERWRITE 0 -@@ -340,11 +345,24 @@ - #define MOVEIT "/bin/mv" + #define OVERWRITE NULL + #define CHECKSPAM 0 +-#define SPAMCHECK "/usr/bin/spamc" ++#define SPAMCHECK "/usr/local/bin/spamc" + #define MINSPACE 0 + #define DELIT 0 + #define NEWLINE '\n' +@@ -507,10 +509,21 @@ FILE * scanner; static char line[4096*16]; + //static char line[4096]; - struct statvfs fs; - int kbfree; - struct linebuf *filebuf; - int res, htmlfd, html, toggle; + unsigned long kbfree; + int htmlfd; -+#ifdef __FreeBSD__ -+ struct statfs fs; ++ struct statfs fs; + if ((ret=statfs(config->virusdir,&fs))!=0) { + do_log(LOG_EMERG, "Unable to get available space!"); + return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) @@ -84,32 +88,34 @@ + do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); + return SCANNER_RET_CRIT; + } -+#else -+ struct statvfs fs; + - /* See if we have enough room to process the message based upon - what the user determines is enough room in p3scan.conf */ - if ( statvfs( config->virusdir, &fs ) == SCANNER_RET_ERR){ -@@ -356,6 +374,7 @@ - do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); - return SCANNER_RET_CRIT; ++ + ret=checktimeout(p); + if (ret < 0) return SCANNER_RET_CRIT; + /* See if we have enough room to process the message based upon +@@ -521,7 +534,7 @@ + do_log(LOG_EMERG, "Unable to get available space!"); + return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) } -+#endif - - /* This is where we should scan for spam - before demime to - give SpamAssassin the virgin message */ -@@ -820,8 +839,8 @@ - do_log(LOG_NOTICE, "Connection from %s:%i", inet_ntoa(p->client_addr.sin_addr), ntohs(p->client_addr.sin_port)); +- kbfree=(fs.f_bavail * fs.f_frsize / 1024); ++ kbfree=(fs.f_bavail * fs.f_bsize / 1024); + if ( config->freespace != 0 && kbfree < config->freespace ){ + p->errmsg=1; + do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); +@@ -1179,8 +1192,10 @@ p->server_addr.sin_family = AF_INET; -- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ -- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); + if (htonl(INADDR_ANY) == config->targetaddr.sin_addr.s_addr) { +- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ +- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); ++// if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ ++// do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); + if (getsockname(p->client_fd, (struct sockaddr*)&p->server_addr, &p->socksize)){ + do_log(LOG_CRIT, "No IP-Conntrack-data (getsockname failed)"); - return 1; - } - do_log(LOG_NOTICE, "Real-server adress is %s:%i", inet_ntoa(p->server_addr.sin_addr), ntohs(p->server_addr.sin_port)); -@@ -1534,7 +1553,7 @@ + return 1; + } + /* try to avoid loop */ +@@ -2041,7 +2056,7 @@ char * responsemsg; int virusdirlen; char chownit[100]; @@ -118,14 +124,15 @@ int len; int ret; FILE * chowncmd; -@@ -1574,8 +1593,8 @@ - }; - // chown /var/run/p3scan/p3scan.pid mail.mail - len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1; -- do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); -- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); -+ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); -+ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); - if ((chowncmd=popen(chownit, "r"))==NULL){ - do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd); - return SCANNER_RET_ERR; +@@ -2080,7 +2095,10 @@ + if (!config->debug){ + len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1; + //do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); +- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); ++// snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); ++ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); ++ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); ++ + if ((chowncmd=popen(chownit, "r"))==NULL){ + do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd); + return SCANNER_RET_ERR; diff --git a/mail/p3scan/files/patch-parsefile.c b/mail/p3scan/files/patch-parsefile.c index a5056ab0e371..d70c0758439d 100644 --- a/mail/p3scan/files/patch-parsefile.c +++ b/mail/p3scan/files/patch-parsefile.c @@ -1,10 +1,16 @@ ---- parsefile.c.orig Tue Feb 17 21:58:27 2004 -+++ parsefile.c Tue Feb 17 21:59:39 2004 -@@ -33,7 +33,6 @@ +--- parsefile.c.orig Wed Jan 5 20:53:04 2005 ++++ parsefile.c Tue Jul 26 11:10:08 2005 +@@ -33,11 +33,12 @@ #include #include #include -#include ++#include #include #include #include "parsefile.h" + #include "getline.h" ++#include + + #define NONULL(x) ( x==NULL ? "" : x) /* this is nice, found in the mutt code */ + diff --git a/mail/p3scan/files/patch-ripmime::build_ripOLE b/mail/p3scan/files/patch-ripmime::build_ripOLE index 2e1b834e7f96..5389503a6ae9 100644 --- a/mail/p3scan/files/patch-ripmime::build_ripOLE +++ b/mail/p3scan/files/patch-ripmime::build_ripOLE @@ -1,5 +1,5 @@ ---- ripmime/build_ripOLE.orig Wed Jul 16 21:18:54 2003 -+++ ripmime/build_ripOLE Wed Feb 18 10:31:19 2004 +--- ripmime/build_ripOLE.orig Wed Jan 5 20:53:04 2005 ++++ ripmime/build_ripOLE Tue Jul 26 12:48:42 2005 @@ -1,4 +1,4 @@ #!/bin/sh cd ripOLE diff --git a/mail/p3scan/files/patch-ripmime::build_tnef b/mail/p3scan/files/patch-ripmime::build_tnef index d2661e654677..103d4235fe61 100644 --- a/mail/p3scan/files/patch-ripmime::build_tnef +++ b/mail/p3scan/files/patch-ripmime::build_tnef @@ -1,5 +1,5 @@ ---- ripmime/build_tnef.orig Sat Nov 15 20:39:05 2003 -+++ ripmime/build_tnef Wed Feb 18 10:31:43 2004 +--- ripmime/build_tnef.orig Wed Jan 5 20:53:04 2005 ++++ ripmime/build_tnef Tue Jul 26 12:48:14 2005 @@ -1,3 +1,3 @@ #!/bin/sh cd tnef diff --git a/mail/p3scan/files/patch-ripmime::tnef::Makefile b/mail/p3scan/files/patch-ripmime::tnef::Makefile index 4f6311f43648..cd1d0d3800bf 100644 --- a/mail/p3scan/files/patch-ripmime::tnef::Makefile +++ b/mail/p3scan/files/patch-ripmime::tnef::Makefile @@ -1,19 +1,13 @@ ---- ripmime/tnef/Makefile.orig Sat Nov 15 20:39:06 2003 -+++ ripmime/tnef/Makefile Wed Feb 18 11:03:29 2004 -@@ -1,13 +1,13 @@ - --CC=cc -+CC?=cc - - # Possible platforms are SUN, HPUX, DEC, SGI, AIX, Linux and MSDOS +--- ripmime/tnef/Makefile.orig Tue Jul 26 14:31:25 2005 ++++ ripmime/tnef/Makefile Tue Jul 26 14:32:30 2005 +@@ -4,8 +4,8 @@ # The main definitions are for 32/16 bits and for byte order, the # default is big endian. You can do -D__TNEF_BYTE_ORDER 1234 for little # endian -PLATFORM=-D___TNEF_BYTE_ORDER=4321 +-CFLAGS=-Wall -g -O2 -I. +PLATFORM=-D___TNEF_BYTE_ORDER=_BYTE_ORDER -include /usr/include/machine/endian.h - #CFLAGS = -O2 -ggdb --CFLAGS = -Wall -g -I.. -+CFLAGS += -Wall -g -I.. - ++CFLAGS+=-Wall -g -O2 -I. default: config.h tnef.h tnef.c + $(CC) $(CFLAGS) $(PLATFORM) -c tnef.c diff --git a/mail/p3scan/files/patch-scanner_avpd.c b/mail/p3scan/files/patch-scanner_avpd.c index a8f6d9a9adc9..3069fedbdb4d 100644 --- a/mail/p3scan/files/patch-scanner_avpd.c +++ b/mail/p3scan/files/patch-scanner_avpd.c @@ -1,5 +1,5 @@ ---- scanner_avpd.c.orig Thu Dec 4 02:58:25 2003 -+++ scanner_avpd.c Wed Feb 18 12:50:42 2004 +--- scanner_avpd.c.orig Wed Jan 5 20:53:04 2005 ++++ scanner_avpd.c Tue Jul 26 12:44:34 2005 @@ -39,12 +39,12 @@ #include #include @@ -14,12 +14,3 @@ #include "p3scan.h" -@@ -81,7 +81,7 @@ - if (avp_fd!=-1 && connected==-1){ - do_log(LOG_DEBUG, "Trying to connect to socket"); - if (connect(avp_fd, (struct sockaddr *)(&avp_socket), -- sizeof(avp_socket.sun_family) + strlen(NodeCtl)) >= 0){ -+ SUN_LEN(&avp_socket)) >= 0){ - connected=1; - do_log(LOG_DEBUG, "avp_socket_connect connected to kavdaemon"); - return 0; diff --git a/mail/p3scan/files/patch-scanner_basic.c b/mail/p3scan/files/patch-scanner_basic.c index 35c4d842f8da..177c0b2d6095 100644 --- a/mail/p3scan/files/patch-scanner_basic.c +++ b/mail/p3scan/files/patch-scanner_basic.c @@ -1,10 +1,11 @@ ---- scanner_basic.c.orig Tue Feb 17 21:58:49 2004 -+++ scanner_basic.c Tue Feb 17 22:20:28 2004 -@@ -34,8 +34,9 @@ +--- scanner_basic.c.orig Thu Jan 6 04:53:04 2005 ++++ scanner_basic.c Fri Jul 29 10:26:09 2005 +@@ -33,9 +33,10 @@ + #include #include #include - #include +#include + #include #include -#include +#include diff --git a/mail/p3scan/files/patch-scanner_sample.c b/mail/p3scan/files/patch-scanner_sample.c index 580f1e331cbf..f9fa827ad828 100644 --- a/mail/p3scan/files/patch-scanner_sample.c +++ b/mail/p3scan/files/patch-scanner_sample.c @@ -1,11 +1,14 @@ ---- scanner_sample.c.orig Tue Feb 17 21:58:55 2004 -+++ scanner_sample.c Tue Feb 17 21:59:01 2004 -@@ -31,7 +31,7 @@ +--- scanner_sample.c.orig Fri Jul 29 10:08:05 2005 ++++ scanner_sample.c Fri Jul 29 10:08:37 2005 +@@ -31,10 +31,10 @@ */ #include -#include -+#include #include #include ++#include + + /* we need p3scan.h */ + #include "p3scan.h" diff --git a/mail/p3scan/files/patch-scanner_trophie.c b/mail/p3scan/files/patch-scanner_trophie.c index ca156fe528bc..4dc46810de72 100644 --- a/mail/p3scan/files/patch-scanner_trophie.c +++ b/mail/p3scan/files/patch-scanner_trophie.c @@ -1,5 +1,5 @@ ---- scanner_trophie.c.orig Thu Dec 4 02:57:56 2003 -+++ scanner_trophie.c Wed Feb 18 12:51:22 2004 +--- scanner_trophie.c.orig Wed Jan 5 20:53:04 2005 ++++ scanner_trophie.c Tue Jul 26 12:44:51 2005 @@ -37,11 +37,11 @@ #include #include @@ -10,15 +10,5 @@ #include #include +#include - + #include "p3scan.h" - -@@ -68,7 +68,7 @@ - if (trophie_fd!=-1 && connected==-1){ - do_log(LOG_DEBUG, "Trying to connect to socket"); - if (connect(trophie_fd, (struct sockaddr *)(&trophie_socket), -- sizeof(trophie_socket.sun_family) + strlen(config->virusscanner)) >= 0){ -+ SUN_LEN(&trophie_socket)) >= 0){ - connected=1; - do_log(LOG_DEBUG, "trophie_socket_connect connected"); - return 0; diff --git a/mail/p3scan/pkg-message b/mail/p3scan/pkg-message index 3cd4839a0b91..442fe457c9ae 100644 --- a/mail/p3scan/pkg-message +++ b/mail/p3scan/pkg-message @@ -16,4 +16,8 @@ in kernel, and add the forwarding rule into your IPFW table, while 192.168.0.254 is the IP of your internal interface, 8110 is the default port of P3scan, and 192.168.0.0/24 is the IP range of your LAN. + +Don't forget chown -R /var/run/p3scan /var/spool/p3scan + must be same as in running clamd. + **********************************************************************