Ver código fonte

first cut for Mailman package (partly contributed, partly rewritten by me, partly still broken IMHO)

Ralf S. Engelschall 20 anos atrás
pai
commit
a29a2984ee

+ 52 - 0
mailman/mailman-apache.conf

@@ -0,0 +1,52 @@
+##
+##  mailman-apache.conf -- Apache Configuration for Mailman
+##
+
+<VirtualHost host.example.com>
+    #   server information
+    ServerName        host.example.com
+    ServerAdmin       hostmaster@host.example.com
+    ServerSignature   on
+
+    #   document area
+    DocumentRoot @l_prefix@/libexec/mailman/htdocs/
+    <Directory "@l_prefix@/libexec/mailman/htdocs">
+        Options       FollowSymLinks
+        AllowOverride None
+        Order         allow,deny
+        Allow         from all
+    </Directory>
+
+    #   pipermail area
+    Alias /mailman/pipermail/ @l_prefix@/var/mailman/archives/public/
+    <Directory "@l_prefix@/var/mailman/archives/public">
+        Options       FollowSymLinks
+        AllowOverride None
+        Order         allow,deny
+        Allow         from all
+    </Directory>
+
+    #   icon area
+    Alias /mailman/icons/ @l_prefix@/libexec/mailman/icons/
+    <Directory "@l_prefix@/libexec/mailman/icons">
+        Options       FollowSymLinks
+        AllowOverride None
+        Order         allow,deny
+        Allow         from all
+    </Directory>
+
+    #   executable area
+    ScriptAlias /mailman/ @l_prefix@/libexec/mailman/cgi-bin/
+    <Directory "@l_prefix@/libexec/mailman/cgi-bin">
+        Options       FollowSymLinks ExecCGI
+        AllowOverride None
+        Order         allow,deny
+        Allow         from all
+    </Directory>
+
+    #   logging
+    CustomLog         @l_prefix@/var/mailman/logs/http-access.log common
+    ErrorLog          @l_prefix@/var/mailman/logs/http-error.log
+    LogLevel          warn
+</VirtualHost>
+

+ 16 - 0
mailman/mailman-sendmail.m4

@@ -0,0 +1,16 @@
+dnl
+dnl mailman.m4: Mailman specific local mailer
+dnl
+
+MAILER_DEFINITIONS
+
+##  Special flags! See:
+##  http://www.sendmail.org/~ca/email/doc8.10/op-sh-5.html#sh-5.4 Note
+##  especially the absence of the "m" and "n" flags. THIS IS IMPORTANT:
+##  mailman handler assumes this behavior to avoid having to know too
+##  much about address parsing and other RFC-2822 mail details.
+
+Mmailman,	P=@l_prefix@/libexec/mailman/mail/mailman.pl, F=rDFMhlqSu, U=@l_nusr@:@l_ngrp@,
+		S=EnvFromL, R=EnvToL/HdrToL,
+		A=mailman $h $u
+

+ 235 - 0
mailman/mailman-sendmail.pl

@@ -0,0 +1,235 @@
+#!@l_prefix@/bin/perl
+##
+## Sendmail mailer for Mailman
+##
+## Simulates these aliases:
+##
+##testlist:              "|/home/mailman/mail/mailman post testlist"
+##testlist-admin:        "|/home/mailman/mail/mailman admin testlist"
+##testlist-bounces:      "|/home/mailman/mail/mailman bounces testlist"
+##testlist-confirm:      "|/home/mailman/mail/mailman confirm testlist"
+##testlist-join:         "|/home/mailman/mail/mailman join testlist"
+##testlist-leave:        "|/home/mailman/mail/mailman leave testlist"
+##testlist-owner:        "|/home/mailman/mail/mailman owner testlist"
+##testlist-request:      "|/home/mailman/mail/mailman request testlist"
+##testlist-subscribe:    "|/home/mailman/mail/mailman subscribe testlist"
+##testlist-unsubscribe:  "|/home/mailman/mail/mailman unsubscribe testlist"
+##owner-testlist:        testlist-owner
+
+## Some assembly required.
+$MMWRAPPER = "@l_prefix@/libexec/mailman/mail/mailman";
+$MMLISTDIR = "@l_prefix@/var/mailman/lists";
+$SENDMAIL = "@l_prefix@/sbin/sendmail -oem -oi";
+$VERSION = '$Id: mailman-sendmail.pl,v 1.1 2005/04/30 17:18:54 rse Exp $';
+
+## Comment this if you offer local user addresses.
+$NOUSERS = "\nPersonal e-mail addresses are not offered by this server.";
+
+# uncomment for debugging....
+#$DEBUG = 1;
+
+use FileHandle;
+use Sys::Hostname;
+use Socket;
+
+($VERS_STR = $VERSION) =~ s/^\$\S+\s+(\S+),v\s+(\S+\s+\S+\s+\S+).*/\1 \2/;
+
+$BOUNDARY = sprintf("%08x-%d", time, time % $$);
+
+## Informative, non-standard rejection letter
+sub mail_error {
+	my ($in, $to, $list, $server, $reason) = @_;
+	my $sendmail;
+
+	if ($server && $server ne "") {
+		$servname = $server;
+	} else {
+		$servname = "This server";
+		$server = &get_ip_addr;
+	}
+
+	#$sendmail = new FileHandle ">/tmp/mm-$$";
+	$sendmail = new FileHandle "|$SENDMAIL $to";
+	if (!defined($sendmail)) {
+		print STDERR "$0: cannot exec \"$SENDMAIL\"\n";
+		exit (-1);
+	}
+
+	$sendmail->print ("From: MAILER-DAEMON\@$server
+To: $to
+Subject: Returned mail: List unknown
+Mime-Version: 1.0
+Content-type: multipart/mixed; boundary=\"$BOUNDARY\"
+Content-Disposition: inline
+
+--$BOUNDARY
+Content-Type: text/plain; charset=us-ascii
+Content-Description: Error processing your mail
+Content-Disposition: inline
+
+Your mail for $list could not be sent:
+	$reason
+
+For a list of publicly-advertised mailing lists hosted on this server,
+visit this URL:
+	http://$server/
+
+If this does not resolve your problem, you may write to:
+	postmaster\@$server
+or
+	mailman-owner\@$server
+
+
+$servname delivers e-mail to registered mailing lists
+and to the administrative addresses defined and required by IETF
+Request for Comments (RFC) 2142 [1].
+$NOUSERS
+
+The Internet Engineering Task Force [2] (IETF) oversees the development
+of open standards for the Internet community, including the protocols
+and formats employed by Internet mail systems.
+
+For your convenience, your original mail is attached.
+
+
+[1] Crocker, D. \"Mailbox Names for Common Services, Roles and
+    Functions\".  http://www.ietf.org/rfc/rfc2142.txt
+
+[2] http://www.ietf.org/
+
+--$BOUNDARY
+Content-Type: message/rfc822
+Content-Description: Your undelivered mail
+Content-Disposition: attachment
+
+");
+
+	while ($_ = <$in>) {
+		$sendmail->print ($_);
+	}
+
+	$sendmail->print ("\n");
+	$sendmail->print ("--$BOUNDARY--\n");
+
+	close($sendmail);
+}
+
+## Get my IP address, in case my sendmail doesn't tell me my name.
+sub get_ip_addr {
+	my $host = hostname;
+	my $ip = gethostbyname($host);
+	return inet_ntoa($ip);
+}
+
+## Split an address into its base list name and the appropriate command
+## for the relevant function.
+sub split_addr {
+	my ($addr) = @_;
+	my ($list, $cmd);
+	my @validfields = qw(admin bounces confirm join leave owner request
+				subscribe unsubscribe);
+
+	if ($addr =~ /(.*)-(.*)\+.*$/) {
+		$list = $1;
+		$cmd = "$2";
+	} else {
+		$addr =~ /(.*)-(.*)$/;
+		$list = $1;
+		$cmd = $2;
+	}
+	if (grep /^$cmd$/, @validfields) {
+		if ($list eq "owner") {
+			$list = $cmd;
+			$cmd = "owner";
+		}
+	} else {
+		$list = $addr;
+		$cmd = "post";
+	}
+
+	return ($list, $cmd);
+}
+
+## The time, formatted as for an mbox's "From_" line.
+sub mboxdate {
+	my ($time) = @_;
+	my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
+	my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+	my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+		localtime($time);
+
+	## Two-digit year handling complies with RFC 2822 (section 4.3),
+	## with the addition that three-digit years are accommodated.
+	if ($year < 50) {
+		$year += 2000;
+	} elsif ($year < 1900) {
+		$year += 1900;
+	}
+
+	return sprintf ("%s %s %2d %02d:%02d:%02d %d",
+		$days[$wday], $months[$mon], $mday,
+		$hour, $min, $sec, $year);
+}
+
+BEGIN: {
+	$sender = undef;
+	$server = undef;
+	@to = ();
+	while ($#ARGV >= 0) {
+		if ($ARGV[0] eq "-r") {
+			$sender = $ARGV[1];
+			shift @ARGV;
+		} elsif (!defined($server)) {
+			$server = $ARGV[0];
+		} else {
+			push(@to, $ARGV[0]);
+		}
+		shift @ARGV;
+	}
+
+	if ($DEBUG) {
+		$to = join(',', @to);
+		print STDERR "to: $to, @to\n";
+		print STDERR "sender: $sender\n";
+		print STDERR "server: $server\n";
+		exit(-1);
+	}
+
+ADDR:	for $addr (@to) {
+		$prev = undef;
+		$list = $addr;
+
+		$cmd= "post";
+		if (! -f "$MMLISTDIR/$list/config.pck") {
+			($list, $cmd) = &split_addr($list);
+			if (! -f "$MMLISTDIR/$list/config.pck") {
+				$was_to = $addr;
+				$was_to .= "\@$server" if ("$server" ne "");
+				mail_error(\*STDIN, $sender, $was_to, $server,
+					"no list named \"$list\" is known by $server");
+				next ADDR;
+			}
+		}
+		$wrapper = new FileHandle "|$MMWRAPPER $cmd $list";
+		if (!defined($wrapper)) {
+			## Defer?
+			print STDERR "$0: cannot exec ",
+				"\"$MMWRAPPER $cmd $list\": deferring\n";
+			exit (-1);
+		}
+
+		# Don't need these without the "n" flag on the mailer def....
+		#$date = &mboxdate(time);
+		#$wrapper->print ("From $sender  $date\n");
+
+		# ...because we use these instead.
+		$from_ = <STDIN>;
+		$wrapper->print ($from_);
+
+		$wrapper->print ("X-Mailman-Handler: $VERSION\n");
+		while (<STDIN>) {
+			$wrapper->print ($_);
+		}
+		close($wrapper);
+	}
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 1592 - 0
mailman/mailman.patch


+ 220 - 0
mailman/mailman.spec

@@ -0,0 +1,220 @@
+##
+##  mailman.spec -- OpenPKG RPM Package Specification
+##  Copyright (c) 2000-2005 OpenPKG Foundation e.V. <http://openpkg.net/>
+##  Copyright (c) 2000-2005 Ralf S. Engelschall <http://engelschall.com/>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   package information
+Name:         mailman
+Summary:      Mailing List Management System
+URL:          http://www.list.org/
+Vendor:       John Viega et al.
+Packager:     OpenPKG
+Distribution: OpenPKG
+Class:        JUNK
+Group:        Network
+License:      GPL
+Version:      2.1.5
+Release:      20050430
+
+#   list of sources
+Source0:      ftp://ftp.gnu.org/gnu/mailman/mailman-%{version}.tgz
+Source1:      manpages.tar.gz
+Source3:      mailman-sendmail.pl
+Source2:      mailman-sendmail.m4
+Source4:      mailman-apache.conf
+Source5:      rc.mailman
+Patch0:       mailman.patch
+
+#   build information
+Prefix:       %{l_prefix}
+BuildRoot:    %{l_buildroot}
+BuildPreReq:  OpenPKG, openpkg >= 20040701, python
+PreReq:       OpenPKG, openpkg >= 20040701, python, MTA
+AutoReq:      no
+AutoReqProv:  no
+
+%description
+    Mailman is software to help manage email discussion lists, much
+    like Majordomo and Smartmail. Unlike most similar products, Mailman
+    gives each mailing list a webpage, and allows users to subscribe,
+    unsubscribe, etc. over the Web. Even the list manager can administer
+    his or her list entirely from the Web. Mailman also integrates most
+    things people want to do with mailing lists, including archiving,
+    mail/news gateways, and so on.
+
+%track
+    prog mailman = {
+        version   = %{version}
+        url       = ftp://ftp.gnu.org/gnu/mailman/
+        regex     = mailman-(__VER__)\.tgz
+    }
+
+%prep
+    %setup -q
+    %setup -q -D -T -a 1
+    %patch -p0
+
+%build
+    #   configure package
+    CC="%{l_cc}" \
+    CFLAGS="%{l_cflags -O}" \
+    CPPFLAGS="%{l_cppflags}" \
+    LDFLAGS="%{l_ldflags}" \
+    ./configure \
+        --prefix=%{l_prefix}/libexec/mailman \
+        --exec-prefix=%{l_prefix}/libexec/mailman \
+        --sysconfdir=%{l_prefix}/etc/mailman \
+        --with-var-prefix=%{l_prefix}/var/mailman \
+        --with-username=%{l_nusr} \
+        --with-groupname=%{l_mgrp} \
+        --with-cgi-gid=%{l_ngrp} \
+        --with-mail-gid=%{l_mgrp} \
+        --with-cgi-ext="" \
+        --with-urlhost="localhost" \
+        --with-mailhost="localhost" \
+        --without-permcheck \
+        --enable-static
+
+    #   build package
+    %{l_make} %{l_mflags}
+
+%install
+    #   install package
+    rm -rf $RPM_BUILD_ROOT
+    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT DIRSETGID=true
+
+    #   create additional directories
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/mailman \
+        $RPM_BUILD_ROOT%{l_prefix}/man/man8
+
+    #   install Sendmail mailer command
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE mailman-sendmail.pl} \
+        $RPM_BUILD_ROOT%{l_prefix}/libexec/mailman/mail/
+
+    #   install icons
+    %{l_shtool} install -c -m 644 \
+        misc/PythonPowered.png misc/mailman.jpg \
+        misc/mm-icon.png misc/mailman-large.jpg \
+        $RPM_BUILD_ROOT%{l_prefix}/libexec/mailman/icons/
+
+    #   install Apache and Sendmail configurations
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE mailman-sendmail.m4} %{SOURCE mailman-apache.conf} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/mailman/
+
+    #   install manual pages
+    %{l_shtool} install -c -m 644 \
+        man8/*.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/
+
+    #   post-adjust default configuration
+    mv $RPM_BUILD_ROOT%{l_prefix}/libexec/mailman/Mailman/mm_cfg.py \
+       $RPM_BUILD_ROOT%{l_prefix}/etc/mailman/mailman.cfg
+    ln -s %{l_prefix}/etc/mailman/mailman.cfg \
+       $RPM_BUILD_ROOT%{l_prefix}/libexec/mailman/Mailman/mm_cfg.py
+    ( echo ""
+      echo "DEFAULT_EMAIL_HOST       = 'host.example.com'"
+      echo "DEFAULT_URL_HOST         = 'host.example.com'"
+      echo "IMAGE_LOGOS              = '/mailman/icons/'"
+      echo "PUBLIC_ARCHIVE_URL       = '/mailman/pipermail/%%(listname)s'"
+      echo "MAILMAN_USER             = '%{l_nusr}'"
+      echo "MAILMAN_GROUP            = '%{l_mgrp}'"
+      echo "DEFAULT_SERVER_LANGUAGE  = 'en'"
+      echo ""
+      echo "#   For available options and their descriptions see:"
+      echo "#   %{l_prefix}/libexec/mailman/Mailman/Defaults.py"
+      echo ""
+    ) >>$RPM_BUILD_ROOT%{l_prefix}/etc/mailman/mailman.cfg
+
+    #   install run-command script
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE rc.mailman} ${RPM_BUILD_ROOT}%{l_prefix}/etc/rc.d/
+
+    #   determine installation files
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+        %{l_files_std} \
+        '%dir %attr(2700,%{l_nusr},%{l_mgrp}) %{l_prefix}/libexec/mailman/mail/mailman-sendmail.pl' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/logs' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/spam' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/qfiles' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/locks' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/lists' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/archives' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/archives/*' \
+        '%dir %attr(2775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/mailman/data' \
+        '%config %attr(0640,%{l_nusr},%{l_mgrp}) %{l_prefix}/etc/mailman/mailman.cfg' \
+        '%config %{l_prefix}/etc/mailman/*'
+
+%files -f files
+
+%clean
+    rm -rf $RPM_BUILD_ROOT
+
+%post
+    #   add hook to MTA configuration
+    if [ $1 -eq  1 ]; then
+        aliases_file=`$RPM_INSTALL_PREFIX/etc/rc --query MTA_aliases_file`
+        update_command=`$RPM_INSTALL_PREFIX/etc/rc --query MTA_aliases_update`
+        if [ ".$aliases_file" != . ]; then
+            ( echo "mailman:       postmaster"
+              echo "mailman-owner: postmaster"
+            ) |\
+            $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
+                -a -i "$RPM_INSTALL_PREFIX:mailman" $aliases_file
+        fi
+        if [ ".$update_command" != . ]; then
+            eval $update_command
+        fi
+    fi
+
+    #   after upgrade, restart service
+    [ $1 -eq 2 ] || exit 0
+    $RPM_INSTALL_PREFIX/libexec/mailman/bin/update
+    eval `%{l_rc} mailman status 2>/dev/null`
+    [ ".$mailman_active" = .yes ] && %{l_rc} mailman restart
+    exit 0
+
+%preun
+    #   before erase, stop service (and remove files)
+    [ $1 -eq 0 ] || exit 0
+    rm -f $RPM_INSTALL_PREFIX/libexec/mailman/bin/paths.pyc     >/dev/null 2>&1 || true
+    rm -f $RPM_INSTALL_PREFIX/libexec/mailman/cron/paths.pyc    >/dev/null 2>&1 || true
+    rm -f $RPM_INSTALL_PREFIX/libexec/mailman/scripts/paths.pyc >/dev/null 2>&1 || true
+    %{l_rc} mailman stop 2>/dev/null
+    exit 0
+
+%postun
+    #   remove hook from MTA configuration
+    [ $1 -eq 0 ] || exit 0
+    aliases_file=`$RPM_INSTALL_PREFIX/etc/rc --query MTA_aliases_file`
+    update_command=`$RPM_INSTALL_PREFIX/etc/rc --query MTA_aliases_update`
+    if [ ".$aliases_file" != . ]; then
+        $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
+            -r -i "$RPM_INSTALL_PREFIX:mailman" $aliases_file
+    fi
+    if [ ".$update_command" != . ]; then
+        eval $update_command
+    fi
+

BIN
mailman/manpages.tar.gz


+ 53 - 0
mailman/rc.mailman

@@ -0,0 +1,53 @@
+#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
+##
+##  rc.mailman -- Run-Commands
+##
+
+%config
+    mailman_enable="$openpkg_rc_def"
+
+%common
+    mailman_ctl="@l_prefix@/libexec/mailman/bin/mailmanctl"
+
+%status -u @l_susr@ -o
+    mailman_usable="unknown"
+    mailman_active="no"
+    rcService mailman enable yes && \
+        @l_prefix@/bin/python ${mailman_ctl} -q FIXME && \
+        mailman_active="yes"
+    echo "mailman_enable=\"$mailman_enable\""
+    echo "mailman_usable=\"$mailman_usable\""
+    echo "mailman_active=\"$mailman_active\""
+
+%start -u @l_susr@
+    rcService mailman enable yes || exit 0
+    rcService mailman active yes && exit 0
+    @l_prefix@/bin/python ${mailman_ctl} -s -q start
+
+%stop -u @l_susr@
+    rcService mailman enable yes || exit 0
+    rcService mailman active no  && exit 0
+    @l_prefix@/bin/python ${mailman_ctl} -q stop
+    sleep 2
+
+%restart -u @l_susr@
+    rcService mailman enable yes || exit 0
+    rcService mailman active no  && exit 0
+    @l_prefix@/bin/python ${mailman_ctl} -q restart
+    sleep 2
+
+%quarterly -u @l_susr@
+    rcService mailman enable yes || exit 0
+    @l_prefix@/bin/python -S @l_prefix@/libexec/mailman/cron/gate_news
+
+%daily -u @l_susr@
+    rcService mailman enable yes || exit 0
+    @l_prefix@/bin/python -S @l_prefix@/libexec/mailman/cron/checkdbs
+    @l_prefix@/bin/python -S @l_prefix@/libexec/mailman/cron/disabled
+    @l_prefix@/bin/python -S @l_prefix@/libexec/mailman/cron/senddigests
+    @l_prefix@/bin/python -S @l_prefix@/libexec/mailman/cron/nighty_gzip
+
+%monthly -u @l_susr@
+    rcService mailman enable yes || exit 0
+    @l_prefix@/bin/python -S @l_prefix@/libexec/mailman/cron/mailpasswds
+