initial commit of file from CVS for smeserver-mailman on Sat Sep 7 19:55:48 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 19:55:48 +10:00
parent b4cf41e403
commit aeebf1b0da
64 changed files with 2941 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
# Copyright (C) 2001,2002 by the Free Software Foundation, Inc.
#
# 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.
"""Creation/deletion hooks for the SME and Q-Mail
"""
import os
import time
import errno
import pwd
from stat import *
from Mailman import mm_cfg
from Mailman import Utils
from Mailman import LockFile
from Mailman.i18n import _
from Mailman.MTA.Utils import makealiases
from Mailman.Logging.Syslog import syslog
def create(mlist, cgi=0, nolock=0):
listname = mlist.internal_name()
msg = 'command failed: %s (status: %s, %s)'
acmd = '/usr/lib/mailman/bin/smelist addlist ' + listname
status = (os.system(acmd) >> 8) & 0xff
if status:
errstr = os.strerror(status)
syslog('error', msg, acmd, status, errstr)
raise RuntimeError, msg % (acmd, status, errstr)
def remove(mlist, cgi=0):
listname = mlist.internal_name()
msg = 'command failed: %s (status: %s, %s)'
acmd = '/usr/lib/mailman/bin/smelist rmlist ' + listname
status = (os.system(acmd) >> 8) & 0xff
if status:
errstr = os.strerror(status)
syslog('error', msg, acmd, status, errstr)
raise RuntimeError, msg % (acmd, status, errstr)

View File

@@ -0,0 +1,33 @@
#!/bin/bash
[ -d /var/lib/mailman/lists/mailman ] && exit 0
echo " "
DOMAIN=`/sbin/e-smith/config get DomainName`
if [ ! -d /var/lib/mailman/lists/mailman ]; then
MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
LENGTH="18"
while [ "${n:=1}" -le "$LENGTH" ]; do
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
let n+=1
done
/sbin/e-smith/config setprop mailman SitePass $PASS
/usr/lib/mailman/bin/mmsitepass "$PASS" > /dev/null 2>&1 || :
/usr/lib/mailman/bin/newlist -q mailman admin@${DOMAIN} dummypass > /dev/null 2>&1 || :
cat > /tmp/hide << EOF
advertised = 0
archive_private = 1
description = 'Mailman Mailing List'
EOF
/usr/lib/mailman/bin/config_list -i /tmp/hide mailman > /dev/null 2>&1 || :
rm -f /tmp/hide
echo -n "* "
/usr/lib/mailman/bin/change_pw -l mailman 2> /dev/null || echo "New mailman password: *UNCHANGED*"; :
"/usr/lib/mailman/bin/add_members -r - -a n mailman << EOF
admin@${DOMAIN}
EOF" > /dev/null 2>&1 || :
else
/etc/e-smith/events/actions/email-assign || :
fi
/usr/lib/mailman/bin/check_perms -f

View File

@@ -0,0 +1,31 @@
#!/usr/bin/perl -wT
package esmith;
use strict;
use esmith::util;
my $usage = "$0 is not meant to be called from the command line.
";
my ($event, $list) = @ARGV;
die $usage unless $event;
die $usage unless $list;
BEGIN
{
$ENV {'PATH'} = '';
$ENV {'SHELL'} = '/bin/bash';
delete $ENV {'ENV'};
}
die "Unknown event $event"
unless ($event =~ /^(addlist|rmlist|update)$/);
$event = $1;
die "Invalid list name $list"
unless ($list =~ /^([\w\-\._]+)$/);
$list = $1;
esmith::util::setRealToEffective ();
system ("/sbin/e-smith/signal-event", "mailman-$event", "$list") == 0
or die ("Error occurred while modifying mailman list $list.\n");

View File

@@ -0,0 +1,2 @@
[Install]
WantedBy=sme-server.target

View File

@@ -0,0 +1,128 @@
#----------------------------------------------------------------------)
# $Id: mailman.pm,v 1.1 2005/02/16 02:34:26 msoulier Exp $
#----------------------------------------------------------------------
# copyright (C) 2002 Mitel Networks Corporation
#----------------------------------------------------------------------
package esmith::FormMagick::Panel::mailman;
use strict;
use esmith::ConfigDB;
use esmith::FormMagick;
use constant SIGEVENT => '/sbin/e-smith/signal-event';
our @ISA = qw(esmith::FormMagick);
our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/;
=head1 NAME
esmith::FormMagick::Panel::mailman - panel backend
=head1 SYNOPSIS
use esmith::FormMagick::Panel::mailman;
my $panel = esmith::FormMagick::Panel::mailman->new();
$panel->display();
=head1 DESCRIPTION
This class is the esmith::FormMagick subclass for the Mailman panel in the
server manager. It is the backend responsible for handling form submissions,
and helping to output the form itself.
=head2 new
Class constructor.
=cut
sub new
{
my $class = ref($_[0]) || $_[0];
my $self = $class->SUPER::new();
$self->{calling_package} = __PACKAGE__;
my $db = esmith::ConfigDB->open
or die "Could not open configuration database";
$self->{db} = $db;
$self->debug(0);
return $self;
}
=head2 get_status
This method returns the current mailman status.
=cut
sub get_status
{
my $self = shift;
my $status = $self->{db}->get_prop('mailman', 'status') || 'disabled';
return $status;
}
=head2 get_access
This method returns the current mailman access.
=cut
sub get_access
{
my $self = shift;
my $access = $self->{db}->get_prop('mailman', 'access') || 'public';
return $access;
}
=head2 get_archivesaccess
This method returns the current mailman archivesaccess.
=cut
sub get_archivesaccess
{
my $self = shift;
my $archivesaccess = $self->{db}->get_prop('mailman', 'archivesaccess') || 'private';
return $archivesaccess;
}
=head2 get_adminaccess
This method returns the current mailman adminaccess.
=cut
sub get_adminaccess
{
my $self = shift;
my $adminaccess = $self->{db}->get_prop('mailman', 'adminaccess') || 'private';
return $adminaccess;
}
=head2 change_settings
This method handles the form submission for the first page.
=cut
sub change_settings
{
my $self = shift;
my $q = $self->{cgi};
my $status = $q->param('status');
$self->{db}->set_prop('mailman', 'status', $status, type => 'service');
system(SIGEVENT, 'mailman-update') == 0
or return $self->error('ERR_UPDATE');
return $self->success('SUCCESS');
}
1;