mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-02 01:20:54 +00:00
9c859f6f6e
- Support stagedir - Fix all leftovers Note that this depends on new Mk/Scripts/check_leftovers.sh added in r351446. - Bump PORTREVISION in all ports due to plist being fixed. - Support man.d on FreeBSD 9+ - Convert NOPORTDOCS - Fix bad perl shebang for scripts/mkaliasdir - Remove pkg-install and move all to pkg-plist - Fix /var/qmail modified warning in poudriere by doing nothing in install-mtree - Fix /var/qmail getting unpredictable/wrong permissions due to USERS/GROUPS changing for every user with HOME=/var/qmail - Use more OPTIONS helpers - Fix ccache support for spamcontrol patch building - Fix build of SMTPEXTFORK in mail/qmail-spamcontrol with recent clang Tested with: pkg and pkg_install
110 lines
1.8 KiB
Perl
110 lines
1.8 KiB
Perl
#!/usr/bin/env perl
|
|
#
|
|
# Script to populate a Qmail ~alias directory with entries from
|
|
# an [SZ]mail{er} or sendmail-like aliases file
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# Dan Cross <tenser@spitfire.ecsel.psu.edu>
|
|
#
|
|
|
|
require 'getopts.pl';
|
|
|
|
$ALIASES = "/etc/aliases";
|
|
|
|
die "$0 must be run as root!\n" if ($< != 0);
|
|
|
|
do Getopts('vf:');
|
|
|
|
$verbose = 0 unless ($verbose = $opt_v);
|
|
$aliases = $ALIASES unless ($aliases = $opt_f);
|
|
|
|
if (($aliasdir = (getpwnam("alias"))[7]) eq "")
|
|
{
|
|
die "User alias does not exist, bailing!\n";
|
|
}
|
|
|
|
if (($qmaildir = (getpwnam("qmaild"))[7]) eq "")
|
|
{
|
|
die "User qmaild does not exist, bailing!\n";
|
|
}
|
|
|
|
$ME = "$qmaildir/control/me";
|
|
|
|
die "Error opening $ME: $!\n" unless open(ME, "$ME");
|
|
chop($me = <ME>);
|
|
close (ME);
|
|
|
|
die "Error opening $aliases: $!\n" unless open(ALIASES, "$aliases");
|
|
|
|
while (<ALIASES>)
|
|
{
|
|
chop;
|
|
|
|
$mode = ">";
|
|
|
|
s/#.*$//;
|
|
|
|
($target, $data) = split(/:/, $_, 2);
|
|
|
|
$data =~ s/^\s+//;
|
|
$data =~ s/\s+$//;
|
|
|
|
next if (/^$/);
|
|
|
|
if ($data =~ /^$/)
|
|
{
|
|
while (chop($data = <ALIASES>))
|
|
{
|
|
$data =~ s/^\s+//;
|
|
$data =~ s/\s+$//;
|
|
|
|
last if ($data !~ /^$/);
|
|
}
|
|
}
|
|
|
|
$f = "$aliasdir/.qmail-$target";
|
|
|
|
@data = split(/\,/, $data);
|
|
$datum = $data[0];
|
|
|
|
if ($datum =~ /^:include:/i)
|
|
{
|
|
$datum =~ s/^:include://i;
|
|
$verbose && print "Symlinking $f to $datum...\n";
|
|
symlink($datum, $f);
|
|
shift(@data);
|
|
$f = $datum;
|
|
$mode = ">>";
|
|
}
|
|
|
|
open(ALIAS, "$mode$f") || die "Error creating $f: $!\n";
|
|
|
|
$verbose && print "Creating $f...\n";
|
|
|
|
foreach $datum (@data)
|
|
{
|
|
$datum =~ s/"$// if ($datum =~ s/^"// ||
|
|
$datum =~ s/^\|[ \t]*"/|/);
|
|
|
|
if ($datum =~ /^[|\/]/)
|
|
{
|
|
print ALIAS $datum, "\n";
|
|
}
|
|
else
|
|
{
|
|
$datum = "&" . $datum;
|
|
$datum .= "\@$me" unless ($datum =~ /\@/);
|
|
print ALIAS "$datum\n";
|
|
}
|
|
|
|
$verbose && print "\tPopulating $f with $datum...\n";
|
|
}
|
|
|
|
close(ALIAS);
|
|
}
|
|
|
|
close(ALIASES);
|
|
|
|
exit 0;
|