Sophos-autoupdate on FreeBSD
Martin Hepworth
maxsec at TOTALISE.CO.UK
Tue Jun 10 14:09:08 IST 2003
Marco Obaid wrote:
> Hi Martin,
>
>
>>If you want my version, or Julian wants me to create a patch file then
>>let me know..
>
>
> Would you please send me your copy?
>
> On a related topic, Sophos has two versions for FreeBSD. I used
> freebsd.elf.tar.Z but there is a note in the manual about:
> "FreeBSD 4 and above: you may need to install the FreeBSD version 3.x
> compatibility libraries on your system." But they do not tell you how to
> install this compatibility library. Did you have to install it?
>
> Can I install the linux version of Sophos on FreeBSD? I tried it and it seemed
> to be working. However, I have not been able to get sophos-autoupdate to work.
>
> Thank you
> Marco
>
>
> _________________________________________________________________
> This mail is sent through MUW Webmail: http://www.MUW.Edu/webmail
> For the latest MUW Events, visit http://www.MUW.Edu/calendar
marco
the elf one should work fine without anything else..run the sweep
command on a directory to prove it.
You'll also need to run the Sophos.install script beforehand to put
Sophos where MS expects it.
--
Martin
-------------- next part --------------
#!/usr/bin/perl
use Sys::Syslog;
$SophosRoot = "/usr/local/Sophos";
$IDELink = "$SophosRoot/ide";
$VDLDir = "../lib";
#$Lynx = "/usr/local/bin/lynx -dump";
$Lynx = "/usr/bin/wget -q -O-"; # On Linux use this
$Unzip = "/usr/bin/unzip -joqq";
$rm = "/bin/rm";
$LockFile = "/tmp/SophosBusy.lock";
$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;
Sys::Syslog::openlog("Sophos-autoupdate", 'pid, nowait', 'mail');
# Work out the current VDL (and hence Sophos Sweep) version number
chdir "$SophosRoot/bin/$VDLDir";
opendir(LIBDIR, ".") || &BailOut("Cannot open Sophos/lib directory");
foreach $vdlname (sort readdir(LIBDIR)) {
next unless $vdlname =~ /^vdl-(\d+)\.(\d+)([a-z]?)\.dat$/;
$MajorVer = $1;
$MinorVer = $2;
$NSVFlag = $3;
}
closedir(LIBDIR);
&BailOut("Could not calculate Sophos version number")
unless defined($MajorVer) && defined($MinorVer);
$SophosVersion = "$MajorVer$MinorVer";
$VDLVersion = "$MajorVer.$MinorVer";
# Derive other variables, filenames and URLs from the version numbers
$ZipName = $SophosVersion . "_ides.zip";
$URL = "http://www.sophos.com/downloads/ide/$ZipName";
($min,$hour,$date,$month,$year) = (localtime)[1,2,3,4,5];
$month++;
$year+=1900;
$IDEDir = $SophosRoot. "/idenew";
# If the directory already exists, then we have already done the update
# for today, so quietly exit.
Sys::Syslog::syslog('info', "Sophos already up-to-date"),exit 0 if -d $IDEDir;
umask 0022;
mkdir $IDEDir, 0755;
chdir $IDEDir or &BailOut("Cannot cd $IDEDir, $!");
# Fetch and unpack the IDE zip file from Sophos
#print STDERR "URL is $URL\n";
$result = system("$Lynx $URL > $ZipName");
if (($result>>8)==1) {
Sys::Syslog::syslog('err', "Your Sophos installation may be too old. Please install the latest release of Sophos");
print STDERR "Your Sophos installation may be too old. Please install the latest release of Sophos";
}
&BailOut("Lynx failed with error return " . ($result>>8) . "\n") if $result>>8;
$result = system("$Unzip $ZipName");
if ($result>>8) {
Sys::Syslog::syslog('err', "Unzipping the new Sophos IDE files failed. This may well be because your Sophos installation is too old. Please install the latest release of Sophos");
print STDERR "Unzipping the new Sophos IDE files failed. This may well be because your Sophos installation is too old. Please install the latest release of Sophos";
&BailOut("Unzip failed with error return " . ($result>>8) . "\n");
}
symlink("$VDLDir/vdl-$VDLVersion$NSVFlag.dat", "vdl.dat");
# Add the new vdl*.vdb files if they are there
foreach $number (1..99) {
$string = "vdl" . sprintf("%02d", $number) . ".vdb";
symlink("$VDLDir/$string", $string) if -f "$VDLDir/$string";
}
# Link in this new directory to Sophos
#chdir $SophosRoot or &BailOut("Cannot cd $SophosRoot, $!");
#$OldLinkTarget = readlink $IDELink;
&LockSophos();
$IDEold = $SophosRoot . "/ideold";
system("$rm -rf $IDEold");
rename $IDELink, $IDEold;
rename $IDEDir, $IDELink;
#unlink $IDELink if -l $IDELink;
#symlink $IDEDir, $IDELink;
&UnlockSophos();
#system("$rm -rf $OldLinkTarget") if defined $OldLinkTarget && -e $OldLinkTarget;
Sys::Syslog::syslog('info', "Sophos successfully updated in $IDEDir");
Sys::Syslog::closelog();
exit 0;
sub BailOut {
Sys::Syslog::syslog('err', @_);
Sys::Syslog::closelog();
warn "@_, $!";
chdir $SophosRoot or die "Cannot cd $SophosRoot, $!";
system("$rm -rf $IDEDir") if -d $IDEDir;
exit 1;
}
sub LockSophos {
open(LOCK, ">$LockFile") or return;
flock(LOCK, $LOCK_EX);
print LOCK "Locked for updating Sophos IDE files by $$\n";
}
sub UnlockSophos {
print LOCK "Unlocked after updating Sophos IDE files by $$\n";
unlink $LockFile;
flock(LOCK, $LOCK_UN);
close LOCK;
}
More information about the MailScanner
mailing list