From d4122741f9c7069dd93b2125988abf6cff1512ee Mon Sep 17 00:00:00 2001 From: Peter Pentchev Date: Mon, 3 Nov 2003 13:42:16 +0000 Subject: Update to 5.3.29 and add the new SpamAssassion patch from Alex Dupre, with a configurable spam threshold value set by the SPAM_THRESHOLD knob. PR: 58306, 58805 Submitted by: Alex Dupre --- mail/vpopmail-devel/Makefile | 7 +- mail/vpopmail-devel/distinfo | 2 +- mail/vpopmail-devel/files/patch-config.h.in | 9 +- mail/vpopmail-devel/files/patch-configure | 36 +++++- mail/vpopmail-devel/files/patch-vdelivermail.c | 166 ++++++++++++++++++++++++- mail/vpopmail/Makefile | 7 +- mail/vpopmail/distinfo | 2 +- mail/vpopmail/files/patch-config.h.in | 9 +- mail/vpopmail/files/patch-configure | 36 +++++- mail/vpopmail/files/patch-vdelivermail.c | 166 ++++++++++++++++++++++++- 10 files changed, 406 insertions(+), 34 deletions(-) (limited to 'mail') diff --git a/mail/vpopmail-devel/Makefile b/mail/vpopmail-devel/Makefile index 98d51a4f888b..61f06c59cdb4 100644 --- a/mail/vpopmail-devel/Makefile +++ b/mail/vpopmail-devel/Makefile @@ -6,7 +6,7 @@ # PORTNAME= vpopmail -PORTVERSION= 5.3.28 +PORTVERSION= 5.3.29 CATEGORIES= mail MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME} @@ -61,6 +61,7 @@ CONFIGURE_ARGS= --enable-qmaildir=${QMAIL_DIR} \ # # HARDQUOTA - size of hard quota, or 'n' for no hard quota # RELAYCLEAR - time in minutes before clearing relay hole (requires roaming) +# SPAM_THRESHOLD - minimum score required to delete spam messages (requires spamassassin) # DEFAULT_DOMAIN - default domain for non-vhost lookups # WITH_SINGLE_DOMAIN - optimize for a site with many users in a single domain # LOGLEVEL - n - no logging, y - log all, @@ -115,6 +116,7 @@ CONFIGURE_ARGS= --enable-qmaildir=${QMAIL_DIR} \ HARDQUOTA?= 10000000 RELAYCLEAR?= 30 +SPAM_THRESHOLD?=15 LOGLEVEL?= y .if defined(WITH_MYSQL) @@ -243,7 +245,8 @@ CONFIGURE_ARGS+= --enable-domainquotas=y .if defined(WITH_SPAMASSASSIN) BUILD_DEPENDS= spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin -CONFIGURE_ARGS+= --enable-spamassassin=${LOCALBASE}/bin/spamc +CONFIGURE_ARGS+= --enable-spamassassin=${LOCALBASE}/bin/spamc \ + --enable-spam-threshold=${SPAM_THRESHOLD} .endif # autoconf and automake can remove our patches to the configure scripts. diff --git a/mail/vpopmail-devel/distinfo b/mail/vpopmail-devel/distinfo index fbf89bc15ed2..50e88b0f4b7d 100644 --- a/mail/vpopmail-devel/distinfo +++ b/mail/vpopmail-devel/distinfo @@ -1 +1 @@ -MD5 (vpopmail-5.3.28.tar.gz) = 68495c9309aa03aec2a754702c4d8a67 +MD5 (vpopmail-5.3.29.tar.gz) = 42904ce91d4b0398ae8f964d692f88af diff --git a/mail/vpopmail-devel/files/patch-config.h.in b/mail/vpopmail-devel/files/patch-config.h.in index f795be18e767..be792244bff0 100644 --- a/mail/vpopmail-devel/files/patch-config.h.in +++ b/mail/vpopmail-devel/files/patch-config.h.in @@ -1,11 +1,14 @@ ---- config.h.in.orig Fri Oct 24 18:43:20 2003 -+++ config.h.in Fri Oct 24 18:43:45 2003 -@@ -89,6 +89,9 @@ +--- config.h.in.orig Tue Oct 7 03:25:53 2003 ++++ config.h.in Sat Nov 1 10:59:26 2003 +@@ -89,6 +89,12 @@ #undef QMAILNEWU /* */ +#undef SPAMC + ++/* */ ++#undef SPAM_THRESHOLD ++ +/* */ #undef QMAILINJECT diff --git a/mail/vpopmail-devel/files/patch-configure b/mail/vpopmail-devel/files/patch-configure index af635b3504dc..1045f191c5be 100644 --- a/mail/vpopmail-devel/files/patch-configure +++ b/mail/vpopmail-devel/files/patch-configure @@ -1,15 +1,17 @@ --- configure.orig Fri Oct 17 01:12:22 2003 -+++ configure Sat Oct 25 01:18:27 2003 -@@ -20,6 +20,8 @@ ++++ configure Sat Nov 1 14:01:27 2003 +@@ -20,6 +20,10 @@ ac_help="$ac_help --enable-qmail-newmrh=path Full path to qmail-newmrh program" ac_help="$ac_help + --enable-spamassassin=path Enable SpamAssassin. Full path to spamc program. default /usr/local/bin/spamc" ++ac_help="$ac_help ++ --enable-spam-threshold=# or n Automatically delete messages that score more than # spam hits" +ac_help="$ac_help --enable-vpopuser=vpopmail user vchkpw was installed as." ac_help="$ac_help --enable-vpopgroup=vchkpw group vchkpw was installed as." -@@ -1317,7 +1319,7 @@ +@@ -1317,7 +1321,7 @@ ;; esac @@ -18,7 +20,7 @@ then echo "configure: warning: === vpopmail must be configured as root. ===" 1>&2 echo "configure: warning: === please switch to the root user and ===" 1>&2 -@@ -1446,6 +1448,27 @@ +@@ -1446,6 +1450,49 @@ EOF @@ -41,12 +43,34 @@ + cat >> confdefs.h <> confdefs.h < 0) ++ while ((file_count = read(0, msgbuf, MSG_BUF_SIZE)) > 0) + write(1, msgbuf, file_count); + _exit(0); + } @@ -44,7 +63,144 @@ + dup2(pim[0], 0); + close(pim[0]); + } ++#ifdef SPAM_THRESHOLD ++ /* silently delete message if spam level > SPAM_THRESHOLD */ ++ if (is_spam(SPAM_THRESHOLD) == 1) { ++ close(write_fd); ++ if (unlink(local_file) != 0) { ++ printf("unlink failed %s errno = %d\n", local_file, errno); ++ return(errno); ++ } ++ return(0); ++ } ++ ++#ifdef MAKE_SEEKABLE ++ if (!Seekable(0)) ++ MakeSeekable(stdin); ++#endif ++ ++ if (lseek(0, 0L, SEEK_SET) < 0) { ++ printf("lseek errno=%d\n", errno); ++ return(errno); ++ } ++#endif +#endif /* read it in chunks and write it to the new file */ while((file_count=read(0,msgbuf,MSG_BUF_SIZE))>0) { +@@ -881,6 +932,9 @@ + if (strncmp(loop_buf, "Delivered-To: ", 14) == 0 && + is_loop_match(loop_buf, address)==1 ) { + ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); ++ + /* return the loop found */ + return(1); + +@@ -919,6 +973,8 @@ + * looping not found value + */ + if ( found == 0 ) { ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); + /* return not found looping message value */ + return(0); + } +@@ -1335,3 +1391,96 @@ + return(1); + } + ++#ifdef SPAM_THRESHOLD ++/* Check for a spam message ++ * This is done by checking for a matching line ++ * in the email headers for X-Spam-Level: which ++ * we put in each spam email ++ * ++ * Return 1 if spam ++ * Return 0 if not spam ++ * Return -1 on error ++ */ ++int is_spam(int threshold) ++{ ++ int i; ++ int found; ++ ++#ifdef MAKE_SEEKABLE ++ if (!Seekable(0)) ++ MakeSeekable(stdin); ++#endif ++ ++ if ( lseek(0, 0L, SEEK_SET) < 0 ) { ++ printf("lseek errno=%d\n", errno); ++ return(errno); ++ } ++ ++ while (fgets(spam_buf, sizeof(spam_buf), stdin) != NULL){ ++ ++ /* if we find the line, return error (looping) */ ++ if (strncmp(spam_buf, "X-Spam-Level: ", 14) == 0 && ++ is_spam_match(spam_buf, threshold) ==1) { ++ ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); ++ ++ /* return the spam found */ ++ return(1); ++ ++ /* check for the start of the body, we only need ++ * to check the headers. ++ */ ++ } else { ++ ++ /* walk through the charaters in the body */ ++ for (i = 0, found = 0; spam_buf[i] != 0 && found == 0; ++i) { ++ switch(spam_buf[i]) { ++ ++ /* skip blank spaces and new lines */ ++ case ' ': ++ case '\n': ++ case '\t': ++ case '\r': ++ break; ++ ++ /* found a non blank, so we are still ++ * in the headers ++ */ ++ default: ++ ++ /* set the found non blank char flag */ ++ found = 1; ++ break; ++ } ++ } ++ ++ /* if the line only had blanks, then it is the ++ * delimiting line between the headers and the ++ * body. We don't need to check the body for ++ * the X-Spam-Level: line. Hence, we ++ * are done with our search and can return the ++ * spam not found value ++ */ ++ if (found == 0) { ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); ++ /* return not found spam message value */ ++ return(0); ++ } ++ } ++ } ++ ++ /* if we get here then the there is either no body ++ * or the logic above failed and we scanned ++ * the whole email, headers and body. ++ */ ++ return(0); ++} ++ ++int is_spam_match(char *xsl, int threshold) ++{ ++ if (strlen(xsl) - strlen("X-Spam-Level: ") > threshold) return(1); ++ else return(0); ++} ++#endif diff --git a/mail/vpopmail/Makefile b/mail/vpopmail/Makefile index 98d51a4f888b..61f06c59cdb4 100644 --- a/mail/vpopmail/Makefile +++ b/mail/vpopmail/Makefile @@ -6,7 +6,7 @@ # PORTNAME= vpopmail -PORTVERSION= 5.3.28 +PORTVERSION= 5.3.29 CATEGORIES= mail MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME} @@ -61,6 +61,7 @@ CONFIGURE_ARGS= --enable-qmaildir=${QMAIL_DIR} \ # # HARDQUOTA - size of hard quota, or 'n' for no hard quota # RELAYCLEAR - time in minutes before clearing relay hole (requires roaming) +# SPAM_THRESHOLD - minimum score required to delete spam messages (requires spamassassin) # DEFAULT_DOMAIN - default domain for non-vhost lookups # WITH_SINGLE_DOMAIN - optimize for a site with many users in a single domain # LOGLEVEL - n - no logging, y - log all, @@ -115,6 +116,7 @@ CONFIGURE_ARGS= --enable-qmaildir=${QMAIL_DIR} \ HARDQUOTA?= 10000000 RELAYCLEAR?= 30 +SPAM_THRESHOLD?=15 LOGLEVEL?= y .if defined(WITH_MYSQL) @@ -243,7 +245,8 @@ CONFIGURE_ARGS+= --enable-domainquotas=y .if defined(WITH_SPAMASSASSIN) BUILD_DEPENDS= spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin -CONFIGURE_ARGS+= --enable-spamassassin=${LOCALBASE}/bin/spamc +CONFIGURE_ARGS+= --enable-spamassassin=${LOCALBASE}/bin/spamc \ + --enable-spam-threshold=${SPAM_THRESHOLD} .endif # autoconf and automake can remove our patches to the configure scripts. diff --git a/mail/vpopmail/distinfo b/mail/vpopmail/distinfo index fbf89bc15ed2..50e88b0f4b7d 100644 --- a/mail/vpopmail/distinfo +++ b/mail/vpopmail/distinfo @@ -1 +1 @@ -MD5 (vpopmail-5.3.28.tar.gz) = 68495c9309aa03aec2a754702c4d8a67 +MD5 (vpopmail-5.3.29.tar.gz) = 42904ce91d4b0398ae8f964d692f88af diff --git a/mail/vpopmail/files/patch-config.h.in b/mail/vpopmail/files/patch-config.h.in index f795be18e767..be792244bff0 100644 --- a/mail/vpopmail/files/patch-config.h.in +++ b/mail/vpopmail/files/patch-config.h.in @@ -1,11 +1,14 @@ ---- config.h.in.orig Fri Oct 24 18:43:20 2003 -+++ config.h.in Fri Oct 24 18:43:45 2003 -@@ -89,6 +89,9 @@ +--- config.h.in.orig Tue Oct 7 03:25:53 2003 ++++ config.h.in Sat Nov 1 10:59:26 2003 +@@ -89,6 +89,12 @@ #undef QMAILNEWU /* */ +#undef SPAMC + ++/* */ ++#undef SPAM_THRESHOLD ++ +/* */ #undef QMAILINJECT diff --git a/mail/vpopmail/files/patch-configure b/mail/vpopmail/files/patch-configure index af635b3504dc..1045f191c5be 100644 --- a/mail/vpopmail/files/patch-configure +++ b/mail/vpopmail/files/patch-configure @@ -1,15 +1,17 @@ --- configure.orig Fri Oct 17 01:12:22 2003 -+++ configure Sat Oct 25 01:18:27 2003 -@@ -20,6 +20,8 @@ ++++ configure Sat Nov 1 14:01:27 2003 +@@ -20,6 +20,10 @@ ac_help="$ac_help --enable-qmail-newmrh=path Full path to qmail-newmrh program" ac_help="$ac_help + --enable-spamassassin=path Enable SpamAssassin. Full path to spamc program. default /usr/local/bin/spamc" ++ac_help="$ac_help ++ --enable-spam-threshold=# or n Automatically delete messages that score more than # spam hits" +ac_help="$ac_help --enable-vpopuser=vpopmail user vchkpw was installed as." ac_help="$ac_help --enable-vpopgroup=vchkpw group vchkpw was installed as." -@@ -1317,7 +1319,7 @@ +@@ -1317,7 +1321,7 @@ ;; esac @@ -18,7 +20,7 @@ then echo "configure: warning: === vpopmail must be configured as root. ===" 1>&2 echo "configure: warning: === please switch to the root user and ===" 1>&2 -@@ -1446,6 +1448,27 @@ +@@ -1446,6 +1450,49 @@ EOF @@ -41,12 +43,34 @@ + cat >> confdefs.h <> confdefs.h < 0) ++ while ((file_count = read(0, msgbuf, MSG_BUF_SIZE)) > 0) + write(1, msgbuf, file_count); + _exit(0); + } @@ -44,7 +63,144 @@ + dup2(pim[0], 0); + close(pim[0]); + } ++#ifdef SPAM_THRESHOLD ++ /* silently delete message if spam level > SPAM_THRESHOLD */ ++ if (is_spam(SPAM_THRESHOLD) == 1) { ++ close(write_fd); ++ if (unlink(local_file) != 0) { ++ printf("unlink failed %s errno = %d\n", local_file, errno); ++ return(errno); ++ } ++ return(0); ++ } ++ ++#ifdef MAKE_SEEKABLE ++ if (!Seekable(0)) ++ MakeSeekable(stdin); ++#endif ++ ++ if (lseek(0, 0L, SEEK_SET) < 0) { ++ printf("lseek errno=%d\n", errno); ++ return(errno); ++ } ++#endif +#endif /* read it in chunks and write it to the new file */ while((file_count=read(0,msgbuf,MSG_BUF_SIZE))>0) { +@@ -881,6 +932,9 @@ + if (strncmp(loop_buf, "Delivered-To: ", 14) == 0 && + is_loop_match(loop_buf, address)==1 ) { + ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); ++ + /* return the loop found */ + return(1); + +@@ -919,6 +973,8 @@ + * looping not found value + */ + if ( found == 0 ) { ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); + /* return not found looping message value */ + return(0); + } +@@ -1335,3 +1391,96 @@ + return(1); + } + ++#ifdef SPAM_THRESHOLD ++/* Check for a spam message ++ * This is done by checking for a matching line ++ * in the email headers for X-Spam-Level: which ++ * we put in each spam email ++ * ++ * Return 1 if spam ++ * Return 0 if not spam ++ * Return -1 on error ++ */ ++int is_spam(int threshold) ++{ ++ int i; ++ int found; ++ ++#ifdef MAKE_SEEKABLE ++ if (!Seekable(0)) ++ MakeSeekable(stdin); ++#endif ++ ++ if ( lseek(0, 0L, SEEK_SET) < 0 ) { ++ printf("lseek errno=%d\n", errno); ++ return(errno); ++ } ++ ++ while (fgets(spam_buf, sizeof(spam_buf), stdin) != NULL){ ++ ++ /* if we find the line, return error (looping) */ ++ if (strncmp(spam_buf, "X-Spam-Level: ", 14) == 0 && ++ is_spam_match(spam_buf, threshold) ==1) { ++ ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); ++ ++ /* return the spam found */ ++ return(1); ++ ++ /* check for the start of the body, we only need ++ * to check the headers. ++ */ ++ } else { ++ ++ /* walk through the charaters in the body */ ++ for (i = 0, found = 0; spam_buf[i] != 0 && found == 0; ++i) { ++ switch(spam_buf[i]) { ++ ++ /* skip blank spaces and new lines */ ++ case ' ': ++ case '\n': ++ case '\t': ++ case '\r': ++ break; ++ ++ /* found a non blank, so we are still ++ * in the headers ++ */ ++ default: ++ ++ /* set the found non blank char flag */ ++ found = 1; ++ break; ++ } ++ } ++ ++ /* if the line only had blanks, then it is the ++ * delimiting line between the headers and the ++ * body. We don't need to check the body for ++ * the X-Spam-Level: line. Hence, we ++ * are done with our search and can return the ++ * spam not found value ++ */ ++ if (found == 0) { ++ /* seek to the end of stdin */ ++ fseek(stdin, 0L, SEEK_END); ++ /* return not found spam message value */ ++ return(0); ++ } ++ } ++ } ++ ++ /* if we get here then the there is either no body ++ * or the logic above failed and we scanned ++ * the whole email, headers and body. ++ */ ++ return(0); ++} ++ ++int is_spam_match(char *xsl, int threshold) ++{ ++ if (strlen(xsl) - strlen("X-Spam-Level: ") > threshold) return(1); ++ else return(0); ++} ++#endif -- cgit v1.2.3