qmail-scanner causes perl error

Forum for getting help with Project Gamera, Spamassassin, Clamav, qmail-scanner and other anti-spam tools.
cormander

qmail-scanner causes perl error

Unread post by cormander »

I have a Plesk 7.1.5 installation on a RH3EL box, and qmail works fine.

I run this command:

rpm -Uvh qmail-scanner-1.24-1.rhel3.art.noarch.rpm

It finishes without error. I then start to get errors on smtp. Consider this transcript (I made the connection and pasted the input ):

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 localhost.localdomain ESMTP
helo world
mail from: corman@unstupid.com
rcpt to: corman@unstupid.com
data
subject: test
from: corman@unstupid.com

this is a test
.
250 localhost.localdomain
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US",
LC_MONETARY = "en_US",
LC_NUMERIC = "en_US",
LC_MESSAGES = "en_US",
LC_COLLATE = "en_US",
LC_TIME = "en_US",
LANG = "en_US"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
250 ok
250 ok
354 go ahead
250 ok 1103133644 qp 25535
quit
221 localhost.localdomain
Connection closed by foreign host.


after removing the qmail-scanner rpm, qmail works fine once again.

Any ideas, anyone?

Thanks,

-Corey
cormander

Unread post by cormander »

Okay, I havn't solved the issue yet, but I think I've come real close. I hope what I did her helps inspire the rest of the fixes.

As far as I understand, ART's version of qmail-scanner replaces the /var/qmail/bin/qmail-queue binary with his qmail-scanner-queue binary.

The qmail-scanner-queue is a simple C program to exec the qmail-scanner-queue.pl script. The reason I believe he does this in C, is so that the permissions of of the setuid ( 4755 ) stick with the child processes.

Anyway, I wasn't very sucessful in setting enviroment variables from his qmail-scanner-queue.c program, so I altered it a bit. I made that C program, instead, run my own script:

/var/qmail/bin/qmail-scanner-env

This reads:

#!/bin/sh

export LC_ALL=C LANGUAGE=C LC_MONETARY LC_NUMERIC=C LC_MESSAGES=C LC_COLLATE=C LC_TIME=C LANG=C

/var/qmail/bin/qmail-scanner-queue.pl

And it looks like this on the filesystem:

-rwsr-xr-x 1 qmailq qmail 147 Dec 16 07:28 /var/qmail/bin/qmail-scanner-env

So now when i telnet to localhost and do the SMTP routines, I get this:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 localhost.localdomain ESMTP
helo world
mail from: corman@unstupid.com
rcpt to: corman@unstupid.com
data
subject: test
from: corman@unstupid.com

this is a test
. 250 localhost.localdomain
250 ok
250 ok
354 go ahead
/bin/rm: cannot remove `/var/spool/qmailscan/tmp/localhost.localdomain11032181336802695/': Permission denied

I believe this is happening on line 1763 of qmail-scanner-queue.pl, which reads:

system("$rm_binary -rf $ENV{'TMPDIR'}/ $scandir/$wmaildir/new/$file_id") if ($DEBUG < 100 && $file_id ne "");

Anyone got any ideas?

Thanks

-Corey
cormander

Unread post by cormander »

I finally decided to give it a shot with the C code, and forget the whole shell script workaround.

I was able to set all the env variable to "C", and this is the code that did it:

The issue appears to be solved for me now. Hope this helps others with the same problem.

/*
*
* Compile via "cc -o qmail-scanner-queue qmail-scanner-queue.c"
* and install as /var/qmail/bin/qmail-scanner-queue
* chown qscand:qscand /var/qmail/bin/qmail-scanner-queue
* chmod 4755 /var/qmail/bin/qmail-scanner-queue
*
* Then change the first line of /var/qmail/bin/qmail-scanner-queue.pl
* to "#!/usr/bin/perl" and "chmod 0755 /var/qmail/bin/qmail-scanner-queue.pl"
*
*/
#define REAL_PATH "/var/qmail/bin/qmail-scanner-queue.pl"
main(ac, av)
char **av;
{

int i, e;

for ( i = 2; av != '\0'; i++ );

for ( e = i; e > 1; e-- ) {

av[e+8] = av[e];

//printf("%s becomes %s\n", av[e], av[e+8]);

}

av[2] = "LC_ALL=C";
av[3] = "LANGUAGE=C";
av[4] = "LC_MONETARY";
av[5] = "LC_NUMERIC=C";
av[6] = "LC_MESSAGES=C";
av[7] = "LC_COLLATE=C";
av[8] = "LC_TIME=C";
av[9] = "LANG=C";

execv(REAL_PATH, av);

}
Post Reply