#! /usr/bin/perl
#
#list-passthrough <next_hop> <listowner>
#
#Passes a message through this filter, simply to stop sendmail
#from expanding aliases, so that mailinglist expansion won't hang
#if one host in the list is down.
#
# <next-hop> is the alias that really expands the list.
# <listowner> is the mail-agent "from" line; this causes failed mail
# to go here instead of the author.  
#
# EXAMPLE:
#
# mylist:  "| /var/lib/list-passthrough mylist-expander fido.wps.com"
# mylist-expander: :include:/var/lib/mylist.names
#

($program = $0) =~ s%.*/%%;

if ($#ARGV < 1) { die "usage: $program next-hop listowner\n"; } 
$nexthop = $ARGV[0];
$listowner = $ARGV[1];

$sendmail = "/usr/sbin/sendmail"; 
$sendmail = "/usr/local/bin/sendmail" unless -x $sendmail;
die "$program: can't find sendmail\n"  unless -x $sendmail;
$iopts = "-om -oi -odb";

# in case sendmail dumps core or something crazy
$SIG{'PIPE'} = "plumber";
sub plumber { die "$program: \"$sendmail\" died prematurely!\n"; }

open (SENDMAIL, "| $sendmail $iopts -f$listowner $nexthop") ||
    die "$program: can't run $sendmail\n";

print SENDMAIL while <STDIN>;   # gobble message

close SENDMAIL;

exit $?;
