[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More zmailer/mailman integration



Gerard Hickey wrote:

> I have just completed reworking the code that Jeff Warnica posted for
> integrating mailman and zmailer. This code basically extends his
> original code to better handle virtual domains.
> 
> The basic idea is that all lists get created with the domain name
> prefixed to the listname. For example, one of my virtual domains is
> moac.org, so I have created moac-climbing, moac-kayak, moac-downhill,
> and moac-xcountry lists. Users are able to mail to both
> moac-climbing@moac.org or climbing@moac.org. Even addresses like
> climbing-admin@moac.org are handled correctly.
> 
> See the comments about configuring mailman.
> 
> The following code is placed in the alias.cf file just after the zmailer
> lists are processed. In my alias.cf it is around line 530.

here goes the _same_ code in a real patch way. Review it :-)

--
Software is like sex, it's better when it's bug free.

diff -Nuar zmailer-CVS-2003-11-29/proto/cf/aliases.cf zmailer-new/proto/cf/aliases.cf
--- zmailer-CVS-2003-11-29/proto/cf/aliases.cf	2004-01-28 14:35:05.000000000 +0100
+++ zmailer-new/proto/cf/aliases.cf	2004-02-03 23:03:16.000000000 +0100
@@ -543,60 +543,89 @@
 # Something like: MAILMAN_ROOT=/var/mailman
 
 if [ -n "$MAILMAN_ROOT" ] ; then
+	local listname root_domain_name mailman_todo
 
-	a="$MAILMAN_ROOT/lists/$lcuser/"
-	if [ -d "$a" ] ; then
-		nattr=$(newattribute $attr privilege "0")
-		$(zapDSNnotify $nattr delivered "$sender" "$lcuser$domain")
-		a=(((local pipe.$lcuser "|$MAILMAN_ROOT/mail/mailman post $lcuser" $nattr)))
-		postzapDSNnotify a +
-		return $a
-	fi
+	# Which domain is this message intended for?
+
+	tsift "$host" in
+
+	(.*)@.*\.([^\.]*)\.([^\.]*)
+		root_domain_name="\2"
+		;;
+	(.*)@([^\.]*)\.([^\.]*)
+		root_domain_name="\2"
+		;;
+	tfist
+
+	# Check to see if we have a list pseudo mail address
+	#
+	# Some of these may not be valid. Original list from Jeff Warnica.
+	# The -admin, -owner and -request updated for mailman 2.0.5.
+
+	listname=$lcuser
+	mailman_todo='post'
 
 	ssift "$lcuser" in
 
 	(.+)-owner
-		listbase="\1"
-		mailman_todo="owner"
+		listname="\1"
+		mailman_todo="mailowner"
 		;;
 	(.+)-admin
-		listbase="\1"
-		mailman_todo="admin"
+		listname="\1"
+		mailman_todo="mailowner"
 		;;
 	(.+)-bounces
-		listbase="\1"
+		listname="\1"
 		mailman_todo="bounces"
 		;;
 	(.+)-confirm
-		listbase="\1"
+		listname="\1"
 		mailman_todo="confirm"
 		;;
 	(.+)-join
-		listbase="\1"
+		listname="\1"
 		mailman_todo="join"
 		;;
 	(.+)-leave
-		listbase="\1"
+		listname="\1"
 		mailman_todo="leave"
 		;;
 	(.+)-request
-		listbase="\1"
-		mailman_todo="request"
+		listname="\1"
+		mailman_todo="mailcmd"
 		;;
 	(.+)-subscribe
-		listbase="\1"
+		listname="\1"
 		mailman_todo="subscribe"
 		;;
 	(.+)-unsubscribe
-		listbase="\1"
+		listname="\1"
 		mailman_todo="unsubscribe"
 		;;
 	tfiss
 
-	if [ -n "$listbase" ] ; then 
+	# General process here is to check if the receipent is a list
+	# with the domain name prepended to the receipent name. If so,
+	# the $listname variable is changed accordingly.
+	#
+	# Example: Mailman list is officially moac-climbing. Mail comes in as
+	# climbing@moac.org. The variable $root_domain_name is prepended and
+	# moac-climbing is found as a list.
+	#
+	# Note: Mailman lists need to be configured to allow the short name
+	# to be used. Under each list the "alias names" in privacy options
+	# needs to set. In the above example, I use 'climbing@' for the
+	# regexp.
+	#
+	if [ -d "$MAILMAN_ROOT/lists/$root_domain_name-$listname" ] ; then
+		listname="$root_domain_name-$listname"
+	fi
+
+	if [ -d "$MAILMAN_ROOT/lists/$listname" ] ; then
 		nattr=$(newattribute $attr privilege "0")
 		$(zapDSNnotify $nattr delivered "$sender" "$lcuser$domain")
-		a=(((local pipe.$lcuser "|$MAILMAN_ROOT/mail/mailman $mailman_todo $listbase" $nattr)))
+		a=(((local pipe.$listname "|$MAILMAN_ROOT/mail/wrapper $mailman_todo $listname" $nattr)))
 		postzapDSNnotify a +
 		return $a
 	fi