--- Desktop/cyrquota-pf_policy.pl 2007-06-11 04:23:24.389169827 +0100 +++ cyrquota-pf_policy.pl 2007-06-11 04:22:54.035764203 +0100 @@ -5,6 +5,9 @@ # Author: Omni Flux # Most recent version is available at http://www.omniflux.com/devel/ # +# Edited by Benjamin Donnachie to add +# initial support for aliases. +# # Policy Daemon code based on postfix-policyd-spf by Meng Weng Wong # available at http://www.openspf.org/ @@ -155,9 +158,11 @@ my $action = $default_response; - if (lc(rhs ($attr{'recipient'})) eq lc($mydomain)) + my $recipient = checkaliases($attr{'recipient'}); + + if (lc(rhs ($recipient)) eq lc($mydomain)) { - print $sock netstring_encode ("0 " . lhs ($attr{'recipient'})); + print $sock netstring_encode ("0 " . lhs ($recipient)); my $result = netstring_read ($sock); if (!$result) { syslog (warning => "query error"); @@ -179,7 +184,7 @@ } else { - syslog (debug => "Skipping external domain: %s", rhs ($attr{'recipient'})) if $verbose; + syslog (debug => "Skipping external domain: %s", rhs ($recipient)) if $verbose; } print STDOUT "action=$action\n\n"; @@ -213,3 +218,38 @@ } return $string; } + +sub checkaliases { + + my $key = ""; + my $value = ""; + + open(FILE, ") { + chomp; + my ($key, $value) = split (/\s+/, $_); + + if ($key eq $_[0]) { + close(FILE); + return $value; + } + elsif ($key =~ /^\@.*/) { + if (($key =~ /\@(.*)/) eq ($_[0] =~ /.*\@(.*)/)) { + if ($value =~ /^\@.*/) { + close (FILE); + return lhs($_[0]).$value; + } + else { + close (FILE); + return $value; + } + } + } + + } + + close (FILE); + return $_[0]; + +}