On May 4, 2004, at 3:42 PM, Pete McNeil wrote:
Every rulebase is potentially a different size & composition, plus sizes typically change with each update. I'm glad to hear all the positive reports on this. :-)
I updated my perl program that does fail-safe (at least on unix-like systems) fetch to honor gzip if we get it (ie, it doesn't *assume* it gets gzipped content in case on day it is accidentally turned off). This updates my sample script on the sniffer web site.
--cut here-- #! /usr/bin/perl -wT use strict;
# fetch the updated rules file from SortMonster's web site and safely # update the local copy if it passes self-integrity test. keep one old # file as backup.
# Time-stamp: "03 May 2004, 11:31:44 ([EMAIL PROTECTED])"
# private license/key pair my ($license,$key) = qw(sample abcdef123456);
# directory where to put the resulting file. snf2check should be there too
my $dir = '.';
# credentials for remote site my ($login,$password) = qw(sniffer ki11sp8m);
### ### The rest should not require any changes. ###
my $host = 'www.sortmonster.net:80'; # file to fetch my $url = "http://$host/Sniffer/Updates/${license}.snf";
# Ensure gzip can be found
$ENV{PATH} = '/usr/bin:/usr/local/bin';chdir($dir) or die "unable to change directory to $dir";
use LWP::UserAgent; use HTTP::Request::Common;
my $tmpfile = "${license}.tmp.$$";$SIG{INT} = $SIG{TERM} = sub { die "killed."; };
$SIG{__DIE__} = sub { unlink $tmpfile, "${tmpfile}.gz"; };my $ua = new LWP::UserAgent or die "unable to create user agent";
$ua->credentials($host,'SortMonster',$login,$password);
my $response = $ua->request(HEAD $url); die "Error while stating ", $response->request->uri, " -- ", $response->status_line, "\nAborting" unless $response->is_success;
# check if newer than our copy...
if ( -f "${license}.snf" ) {
my $current_age = (stat "${license}.snf")[9];
if ($response->last_modified <= $current_age) {
# remote file older, no point fetching it again
exit(0);
}
}# now stick the result into a temp file
$response = $ua->request(GET($url,'Accept-Encoding' => 'gzip'),$tmpfile);
die "Error while getting ", $response->request->uri,
" -- ", $response->status_line, "\nAborting"
unless $response->is_success;
# Check if file came in compressed, and uncompress it.
if ($response->header('Content-Encoding')
and $response->header('Content-Encoding') eq 'gzip') {
rename $tmpfile, "${tmpfile}.gz" or die "rename failure: $!";
system ('gzip','-d','-q',"${tmpfile}.gz") == 0
or die "failure to execute gzip to uncompress: $!";
my $exitvalue = $? >> 8;
my $sig = $? & 127; if ($exitvalue or $sig) {
die "error running gzip decompression: exit $exitvalue\n";
}
}system('./snf2check.exe',$tmpfile,$key) == 0
or die "failure to execute snf2check: $!";my $exitvalue = $? >> 8; my $sig = $? & 127;
if ($exitvalue or $sig) {
die "error running snf2check: exit $exitvalue\n";
} else {
# keep old file just in case...
unlink "${license}.snf.old";
link "${license}.snf","${license}.snf.old"; rename $tmpfile, "${license}.snf";
}exit(0); --cut here--
smime.p7s
Description: S/MIME cryptographic signature
