Thijs Kinkhorst wrote:
> First, I think it's always a good idea not to enable DEBUG by default.
Sure, it's a mistake, I perfectly understand this.
> Second, I don't think that it requires a "rewrite of the entire file" to fix
> it. Using PHP's tempnam() function to get the filenames instead of the
> hardcoded path names with PID is a change of just a few lines.
Did you mean Perl mktemp()? It's not a PHP script!!! :) That makes me
think that I might have missed some Perl dependencies. The script uses
the following:
use strict;
use MIME::Tools;
use MIME::Parser;
use File::MkTemp;
does any of you knows what it corresponds in terms of Debian deps?
Last, would a patch like the attached one would do? I'm all but good in
Perl, so I might need help on that one.
Thank you all for your time on this issue,
Cheers,
Thomas
diff --git a/admin/sa-wrapper b/admin/sa-wrapper
index 76a2ddd..67ee4dc 100755
--- a/admin/sa-wrapper
+++ b/admin/sa-wrapper
@@ -15,8 +15,9 @@
use strict;
use MIME::Tools;
use MIME::Parser;
+use File::MkTemp;
-my $DEBUG = 1;
+my $DEBUG = 0;
my $UNPACK_DIR = '/var/lib/amavis/tmp';
my $SA_LEARN = '/usr/bin/sa-learn';
# my @DOMAINS = qw/example.com example.org/;
@@ -47,8 +48,8 @@ sub recurs
if ($ent->head->mime_type eq 'message/rfc822') {
if ($DEBUG) {
- unlink "/tmp/spam.log.$$" if -e "/tmp/spam.log.$$";
- open(OUT, "|$SA_LEARN -D --$spamham --single >>/tmp/spam.log.$$ 2>&1") or die "Cannot pipe $SA_LEARN: $!";
+ $debug_file = mktemp("/tmp/sa-wrapper.XXXXXX.log");
+ open(OUT, "|$SA_LEARN -D --$spamham --single >>$debug_file 2>&1") or die "Cannot pipe $SA_LEARN: $!";
} else {
open(OUT, "|$SA_LEARN --$spamham --single") or die "Cannot pipe $SA_LEARN: $!";
}
@@ -73,7 +74,8 @@ unless (grep { $_ eq $domain } @DOMAINS) {
if ($DEBUG) {
MIME::Tools->debugging(1);
- open(STDERR, ">/tmp/spam_err.log");
+ $debug_file2 = mktemp("/tmp/sa-wrapper.XXXXXX");
+ open(STDERR, ">$debug_file2");
}
my $parser = new MIME::Parser;
$parser->extract_nested_messages(0);