summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/contrib/buildvirtuser
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2001-02-28 00:19:57 +0000
committergshapiro <gshapiro@FreeBSD.org>2001-02-28 00:19:57 +0000
commit8d82727087db5182be90a20f20175cc720c5d1e5 (patch)
treef7a64a70968946b03a6d79fcded22b5a31689f6d /contrib/sendmail/contrib/buildvirtuser
parent167a83e7b8733416154f871e39e86ba77eb1554d (diff)
downloadFreeBSD-src-8d82727087db5182be90a20f20175cc720c5d1e5.zip
FreeBSD-src-8d82727087db5182be90a20f20175cc720c5d1e5.tar.gz
Import sendmail 8.11.3
Diffstat (limited to 'contrib/sendmail/contrib/buildvirtuser')
-rwxr-xr-xcontrib/sendmail/contrib/buildvirtuser29
1 files changed, 21 insertions, 8 deletions
diff --git a/contrib/sendmail/contrib/buildvirtuser b/contrib/sendmail/contrib/buildvirtuser
index e544828..3ea2d66 100755
--- a/contrib/sendmail/contrib/buildvirtuser
+++ b/contrib/sendmail/contrib/buildvirtuser
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
-# Copyright (c) 1999-2000 Gregory Neil Shapiro. All Rights Reserved.
+# Copyright (c) 1999-2001 Gregory Neil Shapiro. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -27,7 +27,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-# $Id: buildvirtuser,v 1.1.2.1 2000/10/26 22:51:03 gshapiro Exp $
+# $Id: buildvirtuser,v 1.1.2.3 2001/02/12 02:57:13 gshapiro Exp $
=head1 NAME
@@ -45,7 +45,10 @@ directory should contain one file per virtual domain with the filename
matching the virtual domain name and the contents containing a list of
usernames on the left and the actual address for that username on the
right. An empty left column translates to the default for that domain.
-Blank lines and lines beginning with '#' are ignored.
+Blank lines and lines beginning with '#' are ignored. Occurrences of
+$DOMAIN in the file are replaced by the current domain being processed.
+Occurrences of $LHS in the right hand side are replaced by the address on
+the left hand side.
=head1 CONFIGURATION
@@ -66,21 +69,21 @@ Here are some example files from the /etc/mail/virtusers/ directory:
=head2 /etc/mail/virtusers/bsdunix.org:
# Services
- MAILER-DAEMON gshapiro+MAILER-DAEMON.bsdunix.org@gshapiro.net
- postmaster gshapiro+postmaster.bsdunix.org@gshapiro.net
- webmaster gshapiro+webmaster.bsdunix.org@gshapiro.net
+ MAILER-DAEMON gshapiro+bounce.$DOMAIN@gshapiro.net
+ postmaster gshapiro+$LHS.$DOMAIN@gshapiro.net
+ webmaster gshapiro+$LHS.$DOMAIN@gshapiro.net
# Defaults
error:nouser No such user
# Users
- gshapiro gshapiro+bsdunix.org@gshapiro.net
+ gshapiro gshapiro+$DOMAIN@gshapiro.net
bob robert@smtp.org
=head2 /etc/mail/virtusers/smtp.org:
# Defaults
- gshapiro+smtp.org@gshapiro.net
+ gshapiro+$DOMAIN@gshapiro.net
# Users
john john@wookie.org
@@ -92,6 +95,8 @@ Gregory Neil Shapiro E<lt>F<gshapiro@gshapiro.net>E<gt>
=cut
+use strict;
+
my $makemap = "/usr/sbin/makemap";
my $dbtype = "hash";
my $maildir = "/etc/mail";
@@ -102,6 +107,7 @@ my $newvirt = "$maildir/virtusertable.new.db";
my $virt = "$maildir/virtusertable.db";
my %virt = ();
my $newest = 0;
+my ($lhs, $domain, $key, $value);
opendir(VIRTS, $virts) || die "Could not open directory $virts: $!\n";
my @virts = grep { -f "$virts/$_" } readdir(VIRTS);
@@ -126,10 +132,12 @@ LINE: while (<DOMAIN>)
{
if (defined($1))
{
+ $lhs = "$1";
$key = "$1\@$domain";
}
else
{
+ $lhs = "";
$key = "\@$domain";
}
$value = $2;
@@ -138,6 +146,11 @@ LINE: while (<DOMAIN>)
{
die "Bogus line $line in $virts/$domain\n";
}
+
+ # Variable subsitution
+ $key =~ s/\$DOMAIN/$domain/g;
+ $value =~ s/\$DOMAIN/$domain/g;
+ $value =~ s/\$LHS/$lhs/g;
$virt{$key} = $value;
}
close(DOMAIN) || die "Could not close $virts/$domain: $!\n";
OpenPOWER on IntegriCloud