MS + Trend InterScan Virus Wall

Gerry Doris gdoris at ROGERS.COM
Sat Nov 29 20:19:15 GMT 2003


On Sat, 29 Nov 2003, Julian Field wrote:

> Okay, thanks for that.
> Please try changing the trend line in /etc/MailScanner/virus.scanners.conf
> to this:
> trend           /usr/lib/MailScanner/trend-wrapper      /etc/iscan
>
> and use the attached trend-wrapper and trend-autoupdate (make them
> executable and put them in /usr/lib/MailScanner).
>
> Then try
>          cd /tmp
>          /usr/lib/MailScanner/trend-wrapper /etc/iscan /tmp
> and
>          /usr/lib/MailScanner/trend-autoupdate
> and check they both work okay.

I had made the exact change to trend-wrapper months ago and it has been
working correctly.

I wrote my own version of trend-autoupdate that works correctly.  The one
you sent me generates an error at line 40.  The actual output is:

Checking for latest DAT version...
./trend-autoupdate: line 40: [: irlpt9: integer experssion expected
DAT files are up to date

Also, running update_virus_scanners does not provide an entry in the
maillog to say whether the Trend files are up to date or were updated etc.

I've attached my version of trend-autoupdate if you're interested.  It's
been working fine for me.

--
Gerry

"The lyfe so short, the craft so long to learne"  Chaucer

-------------- next part --------------
#!/usr/bin/perl -w

use Sys::Syslog;
use File::Copy;
$LockFile = "/tmp/TrendBusy.lock";
$TIMEOUT = 300;                         #Timeout in sec's
$LOCK_EX = 2;
$LOCK_UN = 8;

unless (-e "/etc/iscan/tmp" && -d "/etc/iscan/tmp") {
mkdir "/etc/iscan/tmp";
}

$PREFIX = "/etc/iscan/tmp";

eval {Sys::Syslog::setlogsock('unix'); };
Sys::Syslog::openlog("Trend-Autoupdate", 'pid, nowait', 'mail');

$SIG{ALRM} = sub { die "timeout" };     # Setup timer

eval {					# Start timer
alarm("$TIMEOUT");
unlink glob("$PREFIX/pattern.asp*");
$retval = system("cd $PREFIX; wget -s http://www.trendmicro.com/download/pattern.asp > /dev/null 2>&1")>>8;
if ($retval == 1 ) {
        Sys::Syslog::syslog('err', "Unable to reach Trend website");
	Sys::Syslog::closelog();
	exit 1;
}
open(PATTERN, "$PREFIX/pattern.asp") or die "Unable to open pattern file: $!";
while (<PATTERN>) {
	if ( $_ =~ /(ptn[0-9]*\.tar)/) {
	$file = $1;
	}
}
close PATTERN;

if (-e "$PREFIX/$file") {
	unlink glob("$PREFIX/pattern.asp*");
        Sys::Syslog::syslog('info', "Trend did not need updating");
        Sys::Syslog::closelog();
	exit 0;
}
else {
        &LockTrend();
	$retval = system("cd $PREFIX; wget http://www.trendmicro.com/ftp/products/pattern/$file > /dev/null 2>&1")>>8;
	if ($retval == 1 ) {
		unlink glob("$PREFIX/*tar");
	        Sys::Syslog::syslog('err', "Trend updater failed");
		Sys::Syslog::closelog();
		&UnlockTrend();
		exit 1;
	}
}

alarm(0);                               #Turn off alarm
};					#End timer 

if ($@ =~ /timeout/) {
&UnlockTrend();         
unlink glob("$PREFIX/*tar");  
Sys::Syslog::syslog('err', "Trend updater timed out");
Sys::Syslog::closelog();
exit 1;
} 

$retval = system("cd $PREFIX; tar xf $PREFIX/$file")>>8;

if ($retval == 0 ) {			# cleanup and finish
	unlink glob("/etc/iscan/lpt*"), "$PREFIX/WHATSNEW\.TXT", glob("$PREFIX/pattern.asp*");  
	move (glob("$PREFIX/lpt*"), "/etc/iscan");
	@oldtar = glob("$PREFIX/*tar*");
	foreach $item (@oldtar) {
		if ($item ne "$PREFIX/$file") {
		unlink $item;
		}
	}

}
elsif ($retval == 1 ) {
	unlink glob("$PREFIX/*tar*");  
        Sys::Syslog::syslog('err', "Trend failed - could not untar file");
	Sys::Syslog::closelog();
	&UnlockTrend();
	exit 1;
}

Sys::Syslog::syslog('info', "Trend updated");
Sys::Syslog::closelog();
&UnlockTrend();         
exit; 

sub LockTrend {
	open(LOCK, ">$LockFile") or return;
	flock(LOCK, $LOCK_EX);
	print LOCK "Locked for updating Trend definitions by $$\n";
}

sub UnlockTrend {
	print LOCK "Unlocked after updating Trend definitions by $$\n";
	unlink $LockFile;
	flock(LOCK, $LOCK_UN);
	close LOCK;
}


More information about the MailScanner mailing list