[cvs] bogofilter/contrib bogopass,1.3,1.4
Matthias Andree
matthias.andree at gmx.de
Wed Dec 4 00:05:58 CET 2002
allyn at users.sourceforge.net writes:
> Update of /cvsroot/bogofilter/bogofilter/contrib
> In directory sc8-pr-cvs1:/tmp/cvs-serv2105
>
> Modified Files:
> bogopass
> Log Message:
> fixed to output original message, which is the whole point of
> bogopass.
My fault, please apologize. I saw that a failure to launch unbase64 went
away unnoticed, and moved it up front -- which was wrong...
Some detailed comments below:
> --- bogopass 28 Nov 2002 03:32:47 -0000 1.3
> +++ bogopass 3 Dec 2002 07:59:08 -0000 1.4
> @@ -1,4 +1,4 @@
> -#! /usr/bin/env perl
> +#!/usr/bin/perl
This trick makes sure it works with perl anywhere on the $PATH, not just
/usr/bin. FreeBSD 5 might fail unless we use env.
> my ($fh, $fn) = tempfile("/tmp/$PROG.XXXXXXXXXX");
> -open P, "|unbase64 >\"$fn\"" or my_die "Can't pipe to unbase64: $?";
> while (<STDIN>) {
> - print P $_ or my_die("Error writing to unbase64 pipe: " . parsewait($?));
> + print $fh $_ or my_die("Error writing to temporary file $fn: " . parsewait($?));
> }
> -close P or my_die("Error writing to unbase64 pipe: " . parsewait($?));
> +close $fh or my_die("Error closing temporary file $fn: " . parsewait($?));
We must not close the file handle yet, unlink0 needs it below.
>
> my $options = join ' ', @ARGV;
> -my $bogo_header = `bogofilter -v $options <$fn`;
> +my $bogo_header = `unbase64 <"$fn" | bogofilter -v $options`;
I've tried some tricks to figure a failure to start unbase64, but at
least my bash will happily launch bogofilter even when it cannot start
unbase64 -- so we need to catch the unbase64 failure explicitly.
> -system("formail -I \"$bogo_header\" < $fn") == 0 or
> +system("formail -I \"$bogo_header\" < \"$fn\"") == 0 or
> my_die "formail failed ($?)";
Yup, good catch; but $fn ought to be safe as long as $PROG will not
contain blanks or shell meta characters. I didn't see this one though,
good that you fixed it. Robustness is never wrong unless you must crack
your own system for some reason ;-)
--
Matthias Andree
More information about the bogofilter-dev
mailing list