aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/milter-regex/Makefile14
-rw-r--r--mail/milter-regex/files/milterregex.sh.in42
-rw-r--r--mail/milter-regex/files/patch-milter-regex.825
-rw-r--r--mail/milter-regex/files/patch-milter-regex.c85
-rw-r--r--mail/milter-regex/pkg-install55
-rw-r--r--mail/milter-regex/pkg-message11
-rw-r--r--mail/milter-regex/pkg-plist3
7 files changed, 178 insertions, 57 deletions
diff --git a/mail/milter-regex/Makefile b/mail/milter-regex/Makefile
index af01401bccd6..55b0df1b8df3 100644
--- a/mail/milter-regex/Makefile
+++ b/mail/milter-regex/Makefile
@@ -12,7 +12,7 @@ CATEGORIES= mail
MASTER_SITES= http://www.benzedrine.cx/
DISTNAME= milter-regex-${PORTVERSION}
-MAINTAINER= dhartmei@FreeBSD.org
+MAINTAINER= ports@freebsd.org
COMMENT= Milter plugin to sendmail for regular expression filtering
WRKSRC= ${WRKDIR}/milter-regex
@@ -21,6 +21,11 @@ MAN8= milter-regex.8
PLIST_FILES= libexec/milter-regex
MAKE_ENV+= LDFLAGS="${LDFLAGS}"
+USE_RC_SUBR= milterregex.sh
+
+SPOOLDIR= /var/run/milter-regex
+SUB_LIST= SPOOLDIR=${SPOOLDIR}
+
.include <bsd.port.pre.mk>
.if defined(SENDMAIL_MILTER_PORT)
@@ -43,9 +48,11 @@ pre-everything::
post-patch:
@${REINPLACE_CMD} -e \
"s:/etc/milter-regex.conf:${PREFIX}/etc/milter-regex.conf:g; \
+ s:/var/spool/milter-regex:${SPOOLDIR}:g; \
s:_milter-regex:${MAILUSER}:g;" ${WRKSRC}/milter-regex.c
@${REINPLACE_CMD} -e \
"s:/etc/milter-regex.conf:${PREFIX}/etc/milter-regex.conf:g; \
+ s:/var/spool/milter-regex:${SPOOLDIR}:g; \
s:mailstats 1:mailstats 8:;" ${WRKSRC}/milter-regex.8
@${REINPLACE_CMD} -e "s:-lpthread:${PTHREAD_LIBS}:g; \
s:-I/usr/src/gnu/usr.sbin/sendmail/include:${PTHREAD_CFLAGS}:g; \
@@ -55,6 +62,9 @@ post-patch:
do-install:
@${INSTALL_PROGRAM} ${WRKSRC}/milter-regex ${PREFIX}/libexec
@${INSTALL_MAN} ${WRKSRC}/milter-regex.8 ${PREFIX}/man/man8
- @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+ @${INSTALL} -d -o ${MAILUSER} -g daemon -m 0700 ${SPOOLDIR}
+
+post-install:
+ @${CAT} ${PKGMESSAGE}
.include <bsd.port.post.mk>
diff --git a/mail/milter-regex/files/milterregex.sh.in b/mail/milter-regex/files/milterregex.sh.in
new file mode 100644
index 000000000000..f869e5cabc5f
--- /dev/null
+++ b/mail/milter-regex/files/milterregex.sh.in
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Start or stop milterregex
+
+# PROVIDE: milterregex
+# REQUIRE: DAEMON
+# BEFORE: mail
+# KEYWORD: FreeBSD shutdown
+#
+# NOTE for FreeBSD 5.0+:
+# If you want this script to start with the base rc scripts
+# move milterregex to /etc/rc.d/milterregex
+
+prefix=%%PREFIX%%
+spooldir=%%SPOOLDIR%%
+
+# Define these milterregex_* variables in one of these files:
+# /etc/rc.conf
+# /etc/rc.conf.local
+# /etc/rc.conf.d/milterregex
+#
+# DO NOT CHANGE THESE DEFAULT VALUES HERE
+#
+[ -z "$milterregex_enable" ] && milterregex_enable="NO" # Enable milter-regex
+#milterregex_program="${prefix}/libexec/milter-regex" # Location of milter-regex
+[ -z "$milterregex_flags" ] && milterregex_flags="" # Flags to milter-regex program
+
+. /etc/rc.subr
+
+name="milterregex"
+rcvar=`set_rcvar`
+command="${prefix}/libexec/milter-regex"
+pidfile="${spooldir}/milter-regex.pid"
+required_files="${prefix}/etc/milter-regex.conf"
+stop_postcmd="milterregex_poststop"
+
+milterregex_poststop() {
+ /bin/rm -f ${pidfile}
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/mail/milter-regex/files/patch-milter-regex.8 b/mail/milter-regex/files/patch-milter-regex.8
new file mode 100644
index 000000000000..f89426009556
--- /dev/null
+++ b/mail/milter-regex/files/patch-milter-regex.8
@@ -0,0 +1,25 @@
+*** milter-regex.8.orig Sat Mar 13 12:21:23 2004
+--- milter-regex.8 Wed Sep 6 16:15:59 2006
+***************
+*** 37,42 ****
+--- 37,43 ----
+ .Nm
+ .Op Fl d
+ .Op Fl c Ar config
++ .Op Fl r Ar pid-file
+ .Op Fl p Ar pipe
+ .Op Fl u Ar user
+ .Sh DESCRIPTION
+***************
+*** 54,60 ****
+--- 54,63 ----
+ output on stdout.
+ .It Fl c Ar config
+ Use the specified configuration file instead of the default,
+ /etc/milter-regex.conf.
++ .It Fl r Ar pid-file
++ Use the specified pid file to write to. Default is:
++ /var/spool/milter-regex/milter-regex.pid
+ .It Fl p Ar pipe
+ Use the specified pipe to interface
+ .Xr sendmail 8 .
diff --git a/mail/milter-regex/files/patch-milter-regex.c b/mail/milter-regex/files/patch-milter-regex.c
new file mode 100644
index 000000000000..f953d92c6bd0
--- /dev/null
+++ b/mail/milter-regex/files/patch-milter-regex.c
@@ -0,0 +1,85 @@
+*** milter-regex.c.orig Sun Mar 6 06:42:53 2005
+--- milter-regex.c Wed Sep 6 16:00:00 2006
+***************
+*** 86,93 ****
+ static void usage(const char *);
+ static void msg(int, struct context *, const char *, ...);
+
+ #define USER "_milter-regex"
+ #define OCONN "unix:/var/spool/milter-regex/sock"
+ #define RCODE_REJECT "554"
+ #define RCODE_TEMPFAIL "451"
+ #define XCODE_REJECT "5.7.1"
+--- 86,94 ----
+ static void usage(const char *);
+ static void msg(int, struct context *, const char *, ...);
+
+ #define USER "_milter-regex"
+ #define OCONN "unix:/var/spool/milter-regex/sock"
++ #define OPID "/var/spool/milter-regex/milter-regex.pid"
+ #define RCODE_REJECT "554"
+ #define RCODE_TEMPFAIL "451"
+ #define XCODE_REJECT "5.7.1"
+***************
+*** 556,565 ****
+--- 557,570 ----
+ {
+ int ch;
+ const char *oconn = OCONN;
++ const char *pid_file_name = OPID;
+ const char *user = USER;
+ sfsistat r = MI_FAILURE;
+ const char *ofile = NULL;
+
++ pid_t pid;
++ FILE *pid_fd = NULL;
++
+ tzset();
+ openlog("milter-regex", LOG_PID | LOG_NDELAY, LOG_DAEMON);
+
+***************
+*** 577,582 ****
+--- 582,590 ----
+ case 'u':
+ user = optarg;
+ break;
++ case 'r':
++ pid_file_name = optarg;
++ break;
+ default:
+ usage(argv[0]);
+ }
+***************
+*** 638,646 ****
+ fprintf(stderr, "daemon: %s\n", strerror(errno));
+ goto done;
+ }
+- umask(0177);
+
+ msg(LOG_INFO, NULL, "started: %s", rcsid);
+ r = smfi_main();
+ if (r != MI_SUCCESS)
+ msg(LOG_ERR, NULL, "smfi_main: terminating due to error");
+--- 646,667 ----
+ fprintf(stderr, "daemon: %s\n", strerror(errno));
+ goto done;
+ }
+
+ msg(LOG_INFO, NULL, "started: %s", rcsid);
++
++ umask(0006);
++
++ if((pid_fd = fopen(pid_file_name, "w")) == NULL) {
++ msg(LOG_ERR, NULL, "can't open file: %s", pid_file_name);
++ goto done;
++ } else {
++ pid = getpid();
++ fprintf(pid_fd, "%d", (int) pid);
++ fclose(pid_fd);
++ }
++
++ umask(0177);
++
+ r = smfi_main();
+ if (r != MI_SUCCESS)
+ msg(LOG_ERR, NULL, "smfi_main: terminating due to error");
diff --git a/mail/milter-regex/pkg-install b/mail/milter-regex/pkg-install
deleted file mode 100644
index 1d4ae61441d0..000000000000
--- a/mail/milter-regex/pkg-install
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-set -e
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-PREFIX=${PKG_PREFIX:-/usr/local}
-MAILUSER=mailnull
-SPOOLDIR=/var/spool/milter-regex
-
-do_notice()
-{
- echo
- echo "+---------------"
- echo "| milter-regex has been installed as $PREFIX/libexec/milter-regex."
- echo "| See milter-regex(8) for instructions on how to register the plugin."
- echo "|"
- echo "| To start the plugin automatically on startup, one can use:"
- echo "|"
- echo "| /etc/rc.conf.local"
- echo "| milter_regex=YES"
- echo "|"
- echo "| /etc/rc.local"
- echo "| if [ X\"\${milter_regex}\" == X\"YES\" -a \\"
- echo "| -x $PREFIX/libexec/milter-regex ]; then"
- echo "| echo -n ' milter-regex'"
- echo "| $PREFIX/libexec/milter-regex"
- echo "| fi"
- echo "|"
- echo "+---------------"
- echo
-}
-
-if [ $# -ne 2 ]; then
- echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
- exit 1
-fi
-
-case $2 in
- PRE-INSTALL)
- ;;
- POST-INSTALL)
- if [ ! -d $SPOOLDIR ]; then
- install -d -o $MAILUSER -g daemon -m 0700 $SPOOLDIR
- fi
- do_notice
- ;;
- *)
- echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/mail/milter-regex/pkg-message b/mail/milter-regex/pkg-message
new file mode 100644
index 000000000000..cfa1b4bb4b40
--- /dev/null
+++ b/mail/milter-regex/pkg-message
@@ -0,0 +1,11 @@
+===> INSTALL NOTES:
+
+ To run milter-regex daemon on startup, add milterregex_enable="YES"
+ in your /etc/rc.conf. You will need to create a config file:
+
+ /usr/local/etc/milter-regex.conf
+
+ The plugin needs to be registered in the sendmail(8) configuration.
+
+ See milter-regex(8) for details.
+
diff --git a/mail/milter-regex/pkg-plist b/mail/milter-regex/pkg-plist
new file mode 100644
index 000000000000..461a9cb985c0
--- /dev/null
+++ b/mail/milter-regex/pkg-plist
@@ -0,0 +1,3 @@
+@exec mkdir -m 700 -p /var/run/milter-regex
+@exec chown mailnull:daemon /var/run/milter-regex
+@dirrmtry /var/run/milter-regex