View | Details | Raw Unified | Return to bug 78698
Collapse All | Expand All

(-)spamass-milter/Makefile (-19 / +27 lines)
Lines 6-34 Link Here
6
#
6
#
7
7
8
PORTNAME=	spamass-milter
8
PORTNAME=	spamass-milter
9
PORTVERSION=	0.2.0
9
PORTVERSION=	0.3.0
10
PORTREVISION=	5
11
CATEGORIES=	mail
10
CATEGORIES=	mail
12
MASTER_SITES=	${MASTER_SITE_SAVANNAH}
11
MASTER_SITES=	${MASTER_SITE_SAVANNAH}
13
MASTER_SITE_SUBDIR=	spamass-milt
12
MASTER_SITE_SUBDIR=	spamass-milt
14
13
15
MAINTAINER=	ports@FreeBSD.org
14
MAINTAINER=	ports@FreeBSD.org
16
COMMENT=	Sendmail Milter (mail filter) for SpamAssassin
15
COMMENT=	Sendmail Milter (mail filter) plugin for SpamAssassin
17
16
18
BUILD_DEPENDS=	spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
17
BUILD_DEPENDS=	spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
19
RUN_DEPENDS=	spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
18
RUN_DEPENDS=	spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
20
19
20
##
21
# Use the following quirks to choose which sendmail to use (ports or system):
21
#
22
#
22
# You can choose the sendmail to be used by specifying
23
#   WITH_SENDMAIL_BASE=yes
24
# or
25
#   WITH_SENDMAIL_PORT=yes
23
#
26
#
24
# WITH_SENDMAIL_BASE=yes
27
# If unspecified, check for an up-to-date system version but give an
25
#  or
28
# installed port preference over it.
26
# WITH_SENDMAIL_PORT=yes
27
#
29
#
28
30
29
# if no preference was set, check for an up to date base version
30
# but give an installed port preference over it.
31
32
.include <bsd.port.pre.mk>
31
.include <bsd.port.pre.mk>
33
32
34
.if exists(${LOCALBASE}/lib/libldap.so)
33
.if exists(${LOCALBASE}/lib/libldap.so)
Lines 36-42 Link Here
36
.endif
35
.endif
37
36
38
.if !defined(WITHOUT_LDAP) && defined(WITH_LDAP)
37
.if !defined(WITHOUT_LDAP) && defined(WITH_LDAP)
39
USE_OPENLDAP=		yes
38
USE_OPENLDAP=yes
40
.endif
39
.endif
41
40
42
.if !defined(WITH_SENDMAIL_BASE) && \
41
.if !defined(WITH_SENDMAIL_BASE) && \
Lines 56-80 Link Here
56
MILTERBASE?=	${LOCALBASE}
55
MILTERBASE?=	${LOCALBASE}
57
.endif
56
.endif
58
57
58
.if !defined(NOPORTDOCS)
59
PORTDOCS=	AUTHORS ChangeLog NEWS README TODO
60
.endif
61
59
MILTERINC=	${MILTERBASE}/include
62
MILTERINC=	${MILTERBASE}/include
60
MILTERLIB=	${MILTERBASE}/lib
63
MILTERLIB=	${MILTERBASE}/lib
61
64
62
CPPFLAGS+=	-I${MILTERINC}
65
CPPFLAGS+=	-I${MILTERINC}
63
LDFLAGS+=	-L${MILTERLIB}
66
LDFLAGS+=	-L${MILTERLIB}
64
67
65
GNU_CONFIGURE=	yes
66
CONFIGURE_ENV+=	CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
67
68
USE_REINPLACE=	yes
68
USE_REINPLACE=	yes
69
70
USE_RC_SUBR=	yes
69
USE_RC_SUBR=	yes
70
GNU_CONFIGURE=	yes
71
CONFIGURE_ENV+=	CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
71
RC_SCRIPTS_SUB=	PREFIX=${PREFIX} RC_SUBR=${RC_SUBR}
72
RC_SCRIPTS_SUB=	PREFIX=${PREFIX} RC_SUBR=${RC_SUBR}
72
73
74
PKGMESSAGE=	${WRKDIR}/pkg-message
75
73
MAN1=		spamass-milter.1
76
MAN1=		spamass-milter.1
74
77
75
post-patch:
78
post-patch:
76
	@${SED} -e 's|/usr/local|${PREFIX}|g' \
77
		${FILESDIR}/activation.txt > ${WRKDIR}/activation.txt
78
	@${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
79
	@${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
79
		${FILESDIR}/spamass-milter.sh > ${WRKDIR}/spamass-milter.sh
80
		${FILESDIR}/spamass-milter.sh > ${WRKDIR}/spamass-milter.sh
80
.if !defined(WITHOUT_LDAP) && defined(WITH_LDAP)
81
.if !defined(WITHOUT_LDAP) && defined(WITH_LDAP)
Lines 83-92 Link Here
83
84
84
post-install:
85
post-install:
85
	@${INSTALL_SCRIPT} ${WRKDIR}/spamass-milter.sh ${PREFIX}/etc/rc.d/spamass-milter.sh
86
	@${INSTALL_SCRIPT} ${WRKDIR}/spamass-milter.sh ${PREFIX}/etc/rc.d/spamass-milter.sh
87
	@${SED} -e's,%%PREFIX%%,${PREFIX},g' \
88
		${FILESDIR}/activation.txt > ${WRKDIR}/activation.txt
86
.if !defined(NOPORTDOCS)
89
.if !defined(NOPORTDOCS)
87
	${MKDIR} ${DOCSDIR}
90
	@${MKDIR} ${DOCSDIR}
88
	${INSTALL_DATA} ${WRKDIR}/activation.txt ${DOCSDIR}/activation.txt
91
	@${INSTALL_DATA} ${WRKDIR}/activation.txt ${DOCSDIR}/activation.txt
92
.for f in ${PORTDOCS}
93
	@${INSTALL_DATA} ${WRKSRC}/${f} ${DOCSDIR}
94
.endfor
89
.endif
95
.endif
96
	@${SED} -e's,%%DOCSDIR%%,${DOCSDIR},g' \
97
		${MASTERDIR}/pkg-message > ${PKGMESSAGE}
90
	@${CAT} ${PKGMESSAGE}
98
	@${CAT} ${PKGMESSAGE}
91
99
92
.include <bsd.port.post.mk>
100
.include <bsd.port.post.mk>
(-)spamass-milter/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
MD5 (spamass-milter-0.2.0.tar.gz) = 70da3e4a6039f5e738ce21f69430e230
1
MD5 (spamass-milter-0.3.0.tar.gz) = ced600331a0df7609fdbdf0e6d0eb943
2
SIZE (spamass-milter-0.2.0.tar.gz) = 113894
2
SIZE (spamass-milter-0.3.0.tar.gz) = 140126
(-)spamass-milter/files/activation.txt (-35 / +21 lines)
Lines 6-40 Link Here
6
6
7
2. If you didn't activate spamd (the SpamAssassin daemon), do so now:
7
2. If you didn't activate spamd (the SpamAssassin daemon), do so now:
8
8
9
	/usr/local/etc/rc.d/spamd.sh start
9
	%%PREFIX%%/etc/rc.d/sa-spamd.sh start
10
10
11
3. Activate spamass-milter:
11
3. Activate spamass-milter:
12
12
13
	/usr/local/etc/rc.d/spamass-milter.sh start
13
	%%PREFIX%%/etc/rc.d/spamass-milter.sh start
14
14
15
4. Backup your sendmail.cf (in /etc/mail).
15
4. Backup your sendmail.cf (in /etc/mail).
16
16
17
5. If you didn't create your own customized version of Sendmail .mc
17
5. If you didn't create your own customized version of Sendmail .mc
18
   file, create one from the default template (replace YOURNAME with a
18
   file, create one from the default template (hostname.mc):
19
   suitable name; a good candidate is the output of `hostname -s'):
20
19
21
	cd /etc/mail
20
	cd /etc/mail
22
	cp -p freebsd.mc YOURNAME.mc
21
	make
23
	echo "SENDMAIL_MC = /etc/mail/YOURNAME.mc" >> /etc/make.conf
24
25
   The last line tells the system to use your customized version instead
26
   of the default freebsd.mc when you run mergemaster(8) later on.
27
22
28
6. Add the spamass-milter hook to your Sendmail .mc file.  The magic
23
6. Add the spamass-milter hook to your hostname.mc file.  The magic
29
   line to add is:
24
   line to add is:
30
25
31
	INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')
26
	INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')
27
	define(`confMILTER_MACROS_CONNECT',`b, j, _, {daemon_name}, {if_name}, {if_addr}')dnl
32
28
33
   Everything should go on a single line, no line break/continuation is
29
   Everything should go on a single line, no line break/continuation is
34
   allowed!
30
   allowed!  The best place to add this is right after the dnsbl-related
35
31
   comments.  (Hint: Every comment in an .mc file starts with `dnl'.)
36
   The best place to add this is right after the dnsbl-related comments.
37
   (Hint: Every comment in an .mc file starts with `dnl'.)
38
32
39
7. Rebuild the sendmail.cf from your .mc file:
33
7. Rebuild the sendmail.cf from your .mc file:
40
34
Lines 42-80 Link Here
42
	make
36
	make
43
	make install
37
	make install
44
38
45
   Or you can run mergemaster(8) instead if you want, although it's an
46
   overkill.
47
48
8. Restart Sendmail:
39
8. Restart Sendmail:
49
40
50
	kill -HUP `head -1 /var/run/sendmail.pid`
41
	cd /etc/mail
42
	make stop
43
	make start
51
44
52
9. Test the whole piece:
45
9. Test the whole piece:
53
46
54
	/usr/sbin/sendmail root < /usr/local/share/doc/p5-Mail-SpamAssassin/sample-nonspam.txt
47
	echo "Testing spamass-milter..." | mail -s"Spam test" root
55
	/usr/sbin/sendmail root < /usr/local/share/doc/p5-Mail-SpamAssassin/sample-spam.txt
56
48
57
   Each of these commands might take a long time to finish (up to about
49
   This might take a long time to finish (up to about 10-20 seconds),
58
   10-20 seconds), so please be patient.
50
   since spamd has just started, so please be patient.
59
51
60
   You should receive two messages, one from `Keith Dawson' and the
52
   You (root) should receive a message from root@hostname, bearing this
61
   other from xl6Ety00V@fismat1.fcfm.buap.mx.  The one from Keith Dawson
53
   header line:
62
   shouldn't be tagged as a spam, bearing this header line:
63
54
64
	X-Spam-Status: No, ...
55
	X-Spam-Status: No, ...
65
56
66
   On the other hand, the one from xl6Ety00V@fismat1.fcfm.buap.mx should
57
   If things don't work as expected, promptly restore the stock FreeBSD
67
   be tagged as a spam, bearing these two header lines:
58
   sendmail.cf (/etc/mail/freebsd.cf) as your default sendmail config,
68
59
   or restore your own backup (if you keep one), as shown in step 8;
69
	X-Spam-Status: Yes, ...
60
   you may lose incoming mail otherwise!
70
	X-Spam-Flag: YES
71
72
   If things don't work as expected, promptly restore your sendmail.cf
73
   from the backup copy then restart sendmail as shown on step 8; you
74
   may lose incoming mail otherwise!
75
61
76
62
77
Now all messages received by Sendmail are filtered through
63
Now all messages received by Sendmail are filtered through
78
SpamAssassin, and probable spam messages are tagged with the header
64
SpamAssassin, and probable spam messages are tagged with the header
79
`X-Spam-Flag: YES'.  Tell your users about this so they can set up
65
`X-Spam-Flag: YES'.  Tell your users about this so they can set up
80
appropriate filters on their mail reader.
66
appropriate filters in their mail client.
(-)spamass-milter/files/patch-spamass-milter.cpp (-64 lines)
Lines 1-64 Link Here
1
--- spamass-milter.cpp.orig	Thu Jun 26 16:10:44 2003
2
+++ spamass-milter.cpp	Wed Oct 13 00:52:23 2004
3
@@ -102,6 +102,10 @@
4
 #include <csignal>
5
 #include <string>
6
 #include <iostream>
7
+using std::string;
8
+using std::cout;
9
+using std::cerr;
10
+using std::endl;
11
 
12
 #ifdef  __cplusplus
13
 extern "C" {
14
@@ -273,6 +277,7 @@
15
 				exit(errno);
16
 				break;
17
 			case 0: /* Child */
18
+				setsid();
19
 				break;
20
 			default: /* Parent */
21
 				exit(0);
22
@@ -351,6 +356,9 @@
23
   string::size_type eoh = ( eoh1 < eoh2 ? eoh1 : eoh2 );
24
   string::size_type bob = assassin->d().find_first_not_of("\r\n", eoh);
25
 
26
+  if (bob == string::npos)
27
+  	bob = assassin->d().size();
28
+
29
   update_or_insert(assassin, ctx, assassin->spam_flag(), &SpamAssassin::set_spam_flag, "X-Spam-Flag");
30
   update_or_insert(assassin, ctx, assassin->spam_status(), &SpamAssassin::set_spam_status, "X-Spam-Status");
31
 
32
@@ -365,7 +373,7 @@
33
 	{
34
 		int score, rv;
35
 		const char *spam_status = assassin->spam_status().c_str();
36
-		rv = sscanf(spam_status,"%*s hits=%d", &score);
37
+		rv = sscanf(spam_status,"%*s score=%d", &score);
38
 		if (rv != 1)
39
 			debug(D_ALWAYS, "Could not extract score from <%s>", spam_status);
40
 		else 
41
@@ -539,6 +547,10 @@
42
 	}
43
   }
44
 
45
+  /* if the header line ends in \r\n, don't return the \r */
46
+  if (header[field_end-1] == '\r')
47
+	field_end--;
48
+
49
   //  Maybe remove the whitespace picked up when a header wraps - this
50
   //  might actually be a requirement
51
   return header.substr( field_start, field_end - field_start );
52
@@ -1341,7 +1353,11 @@
53
 {
54
   // assuming we have a recipient in the form: <username@somehost.somedomain>
55
   // we return 'username'
56
-  return _rcpt.substr(1,_rcpt.find('@')-1);
57
+  int at = _rcpt.find('@');
58
+  int plus = _rcpt.find('+');
59
+  if (plus > 0 && plus < at)
60
+    at = plus;
61
+  return _rcpt.substr(1,at-1);
62
 }
63
 
64
 int
(-)spamass-milter/files/spamass-milter.sh (-10 / +16 lines)
Lines 24-50 Link Here
24
command=%%PREFIX%%/sbin/spamass-milter
24
command=%%PREFIX%%/sbin/spamass-milter
25
required_dirs=%%PREFIX%%/share/spamassassin
25
required_dirs=%%PREFIX%%/share/spamassassin
26
26
27
# set defaults
28
29
spamass_milter_enable=${spamass_milter_enable:-"NO"}
30
spamass_milter_socket=${spamass_milter_socket:-"/var/run/spamass-milter.sock"}
31
spamass_milter_flags=${spamass_milter_flags:-"-f -p ${spamass_milter_socket}"}
32
33
start_postcmd=start_postcmd
27
start_postcmd=start_postcmd
34
stop_postcmd=stop_postcmd
28
stop_postcmd=stop_postcmd
35
29
36
start_postcmd()
30
start_postcmd()
37
{
31
{
38
  sleep 1
32
  if test -f /var/run/sendmail.pid
39
  kill -HUP `head -1 /var/run/sendmail.pid`
33
  then
34
	sleep 1
35
	kill -HUP `head -1 /var/run/sendmail.pid`
36
  fi
40
}
37
}
41
38
42
stop_postcmd()
39
stop_postcmd()
43
{
40
{
44
  rm -f ${spamass_milter_socket}
41
  rm -f ${spamass_milter_socket}
45
  sleep 1
42
  if test -f /var/run/sendmail.pid
46
  kill -HUP `head -1 /var/run/sendmail.pid`
43
  then
44
	sleep 1
45
	kill -HUP `head -1 /var/run/sendmail.pid`
46
  fi
47
}
47
}
48
49
# set defaults
50
51
spamass_milter_enable=${spamass_milter_enable:-"NO"}
52
spamass_milter_socket=${spamass_milter_socket:-"/var/run/spamass-milter.sock"}
53
spamass_milter_flags=${spamass_milter_flags:-"-f -p ${spamass_milter_socket}"}
48
54
49
load_rc_config ${name}
55
load_rc_config ${name}
50
run_rc_command "$1"
56
run_rc_command "$1"
(-)spamass-milter/pkg-descr (-3 / +3 lines)
Lines 1-5 Link Here
1
spamass-milter is a little plugin for the Sendmail Milter (Mail Filter)
1
spamass-milter is a plugin for the Sendmail Milter (Mail Filter) library
2
library that pipes all incoming mail (including things received by
2
that pipes all incoming mail (including things received by rmail/UUCP)
3
rmail/UUCP) through the SpamAssassin, a highly customizable SpamFilter.
3
through the SpamAssassin, a highly customizable spam filter.
4
4
5
WWW: http://savannah.gnu.org/projects/spamass-milt/
5
WWW: http://savannah.gnu.org/projects/spamass-milt/
(-)spamass-milter/pkg-message (-3 / +12 lines)
Lines 1-5 Link Here
1
1
------------------------------------------------------------------------
2
------------------------------------------------------------------------
2
spamass-milter has been installed, but you have to activate it manually
3
spamass-milter has been installed, but it must be activated manually.
3
to use it.  Refer to ${PREFIX}/share/doc/spamass-milter/activation.txt
4
Pleae refer to...
4
for details.
5
6
  %%DOCSDIR%%/activation.txt
7
8
...for details.
9
10
You may also want to tweak your spamd rc.subr(8) startup flags to
11
specify a username to switch credentials to when delivering mail, if
12
applicable.
5
------------------------------------------------------------------------
13
------------------------------------------------------------------------
14
(-)spamass-milter/pkg-plist (-2 / +2 lines)
Lines 1-4 Link Here
1
sbin/spamass-milter
1
sbin/spamass-milter
2
etc/rc.d/spamass-milter.sh
2
etc/rc.d/spamass-milter.sh
3
%%PORTDOCS%%share/doc/spamass-milter/activation.txt
3
%%PORTDOCS%%%%DOCSDIR%%/activation.txt
4
%%PORTDOCS%%@dirrm share/doc/spamass-milter
4
@unexec rmdir %%DOCSDIR%% 2>/dev/null || true

Return to bug 78698