initial commit of file from CVS for e-smith-qmail on Wed 12 Jul 09:06:46 BST 2023

This commit is contained in:
Brian Read
2023-07-12 09:06:46 +01:00
parent 522798702f
commit 2d08981b2a
67 changed files with 2072 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
{
($EmailUnknownUser eq "returntosender") ?
"| bouncesaying 'Recipient unknown'" :
"$EmailUnknownUser";
}

View File

@@ -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));
}

View File

@@ -0,0 +1 @@
| forward $DEFAULT@{"$SystemName.$DomainName"}

View File

@@ -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";
}
}

View File

@@ -0,0 +1 @@
MAILER-DAEMON

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -0,0 +1 @@
{ (defined $DB->get('qmail')->prop('ConcurrencyLocal')) ? $DB->get('qmail')->prop('ConcurrencyLocal') : "20"; }

View File

@@ -0,0 +1 @@
{ (defined $DB->get('qmail')->prop('ConcurrencyRemote'))? $DB->get('qmail')->prop('ConcurrencyRemote') : "20"; }

View File

@@ -0,0 +1 @@
{ $DB->get('qmail')->prop('MaxMessageSize') || "0"; }

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -0,0 +1 @@
{ $DB->get('qmail')->prop('DoubleBounceTo') || "postmaster"; }

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -0,0 +1 @@
{ $qpsmtpd{HeloHost} || $DomainName }

View 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]";
}

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -0,0 +1 @@
{ $DomainName }

View File

@@ -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.
#
}

View File

@@ -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";
}
}

View File

@@ -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);
}

View File

@@ -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";
}
}

View File

@@ -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";
}
}

View 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}:-::";
}

View 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}:-::";
}

View 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);
}

View 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;
}

View 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}:::";
}
}

View 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;
}

View 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;
}

View File

@@ -0,0 +1 @@
.