From alex@armada.alexdupre.com  Fri Oct 24 16:40:10 2003
Return-Path: <alex@armada.alexdupre.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 17C4D16A4BF; Fri, 24 Oct 2003 16:40:10 -0700 (PDT)
Received: from relay.gufi.org (civetta.gufi.org [212.110.23.10])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 22A3043FD7; Fri, 24 Oct 2003 16:40:06 -0700 (PDT)
	(envelope-from alex@armada.alexdupre.com)
Received: from armada.alexdupre.com (host245-49.pool8288.interbusiness.it [82.88.49.245])
	by relay.gufi.org (Postfix) with ESMTP
	id 98CCC20F54; Sat, 25 Oct 2003 01:40:03 +0200 (CEST)
Received: from armada.alexdupre.com (localhost [127.0.0.1])
	by armada.alexdupre.com (8.12.10/8.12.10) with ESMTP id h9ONe7XR007468;
	Sat, 25 Oct 2003 01:40:07 +0200 (CEST)
	(envelope-from alex@armada.alexdupre.com)
Received: (from alex@localhost)
	by armada.alexdupre.com (8.12.10/8.12.10/Submit) id h9ONe73f007467;
	Sat, 25 Oct 2003 01:40:07 +0200 (CEST)
	(envelope-from alex)
Message-Id: <200310242340.h9ONe73f007467@armada.alexdupre.com>
Date: Sat, 25 Oct 2003 01:40:07 +0200 (CEST)
From: Alex Dupre <sysadmin@alexdupre.com>
Reply-To: Alex Dupre <sysadmin@alexdupre.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: roam@freebsd.org
Subject: [New Feature] SpamAssassin support into vpopmail
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         58503
>Category:       ports
>Synopsis:       [New Feature] SpamAssassin support into vpopmail
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    roam
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 24 16:50:22 PDT 2003
>Closed-Date:    Fri Oct 31 09:24:35 PST 2003
>Last-Modified:  Fri Oct 31 09:24:35 PST 2003
>Originator:     Alex Dupre
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD armada.alexdupre.com 5.1-CURRENT FreeBSD 5.1-CURRENT #3: Mon Oct 20 18:11:07 CEST 2003 alex@armada.alexdupre.com:/usr/obj/usr/src/sys/ARMADA i386


	
>Description:
Add SpamAssassin support to vpopmail.
The checks are done before Maildir delivery and are user configurable.

While I'm here, move the USE_MYSQL section before include bsd.port.pre.mk.
	
>How-To-Repeat:
	
>Fix:

	

--- vpopmail.diff begins here ---
diff -ruN vpopmail.orig/Makefile vpopmail/Makefile
--- vpopmail.orig/Makefile	Sat Oct 25 01:30:46 2003
+++ vpopmail/Makefile	Sat Oct 25 01:08:04 2003
@@ -55,6 +55,7 @@
 # WITHOUT_USERS_BIG_DIR - disables using big directories for users
 # WITHOUT_SEEKABLE - disables vdelivermail's attempt to make its input seekable
 # WITH_DOMAIN_QUOTAS	- enable domain quotas
+# WITH_SPAMASSASSIN	- enable SpamAssassin checks before Maildir delivery
 #
 # Set these to the values you'd prefer
 #
@@ -116,6 +117,33 @@
 RELAYCLEAR?=	30
 LOGLEVEL?=	y
 
+.if defined(WITH_MYSQL)
+USE_MYSQL=		yes
+CONFIGURE_ARGS+=	--enable-mysql=y \
+			--enable-incdir=${LOCALBASE}/include/mysql \
+			--enable-libdir=${LOCALBASE}/lib/mysql
+.if defined(WITH_MYSQL_REPLICATION)
+CONFIGURE_ARGS+=	--enable-mysql-replication=y
+.endif
+.if defined(WITH_MYSQL_LOG)
+CONFIGURE_ARGS+=	--enable-mysql-logging=y
+.endif
+.if defined(WITH_MYSQL_LIMITS)
+CONFIGURE_ARGS+=	--enable-mysql-limits=y
+.endif
+
+WITH_MYSQL_SERVER?=		localhost
+WITH_MYSQL_READ_SERVER?=	${WITH_MYSQL_SERVER}
+WITH_MYSQL_UPDATE_SERVER?=	${WITH_MYSQL_SERVER}
+WITH_MYSQL_USER?=		vpopmail
+WITH_MYSQL_READ_USER?=		${WITH_MYSQL_USER}
+WITH_MYSQL_UPDATE_USER?=	${WITH_MYSQL_USER}
+WITH_MYSQL_PASSWD?=		secret
+WITH_MYSQL_READ_PASSWD?=	${WITH_MYSQL_PASSWD}
+WITH_MYSQL_UPDATE_PASSWD?=	${WITH_MYSQL_PASSWD}
+WITH_MYSQL_DB?=			vpopmail
+.endif
+
 .include <bsd.port.pre.mk>
 
 .if exists(${LOCALBASE}/qmail/bin/qmail-send)
@@ -168,33 +196,6 @@
 CONFIGURE_ARGS+=	--enable-learn-passwords=y
 .endif
 
-.if defined(WITH_MYSQL)
-USE_MYSQL=		yes
-CONFIGURE_ARGS+=	--enable-mysql=y \
-			--enable-incdir=${LOCALBASE}/include/mysql \
-			--enable-libdir=${LOCALBASE}/lib/mysql
-.if defined(WITH_MYSQL_REPLICATION)
-CONFIGURE_ARGS+=	--enable-mysql-replication=y
-.endif
-.if defined(WITH_MYSQL_LOG)
-CONFIGURE_ARGS+=	--enable-mysql-logging=y
-.endif
-.if defined(WITH_MYSQL_LIMITS)
-CONFIGURE_ARGS+=	--enable-mysql-limits=y
-.endif
-
-WITH_MYSQL_SERVER?=		localhost
-WITH_MYSQL_READ_SERVER?=	${WITH_MYSQL_SERVER}
-WITH_MYSQL_UPDATE_SERVER?=	${WITH_MYSQL_SERVER}
-WITH_MYSQL_USER?=	vpopmail
-WITH_MYSQL_READ_USER?=	${WITH_MYSQL_USER}
-WITH_MYSQL_UPDATE_USER?=	${WITH_MYSQL_USER}
-WITH_MYSQL_PASSWD?=	secret
-WITH_MYSQL_READ_PASSWD?=	${WITH_MYSQL_PASSWD}
-WITH_MYSQL_UPDATE_PASSWD?=	${WITH_MYSQL_PASSWD}
-WITH_MYSQL_DB?=		vpopmail
-.endif
-
 .if defined(WITH_SYBASE)
 CONFIGURE_ARGS+=	--enable-sybase=y
 .endif
@@ -240,6 +241,11 @@
 CONFIGURE_ARGS+=	--enable-domainquotas=y
 .endif
 
+.if defined(WITH_SPAMASSASSIN)
+BUILD_DEPENDS=	spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
+CONFIGURE_ARGS+=	--enable-spamassassin=${LOCALBASE}/bin/spamc
+.endif
+
 # autoconf and automake can remove our patches to the configure scripts.
 
 post-patch:
@@ -309,5 +315,11 @@
 		>> ${PREFIX}/vpopmail/etc/vpopmail.mysql
 .endif
 	${CHOWN} -R vpopmail:vchkpw ${PREFIX}/vpopmail/bin/ ${PREFIX}/vpopmail/etc/
+.if defined(WITH_SPAMASSASSIN)
+	${ECHO_CMD} "***********************************************************************"
+	${ECHO_CMD} "Now you should add the following options to your spamd.sh startup file:"
+	${ECHO_CMD} "-v -u vpopmail"
+	${ECHO_CMD} "***********************************************************************"
+.endif
 
 .include <bsd.port.post.mk>
diff -ruN vpopmail.orig/files/patch-config.h.in vpopmail/files/patch-config.h.in
--- vpopmail.orig/files/patch-config.h.in	Thu Jan  1 01:00:00 1970
+++ vpopmail/files/patch-config.h.in	Fri Oct 24 18:44:01 2003
@@ -0,0 +1,12 @@
+--- 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 @@
+ #undef QMAILNEWU
+ 
+ /*  */
++#undef SPAMC
++
++/*  */
+ #undef QMAILINJECT
+ 
+ /*  */
diff -ruN vpopmail.orig/files/patch-configure vpopmail/files/patch-configure
--- vpopmail.orig/files/patch-configure	Sat Oct 25 01:28:04 2003
+++ vpopmail/files/patch-configure	Sat Oct 25 01:18:47 2003
@@ -1,6 +1,15 @@
---- configure.orig	Thu Aug 28 21:09:47 2003
-+++ configure	Fri Sep  5 00:13:14 2003
-@@ -1317,7 +1317,7 @@
+--- configure.orig	Fri Oct 17 01:12:22 2003
++++ configure	Sat Oct 25 01:18:27 2003
+@@ -20,6 +20,8 @@
+ 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-vpopuser=vpopmail   user vchkpw was installed as."
+ ac_help="$ac_help
+   --enable-vpopgroup=vchkpw   group vchkpw was installed as."
+@@ -1317,7 +1319,7 @@
    ;;
  esac
  
@@ -9,7 +18,35 @@
  then
      echo "configure: warning: === vpopmail must be configured as root. ===" 1>&2
      echo "configure: warning: === please switch to the root user and  ===" 1>&2
-@@ -1601,15 +1601,6 @@
+@@ -1446,6 +1448,27 @@
+ EOF
+ 
+ 
++# Check whether --enable-spamassassin or --disable-spamassassin was given.
++if test "${enable_spamassassin+set}" = set; then
++  enableval="$enable_spamassassin"
++  spamc="$enableval"
++
++  case $spamc in
++  1*|y*|Y*)
++      spamc="/usr/local/bin/spamc"
++      ;;
++  esac
++
++  if test ! -f "$spamc"
++  then
++      { echo "configure: error: Unable to find your spamc file, specify --enable-spamassassin=/full/path/to/spamc" 1>&2; exit 1; }
++  fi
++
++  cat >> confdefs.h <<EOF
++#define SPAMC "$spamc"
++EOF
++fi
++
+ 
+ vpopuser="vpopmail"
+ # Check whether --enable-vpopuser or --disable-vpopuser was given.
+@@ -1601,15 +1624,6 @@
  EOF
  
  
@@ -25,7 +62,7 @@
  # Check whether --enable-roaming-users or --disable-roaming-users was given.
  if test "${enable_roaming_users+set}" = set; then
    enableval="$enable_roaming_users"
-@@ -1671,17 +1662,7 @@
+@@ -1671,17 +1685,7 @@
  if test "${enable_tcpserver_file+set}" = set; then
    enableval="$enable_tcpserver_file"
    tcpserver_file="$enableval"
diff -ruN vpopmail.orig/files/patch-vdelivermail.c vpopmail/files/patch-vdelivermail.c
--- vpopmail.orig/files/patch-vdelivermail.c	Sat Oct 25 01:28:04 2003
+++ vpopmail/files/patch-vdelivermail.c	Fri Oct 24 18:32:13 2003
@@ -1,6 +1,6 @@
---- vdelivermail.c.orig	Sat Nov  2 22:34:39 2002
-+++ vdelivermail.c	Sat Nov  2 22:35:20 2002
-@@ -263,7 +263,7 @@
+--- vdelivermail.c.orig	Mon Oct 20 20:59:57 2003
++++ vdelivermail.c	Fri Oct 24 18:31:45 2003
+@@ -257,7 +257,7 @@
  
      /* check for wildcard if there's no match */
      if(tmpstr == NULL) {
@@ -9,3 +9,42 @@
              if(TheUser[i-1]=='-') {
                  tmpuser[0] = '\0';
                  strncat(tmpuser,TheUser,i); 
+@@ -444,6 +444,7 @@
+  int inject = 0;
+  FILE *fs;
+  char tmp_file[256];
++ int pim[2];
+ 
+     /* check if the email is looping to this user */
+     if ( is_looping( address ) == 1 ) {
+@@ -631,6 +632,30 @@
+         }
+     }
+ 
++#ifdef SPAMC
++    /* fork the SpamAssassin client - patch by Alex Dupre */
++    if (!pipe(pim)) {
++        pid = vfork();
++        switch (pid) {
++            case -1:
++                close(pim[0]);
++                close(pim[1]);
++                break;
++            case 0:
++                close(pim[0]);
++                dup2(pim[1], 1);
++                close(pim[1]);
++                if (execl(SPAMC, SPAMC, "-u", maildir_to_email(address), 0) == -1) {
++                    while ((file_count=read(0, msgbuf, MSG_BUF_SIZE)) > 0)
++                        write(1, msgbuf, file_count);
++                    _exit(0);
++                }
++        }
++        close(pim[1]);
++        dup2(pim[0], 0);
++        close(pim[0]);
++    }
++#endif
+ 
+     /* read it in chunks and write it to the new file */
+     while((file_count=read(0,msgbuf,MSG_BUF_SIZE))>0) {
--- vpopmail.diff ends here ---



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->roam  
Responsible-Changed-By: krion 
Responsible-Changed-When: Fri Oct 24 16:56:59 PDT 2003 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=58503 
State-Changed-From-To: open->closed 
State-Changed-By: roam 
State-Changed-When: Fri Oct 31 09:24:16 PST 2003 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=58503 
>Unformatted:
