--- sendmail-8.12.5/contrib/etrn.pl.mwe Tue Jul 9 11:17:50 2002 +++ sendmail-8.12.5/contrib/etrn.pl Tue Jul 9 11:33:13 2002 @@ -81,12 +81,13 @@ while (){ if (/^Fw.*$/){ # look for a line starting with "Fw" $cwfile = $_; - chop($cwfile); - $optional = /^Fw-o/; - $cwfile =~ s,^Fw[^/]*,,; # extract the file name - + chomp($cwfile); + ($optional,$cwfile,$comment_delim) = /^Fw(-o)?\s*(\S*)\s*(?:\s%(.*))?$/; + if (!$comment_delim) $comment_delim = '[^#]'; + $comment_delim =~ s/[\\](.)/$1/g; # unescape if (-r $cwfile) { - push (@cwfiles, $cwfile); + push (@cwfiles, {'file' => $cwfile, 'nocomment' => $comment_delim}); + } else { die "$cwfile is not readable" unless $optional; } @@ -103,16 +104,16 @@ for $cwfile (@cwfiles) { $0 = "$av0 - reading $cwfile"; - if (open(CW, "<$cwfile")){ + if (open(CW, "<$cwfile->{'file'}")){ while (){ - next if /^\#/; + next unless /^$cwfile->{'nocomment'}/; $thishost = $_; - chop($thishost); + chomp($thishost); push(@hosts, $thishost) unless $thishost =~ $hostname; } close(CW); } else { - die "open $cwfile: $!"; + die "open $cwfile->{'file'}: $!"; } } }