Jon_HansonMountain Dew Rules Premium Member join:2001-07-09 Gilbert, AZ |
Perl questionI'm trying to debug what's going on with qmail-scanner on my Gentoo system. The program is a Perl script and I'm only just beginning to learn Perl. Below is the section of the code that I'm looking at (the debug lines with JMH in them were added by me to see what's going on): code:
open(SA,"$spamc_binary $spamc_options < $scandir/$wmaildir/new/$file_id.spamc")||&tempfail("cannot open fo r write $scandir/$wmaildir/new/$file_id.spamc - $!"); while (<SA> ) { &debug("Read line: $_"); if ($spamc_options =~ /\-c/) { ($sa_score,$sa_max)=split(/\//,$_,2); $sa_max=~s/\n//g; } #X-Spam-Status: No, hits=2.8 required=5.0 if (/^X-Spam-Status: (Yes|No), hits=(.*) required=(.*)/) { &debug("SA (JMH): Found X-Spam-Status header."); $sa_status=1 if ($1 eq "Yes"); $sa_score=$2;$sa_max=$3; &debug("SA (JMH): sa_status: $sa_status, sa_score=$sa_score, sa_max=$sa_ma x"); } print SOUT;
The very first line should be setting up the call to spamc (SpamAssassin's front-end). I thought that the <SA> identifier in the while statement should now relate to the lines outputted by spamc. However the "Read line" debug statement I added shows that I'm just getting the lines of the message out without any SpamAssassin-added status lines. If I run the same message manually through spamc then I get SpamAssassin's headers. Does anyone have any suggestions? |
|
SteveI know your IP address
join:2001-03-10 Tustin, CA |
Steve
2003-May-17 3:02 am
Bug #1: the open() string needs a pipe at the end to indicate you're opening a process. Looks to me like it's getting confused. Suggestion #1: don't guess what is actually being opened: code:
my $cmd = "$spamc_binary $spamc_options ..."; # etc. print "Running -> {$cmd}\n"; open(SA, "$cmd |") || ...
|
|
Jon_HansonMountain Dew Rules Premium Member join:2001-07-09 Gilbert, AZ |
In the real Perl script there is a pipe at the end of the command. I guess it got stripped off when I copied it.
The line just before the first one I copied out of the script has another debug line that writes to the log exactly what is being executed. It looks correct. |
|
SteveI know your IP address
join:2001-03-10 Tustin, CA |
Steve
2003-May-17 11:26 am
OK, well, we can only work with what's in front of us.
If you run the spamc command yourself (e.g., outside of perl), do you get what you expect?
Steve |
|
Jon_HansonMountain Dew Rules Premium Member join:2001-07-09 Gilbert, AZ |
Yes. |
|
SteveI know your IP address
join:2001-03-10 Tustin, CA |
Steve
2003-May-17 1:03 pm
Which version of perl are you using, and on which platform?
Steve |
|
Jon_HansonMountain Dew Rules Premium Member join:2001-07-09 Gilbert, AZ |
I'm using Perl 5.8.0 on a Gentoo Linux system. According to qmail-scanner's Source Forge project page, it fully supports version 5.8.0 of Perl.
I did some searching on qmail-scanner's mailing list and I've seen reports of problems similar to mine. A search on Gentoo's forums didn't turn up any relevant information. |
|
SteveI know your IP address
join:2001-03-10 Tustin, CA |
to Jon_Hanson
Ok, which version of SpamAssassin, and what are the values for $spamc_binary and $spamc_options ? |
|
Jon_HansonMountain Dew Rules Premium Member join:2001-07-09 Gilbert, AZ |
SpamAssassin: 2.44 $spamc_binary='/usr/bin/spamc' $spamc_options=' -f' |
|
SteveI know your IP address
join:2001-03-10 Tustin, CA |
Steve
2003-May-17 2:26 pm
Well, I've looked at / played with the code and it all looks ok to me, so I suspect that you're running this under some qmail process that is causing permissions issues. How's this program running?
Steve |
|
sporkmedrop the crantini and move it, sister MVM join:2000-07-01 Morristown, NJ |
Also turn on logging in qmail-scanner. It's quite chatty, and either it's logs or qmail's logs will tell you what's wrong. My initial suspicion would be that the 'softlimits' line in your qmail run script is set too low. Follow the advice on the qmail-scanner page. |
|
Jon_HansonMountain Dew Rules Premium Member join:2001-07-09 Gilbert, AZ |
to Steve
said by Steve: Well, I've looked at / played with the code and it all looks ok to me, so I suspect that you're running this under some qmail process that is causing permissions issues. How's this program running?
Steve
I believe that the script runs as qmailq. What happens is that when mail comes in on my external interface this Perl script is used as a "wrapper" around the standard qmail queue program. Once it finishes running it injects the message into the normal mail queue if it didn't keep the message because of a virus. |
|
| Jon_Hanson |
to sporkme
said by sporkme: Also turn on logging in qmail-scanner. It's quite chatty, and either it's logs or qmail's logs will tell you what's wrong. My initial suspicion would be that the 'softlimits' line in your qmail run script is set too low. Follow the advice on the qmail-scanner page.
I've got the log level set above 100 so it leaves its temporary files around too. I checked my softlimit and I had it set at eight megabytes. The qmail-scanner webpage recommends anywhere from five megabytes to 11 megabytes. I set it to 11 but that doesn't seem to help. I'll delve some more into the logs to see if I can find out anything else. I'm partially using this experience to learn Perl and I must say I've learned a lot so far  . I appreciate everyone's help too. |
|
| Jon_Hanson |
Here is some more information that I've figured out. The -f option to spamc tells spamc to just dump out the original message back to stdout if something went wrong with the spamc/spamd communication. I also added debug code to print the exit code from spamc. Every time it is 18944. I'm trying to figure out what that means because it doesn't look like a nice zero. So I think that something is going wrong when spamc is doing its transaction with spamd because I'm seeing the results of the -f option (just getting the message dumped back to stdout). |
|
|
| Jon_Hanson |
I figured out what the problem was. Turning on the debug logging of spamd was all it took. The problem was that spamd was trying to create a user preference file in /var/qmail/.spamassassin/user_prefs but it didn't have permission to do that in that directory so it must have died silently. Since I have a site-wide configuration I want to use anyway, I just told spamd to ignore user preferences (the -x option). It's working fine now. Thanks everyone for the suggestions. |
|