ports/103114: [patch] port mail/milter-regex rc.d support

Derek Marcotte derekm.nospam at rogers.com
Sun Sep 10 21:30:39 UTC 2006


>Number:         103114
>Category:       ports
>Synopsis:       [patch] port mail/milter-regex rc.d support
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 10 21:30:18 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Derek Marcotte
>Release:        FreeBSD 6.1-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD server.razorfever.net 6.1-RELEASE-p2 FreeBSD 6.1-RELEASE-p2 #1: Mon Jun 19 11:53:43 EDT 2006 derek at server.razorfever.net:/usr/obj/usr/src/sys/GENERIC-NOUHID i386


>Description:
	Add support for rc.d style startup scripts for mail/milter-regex port.
I was in touch with dhartmei at FreeBSD.org, who was listed as maintainer for
this port.  

He says:

"I can't commit to the ports tree, please send the patch to the ports
mailing list instead and ask someone with ports privileges to commit it.

While they're at it, they can also change the maintainer line so it
points to the list instead, please :)"

>How-To-Repeat:
>Fix:

--- milter-regex.patch begins here ---
diff -ruN milter-regex.old/Makefile milter-regex/Makefile
--- milter-regex.old/Makefile	Wed May 10 21:11:35 2006
+++ milter-regex/Makefile	Fri Sep  8 13:50:15 2006
@@ -12,7 +12,7 @@
 MASTER_SITES=	http://www.benzedrine.cx/
 DISTNAME=	milter-regex-${PORTVERSION}
 
-MAINTAINER=	dhartmei at FreeBSD.org
+MAINTAINER=	ports at freebsd.org
 COMMENT=	Milter plugin to sendmail for regular expression filtering
 
 WRKSRC=		${WRKDIR}/milter-regex
@@ -21,6 +21,11 @@
 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 @@
 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 @@
 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 -ruN milter-regex.old/files/milterregex.sh.in milter-regex/files/milterregex.sh.in
--- milter-regex.old/files/milterregex.sh.in	Wed Dec 31 19:00:00 1969
+++ milter-regex/files/milterregex.sh.in	Thu Sep  7 17:28:44 2006
@@ -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 -ruN milter-regex.old/files/patch-milter-regex.8 milter-regex/files/patch-milter-regex.8
--- milter-regex.old/files/patch-milter-regex.8	Wed Dec 31 19:00:00 1969
+++ milter-regex/files/patch-milter-regex.8	Wed Sep  6 16:22:26 2006
@@ -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 -ruN milter-regex.old/files/patch-milter-regex.c milter-regex/files/patch-milter-regex.c
--- milter-regex.old/files/patch-milter-regex.c	Wed Dec 31 19:00:00 1969
+++ milter-regex/files/patch-milter-regex.c	Wed Sep  6 16:02:25 2006
@@ -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 -ruN milter-regex.old/pkg-install milter-regex/pkg-install
--- milter-regex.old/pkg-install	Thu Apr  8 04:05:49 2004
+++ milter-regex/pkg-install	Wed Dec 31 19:00:00 1969
@@ -1,55 +0,0 @@
-#!/bin/sh
-#
-# 	$FreeBSD: ports/mail/milter-regex/pkg-install,v 1.2 2004/04/07 15:44:50 dhartmei Exp $
-#
-
-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 -ruN milter-regex.old/pkg-message milter-regex/pkg-message
--- milter-regex.old/pkg-message	Wed Dec 31 19:00:00 1969
+++ milter-regex/pkg-message	Thu Sep  7 18:38:34 2006
@@ -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 -ruN milter-regex.old/pkg-plist milter-regex/pkg-plist
--- milter-regex.old/pkg-plist	Wed Dec 31 19:00:00 1969
+++ milter-regex/pkg-plist	Thu Sep  7 17:35:16 2006
@@ -0,0 +1,3 @@
+ at exec mkdir -m 700 -p /var/run/milter-regex
+ at exec chown mailnull:daemon /var/run/milter-regex
+ at unexec rmdir /var/run/milter-regex
--- milter-regex.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list