Hi,

A new version of the script more upstream compliant
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;

# Bastien ROUCARIES bastien.roucaries+deb...@gmail.com
# inspired by postfix to mailman

my $USE_SUBDOMAIN_SCHEME = '1';
my $DEFAULT_POSTERMASTER = 'listmaster';
# not used if $USE_SUBDOMAIN_SCHEME = 1;
my $DEFAULT_DOMAIN = 'exemple.com';

# Install this file as /var/lib/sympa/bin/postfix-to-sympa.pl
#
# To configure a virtual domain to connect to sympa, edit Postfix thusly:
#
# /etc/postfix/main.cf:
#    relay_domains = ... lists.example.com
#    transport_maps = hash:/etc/postfix/transport
#    sympa_destination_recipient_limit = 1
#
# /etc/postfix/master.cf
#    sympa unix  -       n       n       -       -       pipe
#      flags=FR user=sympa 
#      argv=/var/lib/sympa/bin/postfix-to-mailman.pl ${nexthop} ${mailbox}
#
# /etc/postfix/transport:
#   lists.example.com   sympa:
#
# Replace lists.example.com above with the name of the domain to be
# connected to sympa. Note that _all_ mail to that domain will go to
# sympa, so you don't want to put the name of your main domain
# here. Typically a virtual domain lists.domain.com is used for
# sympa, and domain.com for regular email.
# 
# BEWARE BEWARE 
#
# This script send listmaster message to postmas...@exemple.com
# where exemple.com is the subdomain of lists.exemple.com
# if it is not the case change $USE_SUBDOMAIN_SCHEME to false
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#  
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#  
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#  
#

# command line usage error 
my $EX_USAGE = 64;
# addressee unknown
my $EX_NOUSER  = 67; 
# internal software error
my $EX_SOFTWARE = 70; 
# temporary failure
my $EX_TEMPFAIL = 75;  

# go to non interactive ;
POSIX::nice(5);

# see if writing to stderr is safe (PANAROIAC)
select(STDERR) || exit($EX_SOFTWARE);

# arg are user domain [extension]
if(!($#ARGV == 1 ||  $#ARGV == 2)) {
    $! = $EX_USAGE;
    die('Did you forget to set sympa_destination_recipient_limit=1 in main.cf?');
}

my $domain = $ARGV[0];
my $user = $ARGV[1];

my $LIST_OWNER = '';
if($USE_SUBDOMAIN_SCHEME == 1) {
    $domain =~ /(lists)\.(.*)/;
    my $subdomain = $2;
    if(!defined($subdomain)) {
	$! = $EX_USAGE;
        die('domain does not seems to be valid!');	
    }
    $LIST_OWNER = $DEFAULT_POSTERMASTER.'@'.$subdomain;
} else {
    $LIST_OWNER = $DEFAULT_POSTERMASTER;
}

# Redirect required addresses required by rfc root|postmaster|abuse|mailer-daemon
# of by sympa: sympa-request|sympa-owner
# to list owner 
$user =~ /(root|postmaster|abuse|mailer-daemon|sympa-request|sympa-owner|listowner)/;
if(defined($1)) {
    $! = 0;
    exec("/usr/sbin/sendmail $LIST_OWNER");
    exit(1);
}

# Redirect ARF as sympa documentation
if($user eq 'abuse-feedback-report') {
    exec('/usr/lib/sympa/lib/sympa/bouncequeue '.'sympa@'."$domain");
    exit(1);
}

# Redirect bounce if requiered
if($user eq 'bounce') {
    exec('/usr/lib/sympa/lib/sympa/bouncequeue '.'sympa@'."$domain");
    exit(1);
}


# search if address is special
$user =~ /(.*)-(request|editor|subscribe|unsubsribe)/;
if(defined($2)) {
    exec('/usr/lib/sympa/lib/sympa/queue '."$user".'@'."$domain");
    exit(1);
}

$user =~ /(.*)-(owner)/;
if(defined($2)) {
    exec('/usr/lib/sympa/lib/sympa/bouncequeue '."$user".'@'."$domain");
    exit(1);
}

exec('/usr/lib/sympa/lib/sympa/queue '."$user".'@'."$domain");
exit(1);





Reply via email to