summaryrefslogtreecommitdiff
path: root/localmkpostfixvirtual
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2002-11-04 22:43:31 +0000
committerJonas Smedegaard <dr@jones.dk>2002-11-04 22:43:31 +0000
commit9dbd49b1bb3181c90bb23769bc44c5498f97d505 (patch)
tree0d44af0cb7b15bc54a98069fa579ca8f22887c88 /localmkpostfixvirtual
parenteeb7288b221cc21eef198792f0fdb0d04c98da90 (diff)
Major update:
* Support for catch-all pseudo-address: +@ or +@mailgroup * Correct handling of account being both uid and mailgroup * Improved separation of mailgroup owners and other mailgroup members (don't take it for granted that mailgroup owner and gid is the same).
Diffstat (limited to 'localmkpostfixvirtual')
-rwxr-xr-xlocalmkpostfixvirtual32
1 files changed, 25 insertions, 7 deletions
diff --git a/localmkpostfixvirtual b/localmkpostfixvirtual
index 79ad78f..b2b94a7 100755
--- a/localmkpostfixvirtual
+++ b/localmkpostfixvirtual
@@ -3,7 +3,7 @@
# /usr/local/sbin/localmkpostfixvirtual
# Copyright 2001-2002 Jonas Smedegaard <dr@jones.dk>
#
-# $Id: localmkpostfixvirtual,v 1.9 2002-11-03 03:06:32 jonas Exp $
+# $Id: localmkpostfixvirtual,v 1.10 2002-11-04 22:43:31 jonas Exp $
#
# Generate virtual file for postfix
#
@@ -35,7 +35,7 @@ function get_roomnumber_field() { getent passwd $1 | awk -F: '{print $5}' | awk
function get_other_field() { getent passwd $1 | awk -F: '{print $5}' | awk -F, '{print $5}'; }
function get_groups() { groups $1 | sed -e 's/^.*: //' -e "s/\( \+\|^\)$1\( \+\|$\)/\1/"; }
function get_domain() { echo $1 | egrep "^@[\.[:alnum:]-]+$" | sed -e 's/@//'; }
-function get_account() { echo $1 | egrep "^[\.[:alnum:]-]+@($gid|$maildomain)?$" | sed -e 's/@.*//'; }
+function get_account() { echo $1 | egrep "^([\.[:alnum:]-]+|\+)@($gid|$maildomain)?$" | sed -e 's/@.*//'; }
function print_accounts() {
uid=$1
@@ -47,7 +47,19 @@ function print_accounts() {
uid_seen=""
for mailaccountchunk in `get_other_field $uid`; do
for mailaccount in `get_account $mailaccountchunk`; do
- echo "$mailaccount@$maildomain $uid"
+ case $mailaccount in
+ '+')
+ if [ -z "$joker_seen" ]; then
+ echo "@$maildomain $uid"
+ joker_seen="$uid"
+ else
+ echo "#WARNING: Catch-all for $maildomain already set to $joker_seen: `get_fullname_field $uid`"
+ fi
+ ;;
+ *)
+ echo "$mailaccount@$maildomain $uid"
+ ;;
+ esac
uid_seen=1
done
done
@@ -66,14 +78,20 @@ for gid in $@; do
fi
loop=true
print_accounts root "$maildomain" "$maildomain VIRTUAL" "postmaster@$maildomain root"
+ mailgroupowners=""
mailusers=""
mailgroups=`get_roomnumber_field $gid`
- [ -z "$mailgroups" ] && mailgroups=$gid
+ test -z "$mailgroups" && mailgroups=$gid
for mailgroup in $mailgroups; do
- mailusers="$mailusers `members $mailgroup`"
+ mailgroupowners="$mailgroup_owners `members -p $mailgroup`"
+ mailusers="$mailusers `members -s $mailgroup`"
done
-# for uid in `members $gid | sort`; do
- for uid in `echo $mailusers | tsort | uniq | grep -v $gid | sort`; do
+ # Do mailgroup owners (and don't warn if there's no addresses attached)
+ for uid in `echo $mailgroupowners | tsort | uniq | sort`; do
+ print_accounts $uid "$maildomain" "# `get_fullname_field $uid` (`get_groups $uid`)" ""
+ done
+ # Do secondary mailgroup members
+ for uid in `echo $mailusers | tsort | uniq | sort`; do
print_accounts $uid "$maildomain" "# `get_fullname_field $uid` (`get_groups $uid`)" "#WARNING: No addresses for $uid"
done
done