+sa-learn(1) support.
authorshort <>
Tue, 27 Jul 2004 07:25:57 +0000 (07:25 +0000)
committershort <>
Tue, 27 Jul 2004 07:25:57 +0000 (07:25 +0000)
Workarounded closing of stderr for spawned processes corrupting inetd() access.

perlmail-accept

index c4fa61e..9a8584b 100755 (executable)
@@ -130,8 +130,8 @@ sub inetd
                $length==($_=read STDIN,$message,$length) or confess "Got $_ out of required $length bytes";
                $length==length $message or confess "False read return ".length($message)." instead of $length";
                {
-                       local *STDOUT;
-                       local *STDERR;
+                       local *STDOUT;  # FIXME: fd's inherited by spawned processes are not closed this way!
+                       local *STDERR;  # FIXME: fd's inherited by spawned processes are not closed this way!
                        local $DoBell=0;
                        process $message;
                        if ($DoBell) {
@@ -489,12 +489,16 @@ my($message)=@_;
 # return: true (error-message or "1") if is spam
 sub spamassassin
 {
+my($cmd)=@_;
+
+       $cmd||="spamassassin --exit-code";
        # spamassassin has exit code 1 if IS spam, code 0 if NOT spam
        local *CHILD;
        local $SIG{"PIPE"}=sub { warn "spamassassin gave me SIGPIPE: broken pipe"; };
        # prevent Razor2's: Can't call method "log" on unblessed reference at Razor2/Client/Agent.pm line 212.
        local $ENV{"HOME"}=$HOME;
-       open CHILD,'|spamassassin --exit-code --mbox >/dev/null'
+       # 2>/dev/null to prevent error messages to corrupt inetd() output of perlmail-accept(1)
+       open CHILD,"|$cmd --mbox >/dev/null 2>/dev/null"
                        or return 0;
        print CHILD $Message;
        my $return=close CHILD;