#!/usr/bin/perl use Fcntl; sub smtpd_access_policy { if ($attr{"sender"} =~ /\@sender\.example\.com$/i and $attr{"recipient"} =~ /\@recipient\.example\.com$/i) { return "FILTER smtp:[fax.example.com]"; } else { return "dunno"; } } # # You should not have to make changes below this point. # sub LOCK_SH { 1 }; # Shared lock (used for reading). sub LOCK_EX { 2 }; # Exclusive lock (used for writing). sub LOCK_NB { 4 }; # Don't block (for testing). sub LOCK_UN { 8 }; # Release lock. # # Log an error and abort. # sub fatal_exit { my($first) = shift(@_); exit 1; } # # We don't need getopt() for now. # while ($option = shift(@ARGV)) { if ($option eq "-v") { $verbose = 1; } else { exit 1; } } # # Unbuffer standard output. # select((select(STDOUT), $| = 1)[0]); # # Receive a bunch of attributes, evaluate the policy, send the result. # while () { if (/([^=]+)=(.*)\n/) { $attr{substr($1, 0, 512)} = substr($2, 0, 512); } elsif ($_ eq "\n") { fatal_exit "unrecognized request type: '%s'", $attr{request} unless $attr{"request"} eq "smtpd_access_policy"; $action = smtpd_access_policy(); print STDOUT "action=$action\n\n"; %attr = (); } else { chop; } }