initial commit of file from CVS for e-smith-qmail on Wed 12 Jul 09:06:46 BST 2023
This commit is contained in:
24
root/etc/e-smith/db/accounts/migrate/10AdminEmail
Normal file
24
root/etc/e-smith/db/accounts/migrate/10AdminEmail
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
my $conf = esmith::ConfigDB->open;
|
||||
return unless $conf;
|
||||
|
||||
my $admin_email = $conf->get_value_and_delete('AdminEmail');
|
||||
return unless defined $admin_email;
|
||||
|
||||
my $admin = $DB->get('admin') ||
|
||||
$DB->new_record('admin', {type => 'system'});
|
||||
if ($admin_email)
|
||||
{
|
||||
$admin->merge_props(
|
||||
EmailForward => 'forward',
|
||||
ForwardAddress => $admin_email,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$admin->merge_props(
|
||||
EmailForward => 'local',
|
||||
ForwardAddress => '',
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
15000000
|
1
root/etc/e-smith/db/configuration/defaults/qmail/status
Normal file
1
root/etc/e-smith/db/configuration/defaults/qmail/status
Normal file
@@ -0,0 +1 @@
|
||||
enabled
|
1
root/etc/e-smith/db/configuration/defaults/qmail/type
Normal file
1
root/etc/e-smith/db/configuration/defaults/qmail/type
Normal file
@@ -0,0 +1 @@
|
||||
service
|
22
root/etc/e-smith/events/actions/pseudonym-cleanup
Normal file
22
root/etc/e-smith/events/actions/pseudonym-cleanup
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::event;
|
||||
|
||||
my $accounts = esmith::AccountsDB->open() or
|
||||
die "Unable to open accounts db: $!";
|
||||
|
||||
my ($self, $account) = @ARGV;
|
||||
|
||||
# Find all "pseudonyms" entries in the e-smith accounts database and
|
||||
# if the pseudonyms has an unexisting Account associated we change
|
||||
# it to user "admin".
|
||||
|
||||
foreach my $pseudo ( $accounts->pseudonyms ) {
|
||||
unless ( $accounts->get($pseudo->prop('Account')) ) {
|
||||
$pseudo->set_prop( 'Account', 'admin' );
|
||||
print "orphaned pseudonym " . $pseudo->key. " has been associated to admin account"
|
||||
}
|
||||
}
|
||||
|
36
root/etc/e-smith/events/actions/qmail-delete-group
Normal file
36
root/etc/e-smith/events/actions/qmail-delete-group
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-2005 MItel Networks Corporation
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
|
||||
my $event = $ARGV [0];
|
||||
my $groupName = $ARGV [1];
|
||||
|
||||
die "Groupname argument missing." unless defined ($groupName);
|
||||
|
||||
$groupName =~ s/\./:/g;
|
||||
unlink "/var/qmail/alias/.qmail-$groupName";
|
||||
unlink "/var/qmail/alias/.qmail-$groupName-default";
|
||||
|
||||
exit (0);
|
26
root/etc/e-smith/events/actions/qmail-ipup
Normal file
26
root/etc/e-smith/events/actions/qmail-ipup
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2001-2006 Mitel Networks Corporation
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
#------------------------------------------------------------
|
||||
# Reset qmail TCP timeouts, and tell qmail-send to retry sending
|
||||
#------------------------------------------------------------
|
||||
|
||||
/var/qmail/bin/qmail-tcpok
|
||||
exec sv alarm /service/qmail
|
112
root/etc/e-smith/events/actions/qmail-update-group
Normal file
112
root/etc/e-smith/events/actions/qmail-update-group
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002-2006 Mitel Networks Corporation
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::util;
|
||||
|
||||
my $c = esmith::ConfigDB->open_ro || die "Couldn't open config db\n";
|
||||
my $a = esmith::AccountsDB->open_ro || die "Couldn't open accounts db\n";
|
||||
|
||||
my $event = $ARGV [0] || die "Event name arg missing\n";;
|
||||
my @groups;
|
||||
|
||||
if (scalar @ARGV)
|
||||
{
|
||||
@groups = map { $a->get($_); } @ARGV;
|
||||
foreach my $g (@groups)
|
||||
{
|
||||
my $type = $g->prop('type');
|
||||
if ($type =~ /^user/)
|
||||
{
|
||||
# That's fine. We were probably just called from the user-delete
|
||||
# event, in which case we want to update all of the groups. So, leave
|
||||
# the groups array empty.
|
||||
@groups = ();
|
||||
last;
|
||||
}
|
||||
elsif ($type !~ /^group/){
|
||||
die "Expected a user or a group. Got neither: $type\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Regenerate all the groups if the previous block failed in some way.
|
||||
unless (@groups)
|
||||
{
|
||||
@groups = $a->groups;
|
||||
}
|
||||
|
||||
foreach my $group (@groups)
|
||||
{
|
||||
my $groupName = $group->key;
|
||||
unless ($group->prop('type') eq 'group')
|
||||
{
|
||||
warn "Account $groupName is not a group account.\n";
|
||||
next;
|
||||
}
|
||||
my %properties = $group->props;
|
||||
$groupName =~ s/\./:/g;
|
||||
my $group = "/var/qmail/alias/.qmail-$groupName";
|
||||
my @group_members = split(/,/, $properties{Members});
|
||||
# Check if we should exclude members from this group email address
|
||||
my @exclude_users = split(/,/, ($properties{EmailExcludeUsers} || ''));
|
||||
my @exclude_groups = split(/,/, ($properties{EmailExcludeGroups} || ''));
|
||||
foreach my $exclude_group (@exclude_groups){
|
||||
my $g = $a->get($exclude_group);
|
||||
next unless $g;
|
||||
push @exclude_users, split(/,/, ($g->prop('Members') || ''));
|
||||
}
|
||||
my %exclude = map { $_, 1 } @exclude_users;
|
||||
@exclude_users = keys %exclude;
|
||||
my @members = ();
|
||||
foreach my $user (@group_members){
|
||||
next if grep { $_ eq $user } @exclude_users;
|
||||
push @members, $user;
|
||||
}
|
||||
my $members = join(',', @members);
|
||||
|
||||
esmith::util::processTemplate(
|
||||
{
|
||||
CONFREF =>
|
||||
{
|
||||
Members => $members,
|
||||
},
|
||||
|
||||
TEMPLATE_PATH =>
|
||||
"/var/qmail/alias/.qmail-group",
|
||||
|
||||
OUTPUT_FILENAME => "/var/qmail/alias/.qmail-$groupName",
|
||||
}
|
||||
);
|
||||
|
||||
unless (-f "/var/qmail/alias/.qmail-$groupName-default")
|
||||
{
|
||||
symlink "/var/qmail/alias/.qmail-$groupName",
|
||||
"/var/qmail/alias/.qmail-$groupName-default";
|
||||
}
|
||||
|
||||
}
|
||||
exit (0);
|
84
root/etc/e-smith/events/actions/qmail-update-user
Normal file
84
root/etc/e-smith/events/actions/qmail-update-user
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-2005 Mitel Networks Corporation
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
package esmith;
|
||||
|
||||
use strict;
|
||||
use Errno;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::templates;
|
||||
use User::pwent;
|
||||
|
||||
|
||||
my $accountsdb = esmith::AccountsDB->open_ro or
|
||||
die "Could not open accounts db\n";
|
||||
|
||||
my $event = shift;
|
||||
my $userName = shift;
|
||||
my @users;
|
||||
|
||||
if (defined $userName)
|
||||
{
|
||||
my $user = $accountsdb->get($userName);
|
||||
die
|
||||
"Account $userName is not a user account; update email forwarding failed.\n"
|
||||
unless $userName eq 'admin' || ($user && $user->prop('type') eq "user");
|
||||
@users = ($user);
|
||||
}
|
||||
else
|
||||
{
|
||||
@users = ( $accountsdb->users, $accountsdb->get('admin') );
|
||||
}
|
||||
|
||||
foreach my $user (@users)
|
||||
{
|
||||
my $userName = $user->key;
|
||||
|
||||
setpwent();
|
||||
my $home = getpwnam($userName)->dir;
|
||||
for my $dotfile ( qw(.qmail .qmail-junkmail) )
|
||||
{
|
||||
esmith::templates::processTemplate (
|
||||
{
|
||||
MORE_DATA =>
|
||||
{
|
||||
USERNAME => $userName ,
|
||||
},
|
||||
TEMPLATE_PATH => "/$dotfile",
|
||||
TEMPLATE_EXPAND_QUEUE =>
|
||||
[
|
||||
"/etc/e-smith/templates-user-custom",
|
||||
"/etc/e-smith/templates-user",
|
||||
],
|
||||
OUTPUT_PREFIX => "$home",
|
||||
UID => $userName,
|
||||
GID => $userName,
|
||||
PERMS => 0644,
|
||||
} );
|
||||
};
|
||||
unless (-f "$home/.qmail-default")
|
||||
{
|
||||
symlink ".qmail", "$home/.qmail-default";
|
||||
}
|
||||
}
|
||||
|
||||
exit (0);
|
@@ -0,0 +1,2 @@
|
||||
| [ -d ./Maildir/.junkmail/ ] || /var/qmail/bin/maildirmake ./Maildir/.junkmail/
|
||||
./Maildir/.junkmail/
|
14
root/etc/e-smith/templates-user/.qmail/00setup
Normal file
14
root/etc/e-smith/templates-user/.qmail/00setup
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
# vim: ft=perl:
|
||||
die "USERNAME not set." unless defined ($USERNAME);
|
||||
|
||||
use esmith::AccountsDB;
|
||||
$adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB";
|
||||
|
||||
$user = $adb->get($USERNAME) or die "No user $USERNAME in AccountsDB";
|
||||
|
||||
%props = $user->props;
|
||||
$props{EmailForward} ||= 'local';
|
||||
|
||||
$OUT = '';
|
||||
}
|
20
root/etc/e-smith/templates-user/.qmail/10Filter
Normal file
20
root/etc/e-smith/templates-user/.qmail/10Filter
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
# vim: ft=perl:
|
||||
$OUT = '';
|
||||
|
||||
$props{Filter} ||= 'yes';
|
||||
|
||||
return '# Filter property is no'
|
||||
unless ($props{Filter} eq 'yes');
|
||||
|
||||
my $preprocessing = "";
|
||||
my $dt = $qmail{DeliveryType} || '';
|
||||
|
||||
if ($dt eq 'program')
|
||||
{
|
||||
$preprocessing .= '| ';
|
||||
}
|
||||
$preprocessing .= $qmail{DeliveryInstruction} || '';
|
||||
|
||||
$OUT = "$preprocessing\n" if $preprocessing;
|
||||
}
|
7
root/etc/e-smith/templates-user/.qmail/70Forward
Normal file
7
root/etc/e-smith/templates-user/.qmail/70Forward
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
# vim: ft=perl:
|
||||
return '# Forward not set'
|
||||
unless ($props{EmailForward} =~ /^(forward|both)$/);
|
||||
|
||||
return '&' . $props{ForwardAddress};
|
||||
}
|
7
root/etc/e-smith/templates-user/.qmail/90local
Normal file
7
root/etc/e-smith/templates-user/.qmail/90local
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
# vim: ft=perl:
|
||||
return '# No local delivery'
|
||||
unless ($props{EmailForward} =~ /^(local|both)$/);
|
||||
|
||||
return './Maildir/';
|
||||
}
|
3
root/etc/e-smith/templates.metadata/home/e-smith/.qmail
Normal file
3
root/etc/e-smith/templates.metadata/home/e-smith/.qmail
Normal file
@@ -0,0 +1,3 @@
|
||||
UID="admin"
|
||||
GID="admin"
|
||||
PERMS=0640
|
@@ -0,0 +1,2 @@
|
||||
UID="alias"
|
||||
GID="qmail"
|
@@ -0,0 +1 @@
|
||||
FILTER=sub { $_[0] =~ /^\s*$/ ? '' : $_[0] }
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
($EmailUnknownUser eq "returntosender") ?
|
||||
"| bouncesaying 'Recipient unknown'" :
|
||||
"$EmailUnknownUser";
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
# Generic template to rebuild any .qmail-groupname file. Expects
|
||||
# to be called with a CONFREF containing the group members.
|
||||
$OUT .= join("\n", map { '&' . $_ } split(/,/, $Members));
|
||||
}
|
@@ -0,0 +1 @@
|
||||
| forward $DEFAULT@{"$SystemName.$DomainName"}
|
@@ -0,0 +1,13 @@
|
||||
{
|
||||
use esmith::AccountsDB;
|
||||
my $a = esmith::AccountsDB->open_ro;
|
||||
|
||||
$OUT = '';
|
||||
|
||||
for my $user ( $a->get('admin'), $a->users )
|
||||
{
|
||||
next if ( ($user->prop('EveryoneEmail') || 'yes') eq 'no');
|
||||
|
||||
$OUT .= '&' . $user->key . "\n";
|
||||
}
|
||||
}
|
1
root/etc/e-smith/templates/var/qmail/control/bouncefrom
Normal file
1
root/etc/e-smith/templates/var/qmail/control/bouncefrom
Normal file
@@ -0,0 +1 @@
|
||||
MAILER-DAEMON
|
1
root/etc/e-smith/templates/var/qmail/control/bouncehost
Normal file
1
root/etc/e-smith/templates/var/qmail/control/bouncehost
Normal file
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
@@ -0,0 +1 @@
|
||||
{ (defined $DB->get('qmail')->prop('ConcurrencyLocal')) ? $DB->get('qmail')->prop('ConcurrencyLocal') : "20"; }
|
@@ -0,0 +1 @@
|
||||
{ (defined $DB->get('qmail')->prop('ConcurrencyRemote'))? $DB->get('qmail')->prop('ConcurrencyRemote') : "20"; }
|
1
root/etc/e-smith/templates/var/qmail/control/databytes
Normal file
1
root/etc/e-smith/templates/var/qmail/control/databytes
Normal file
@@ -0,0 +1 @@
|
||||
{ $DB->get('qmail')->prop('MaxMessageSize') || "0"; }
|
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
1
root/etc/e-smith/templates/var/qmail/control/defaulthost
Normal file
1
root/etc/e-smith/templates/var/qmail/control/defaulthost
Normal file
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
@@ -0,0 +1 @@
|
||||
{ $DB->get('qmail')->prop('DoubleBounceTo') || "postmaster"; }
|
1
root/etc/e-smith/templates/var/qmail/control/envnoathost
Normal file
1
root/etc/e-smith/templates/var/qmail/control/envnoathost
Normal file
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
1
root/etc/e-smith/templates/var/qmail/control/helohost
Normal file
1
root/etc/e-smith/templates/var/qmail/control/helohost
Normal file
@@ -0,0 +1 @@
|
||||
{ $qpsmtpd{HeloHost} || $DomainName }
|
11
root/etc/e-smith/templates/var/qmail/control/locals
Normal file
11
root/etc/e-smith/templates/var/qmail/control/locals
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Everything except the localhost and the local machine name is now
|
||||
# treated as a virtual domain.
|
||||
#
|
||||
localhost
|
||||
{"$SystemName.$DomainName"}
|
||||
{
|
||||
return "# No ExternalIP" unless (defined $ExternalIP);
|
||||
|
||||
return "[$ExternalIP]";
|
||||
}
|
1
root/etc/e-smith/templates/var/qmail/control/me
Normal file
1
root/etc/e-smith/templates/var/qmail/control/me
Normal file
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
1
root/etc/e-smith/templates/var/qmail/control/plusdomain
Normal file
1
root/etc/e-smith/templates/var/qmail/control/plusdomain
Normal file
@@ -0,0 +1 @@
|
||||
{ $DomainName }
|
@@ -0,0 +1,25 @@
|
||||
{
|
||||
#
|
||||
# qmail's smtproutes mechanism works such that the LAST BEST match
|
||||
# found in /var/qmail/control/smtproutes will be used in preference
|
||||
# to any other entry.
|
||||
#
|
||||
# Consider the following /var/qmail/control/smtproutes example:
|
||||
#
|
||||
# :smarthost.somewhere
|
||||
# domain.place:some.host
|
||||
# domain.place:other.host
|
||||
# :some.other.smarthost.elsewhere
|
||||
#
|
||||
# Mail for user@domain.place will ALWAYS be delivered to
|
||||
# other.host. The entry for some.host will NEVER be used.
|
||||
#
|
||||
# Mail for any other domain will ALWAYS be delivered to
|
||||
# some.other.smarthost.elsewhere. The entry for smarthost.somewhere
|
||||
# will NEVER be used.
|
||||
#
|
||||
# Therefore, if you wish to make any customisations to the
|
||||
# /var/qmail/control/smtproutes templates, you must ensure that they
|
||||
# appear AFTER the standard e-smith template entries.
|
||||
#
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
{
|
||||
$OUT = "";
|
||||
|
||||
use esmith::DomainsDB;
|
||||
my $ddb = esmith::DomainsDB->open_ro();
|
||||
|
||||
for my $domain ( $ddb->domains )
|
||||
{
|
||||
my $mail_server = $domain->prop('MailServer')
|
||||
|| $DelegateMailServer
|
||||
|| 'localhost';
|
||||
|
||||
next if ( $mail_server eq 'localhost' );
|
||||
|
||||
$OUT .= $domain->key . ":$mail_server\n";
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
{
|
||||
$OUT = "";
|
||||
|
||||
#--------------------------------------------------
|
||||
# Now check for SMTP smart host
|
||||
#--------------------------------------------------
|
||||
|
||||
if (
|
||||
$SMTPSmartHost
|
||||
&&
|
||||
($SMTPSmartHost ne 'off')
|
||||
&&
|
||||
($SMTPSmartHost !~ /^\s*$/)
|
||||
)
|
||||
{
|
||||
# Is the smtp-auth-proxy enabled?
|
||||
if (${'smtp-auth-proxy'}{'status'} eq 'enabled')
|
||||
{
|
||||
$OUT .= ":localhost:26";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= ":$SMTPSmartHost";
|
||||
}
|
||||
}
|
||||
|
||||
chomp ($OUT);
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
use esmith::DomainsDB;
|
||||
my $domainsdb = esmith::DomainsDB->open_ro();
|
||||
|
||||
for my $domain ($domainsdb->domains)
|
||||
{
|
||||
my $mail_server = $domain->prop('MailServer')
|
||||
|| $DelegateMailServer
|
||||
|| 'localhost';
|
||||
|
||||
next if ( $mail_server ne 'localhost' );
|
||||
|
||||
$emaildomain = $domain->key;
|
||||
my $handler = $domain->prop('EmailTo') || "alias-localdelivery";
|
||||
$OUT .= "$emaildomain:$handler\n";
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
my $dms = $DelegateMailServer;
|
||||
|
||||
return "# DelegateMailServer is set" if ($dms && ($dms !~ /^\s*$/));
|
||||
|
||||
$OUT = "";
|
||||
|
||||
use esmith::AccountsDB;
|
||||
|
||||
my $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB";
|
||||
|
||||
for my $pseudo ($adb->pseudonyms)
|
||||
{
|
||||
next unless ($pseudo->key =~ /@/);
|
||||
|
||||
my $account = $pseudo->prop("Account");
|
||||
$account = "admin" and warn $pseudo->prop("Account") . " is not a valid account, default to admin " unless $adb->get($account);
|
||||
my $acct = $adb->get($account);
|
||||
if ($acct->prop('type') eq "group")
|
||||
{
|
||||
$account =~ s/\./:/g;
|
||||
}
|
||||
|
||||
$OUT .= $pseudo->key . ":$account\n";
|
||||
}
|
||||
}
|
32
root/etc/e-smith/templates/var/qmail/users/assign/30admin
Normal file
32
root/etc/e-smith/templates/var/qmail/users/assign/30admin
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for the admin user. This will be
|
||||
# handled by ~admin/.qmail.
|
||||
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("admin");
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'admin\' "
|
||||
. "while processing admin assignment.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
# Assign mail for the admin user itself, and for admin-ext.
|
||||
|
||||
my $admin_assign = "admin:${uid}:${gid}:${dir}";
|
||||
$OUT .= "=admin:${admin_assign}:::\n";
|
||||
$OUT .= "+admin-:${admin_assign}:-::";
|
||||
}
|
32
root/etc/e-smith/templates/var/qmail/users/assign/40alias
Normal file
32
root/etc/e-smith/templates/var/qmail/users/assign/40alias
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for the alias user. This will be
|
||||
# handled by ~alias/.qmail.
|
||||
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("alias");
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'alias\' "
|
||||
. "while processing alias assignment.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
# Assign mail for the alias user itself, and for alias-ext.
|
||||
|
||||
my $alias_assign = "alias:${uid}:${gid}:${dir}";
|
||||
$OUT .= "=alias:${alias_assign}:::\n";
|
||||
$OUT .= "+alias-:${alias_assign}:-::";
|
||||
}
|
36
root/etc/e-smith/templates/var/qmail/users/assign/45shared
Normal file
36
root/etc/e-smith/templates/var/qmail/users/assign/45shared
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for the shared group. This will
|
||||
# be handled by ~alias/.qmail-shared and ~alias/.qmail-shared-ext.
|
||||
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("alias");
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'alias\' "
|
||||
. "while processing shared assignment.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
my $alias_assign = "alias:${uid}:${gid}:${dir}";
|
||||
|
||||
$OUT .= "=shared:${alias_assign}:-:shared:\n";
|
||||
$OUT .= "+shared-:${alias_assign}:-shared-::\n";
|
||||
|
||||
# Need to remove the final newline character. Blank lines in
|
||||
# /var/qmail/users/assign are prohibited.
|
||||
|
||||
chomp($OUT);
|
||||
}
|
56
root/etc/e-smith/templates/var/qmail/users/assign/50system
Normal file
56
root/etc/e-smith/templates/var/qmail/users/assign/50system
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for system accounts. These will
|
||||
# be handled by admin. Make sure we DON'T reassign the admin or
|
||||
# alias users!
|
||||
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("admin");
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'admin\' "
|
||||
. "while processing system assignments.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
my $admin_assign = "admin:${uid}:${gid}:${dir}";
|
||||
|
||||
use esmith::AccountsDB;
|
||||
my $adb = esmith::AccountsDB->open_ro();
|
||||
|
||||
foreach my $user ( $adb->get_all_by_prop( type => 'system' ) )
|
||||
{
|
||||
next if ($user->key eq "admin");
|
||||
next if ($user->key eq "alias");
|
||||
next if ($user->key eq "shared");
|
||||
|
||||
# Assign mail for system_account@
|
||||
$OUT .= "=" . $user->key . ":${admin_assign}:::\n";
|
||||
|
||||
# Assign mail for system_account-ext@
|
||||
$OUT .= "+" . $user->key . "-:${admin_assign}:-::\n";
|
||||
}
|
||||
|
||||
# Need to remove the final newline character. Blank lines in
|
||||
# /var/qmail/users/assign are prohibited.
|
||||
|
||||
chomp($OUT);
|
||||
|
||||
# Failsafe: /var/qmail/users/assign cannot have blank lines.
|
||||
# Therefore, if $OUT is empty, simply set up an assign for the
|
||||
# admin user.
|
||||
|
||||
$OUT = "=admin:${admin_assign}:::" unless $OUT;
|
||||
}
|
59
root/etc/e-smith/templates/var/qmail/users/assign/60users
Normal file
59
root/etc/e-smith/templates/var/qmail/users/assign/60users
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for users. These will be handled by
|
||||
# ~user/.qmail.
|
||||
|
||||
use esmith::AccountsDB;
|
||||
my $adb = esmith::AccountsDB->open_ro();
|
||||
|
||||
foreach $user ( $adb->users )
|
||||
{
|
||||
my $user_name = $user->key;
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam($user_name);
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'$user_name\' "
|
||||
. "while processing user assignments.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
$user_assign = $user_name . ":${uid}:${gid}:${dir}";
|
||||
|
||||
# Assign mail for user@
|
||||
$OUT .= "=" . $user_name . ":${user_assign}:::\n";
|
||||
|
||||
# Assign mail for user-ext@
|
||||
$OUT .= "+" . $user_name . "-:${user_assign}:-::\n";
|
||||
}
|
||||
|
||||
# Need to remove the final newline character. Blank lines in
|
||||
# /var/qmail/users/assign are prohibited.
|
||||
|
||||
chomp($OUT);
|
||||
|
||||
# Failsafe: /var/qmail/users/assign cannot have blank lines.
|
||||
# Therefore, if $OUT is empty, simply set up an assign for the
|
||||
# alias user.
|
||||
|
||||
unless ($OUT)
|
||||
{
|
||||
(undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("alias");
|
||||
|
||||
$alias_assign = "alias:${uid}:${gid}:${dir}";
|
||||
$OUT = "=alias:${alias_assign}:::";
|
||||
}
|
||||
}
|
147
root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms
Normal file
147
root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms
Normal file
@@ -0,0 +1,147 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for pseudonyms. These will
|
||||
# be handled by ~user/.qmail in the case of a user pseudonym
|
||||
# or by ~admin/.qmail in the case of a system pseudonym or by
|
||||
# alias/.qmail-groupname in the case of a group pseudonym.
|
||||
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("alias");
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'alias\' "
|
||||
. "while processing pseudonym assignments.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
my $alias_assign = "alias:${uid}:${gid}:${dir}";
|
||||
|
||||
undef $uid;
|
||||
undef $gid;
|
||||
undef $dir;
|
||||
|
||||
(undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("admin");
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'admin\' "
|
||||
. "while processing pseudonym assignments.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
my $admin_assign = "admin:${uid}:${gid}:${dir}";
|
||||
|
||||
# Create assignments for each pseudonym.
|
||||
|
||||
use esmith::AccountsDB;
|
||||
my $adb = esmith::AccountsDB->open_ro();
|
||||
|
||||
foreach $pseudonym ( $adb->pseudonyms )
|
||||
{
|
||||
next if ( $pseudonym->key =~ /@/ ); # user@domain goes in virtualdomains
|
||||
|
||||
my $account = $pseudonym->prop('Account');
|
||||
unless ($account)
|
||||
{
|
||||
my $key = $pseudonym->key;
|
||||
warn "pseudonym $key has no account property, default to admin";
|
||||
$account = $adb->get('admin');
|
||||
#next;
|
||||
}
|
||||
|
||||
$account = $adb->get($pseudonym->prop('Account'));
|
||||
unless ($account)
|
||||
{
|
||||
my $key = $pseudonym->key;
|
||||
warn "pseudonym $key points to account which does not exist, default to admin";
|
||||
$account = $adb->get('admin');
|
||||
#next;
|
||||
}
|
||||
|
||||
my $i = 1;
|
||||
while ( $account->prop('type') eq "pseudonym")
|
||||
{
|
||||
$account = $adb->get($account->prop('Account'));
|
||||
unless ($account)
|
||||
{
|
||||
my $key = $pseudonym->key;
|
||||
warn "pseudonym $key points to account which does not exist, default to admin";
|
||||
$account = $adb->get('admin');
|
||||
last;
|
||||
}
|
||||
$i ++; last if $i>10;
|
||||
}
|
||||
|
||||
if ($account->prop('type') eq "pseudonym")
|
||||
{
|
||||
warn "users/assign: Skipping " . $pseudonym->key . " - too many pseudonym levels\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($account->prop('type') eq "user")
|
||||
{
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam($account->key);
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'" . $account->key . "\' "
|
||||
. "while processing pseudonym assignments.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
$assign = $account->key . ":${uid}:${gid}:${dir}";
|
||||
|
||||
# Assign mail for user_pseudonym@
|
||||
$OUT .= "=" . $pseudonym->key . ":${assign}:::\n";
|
||||
$OUT .= "+" . $pseudonym->key . "-:${assign}:-::\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($account->prop('type') eq "group" || $account->key eq "shared")
|
||||
{
|
||||
$OUT .= "=" . $pseudonym->key . ":${alias_assign}:-:" . $account->key . ":\n";
|
||||
$OUT .= "+" . $pseudonym->key . "-:${alias_assign}:-:" . $account->key . ":\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($account->prop('type') eq "system" )
|
||||
{
|
||||
$OUT .= "=" . $pseudonym->key . ":${admin_assign}:::\n";
|
||||
$OUT .= "+" . $pseudonym->key . "-:${admin_assign}:-::\n";
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
# Need to remove the final newline character. Blank lines in
|
||||
# /var/qmail/users/assign are prohibited.
|
||||
|
||||
chomp($OUT);
|
||||
|
||||
# Failsafe: /var/qmail/users/assign cannot have blank lines.
|
||||
# Therefore, if $OUT is empty, simply set up an assign for the
|
||||
# alias user.
|
||||
|
||||
$OUT = "=alias:${alias_assign}:::" unless $OUT;
|
||||
}
|
51
root/etc/e-smith/templates/var/qmail/users/assign/80groups
Normal file
51
root/etc/e-smith/templates/var/qmail/users/assign/80groups
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
$OUT = '';
|
||||
|
||||
# Generate qmail user assignments for groups. These will be handled
|
||||
# by ~alias/.qmail-groupname and ~alias/.qmail-groupname-ext.
|
||||
|
||||
my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef)
|
||||
= getpwnam("alias");
|
||||
|
||||
# It is almost impossible to get Text::Template to output nothing
|
||||
# on failure. It can be done by removing the newline at the end of
|
||||
# this file but that is messy. Therefore, we'll simply return an
|
||||
# error message that will make qmail-newu fail. Also send a
|
||||
# warning message that will be captured in the logs.
|
||||
|
||||
unless (defined $uid && defined $gid && defined $dir)
|
||||
{
|
||||
my $msg =
|
||||
"Failed to obtain user details for \'alias\' "
|
||||
. "while processing group assignments.";
|
||||
|
||||
warn "$msg\n";
|
||||
$OUT = $msg;
|
||||
return;
|
||||
}
|
||||
|
||||
my $alias_assign = "alias:${uid}:${gid}:${dir}";
|
||||
|
||||
use esmith::AccountsDB;
|
||||
my $adb = esmith::AccountsDB->open_ro();
|
||||
|
||||
foreach $group ( $adb->groups )
|
||||
{
|
||||
# Assign mail for group@
|
||||
$OUT .= "=" . $group->key . ":${alias_assign}:-:" . $group->key . ":\n";
|
||||
|
||||
# Assign mail for group-ext@
|
||||
$OUT .= "+" . $group->key . "-:${alias_assign}:-" . $group->key . "-::\n";
|
||||
}
|
||||
|
||||
# Need to remove the final newline character. Blank lines in
|
||||
# /var/qmail/users/assign are prohibited.
|
||||
|
||||
chomp($OUT);
|
||||
|
||||
# Failsafe: /var/qmail/users/assign cannot have blank lines.
|
||||
# Therefore, if $OUT is empty, simply set up an assign for the
|
||||
# alias user.
|
||||
|
||||
$OUT = "=alias:${alias_assign}:::" unless $OUT;
|
||||
}
|
@@ -0,0 +1 @@
|
||||
.
|
Reference in New Issue
Block a user