[Netpass-devel] NetPass-Snort/lib/NetPass Snort.pm,1.3,1.4
Brought to you by:
jeffmurphy
From: rcolantuoni <rco...@us...> - 2006-01-05 17:26:17
|
Update of /cvsroot/netpass/NetPass-Snort/lib/NetPass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7539/NetPass-Snort/lib/NetPass Modified Files: Snort.pm Log Message: modified snortRestart() to do a stop/start, since a HUP will fail when the snort buffer does not contain a large enough amount of data. Index: Snort.pm =================================================================== RCS file: /cvsroot/netpass/NetPass-Snort/lib/NetPass/Snort.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Snort.pm 4 Jan 2006 16:02:09 -0000 1.3 +++ Snort.pm 5 Jan 2006 17:26:06 -0000 1.4 @@ -223,52 +223,13 @@ my %opts = %::opts; my $fh = new FileHandle; - return undef unless exists $opts{'S'}; - my $md5 = md5_hex(hostip.$opts{'S'}); - - return undef unless ($self->$check_soap_auth($key)); return undef unless ($self->$snortRunning()); - my $pid = $self->$snortGetPid(); - return undef unless $pid; - - my $soap = $self->$createSoapConnection(); - return undef unless $soap; - - my $aref = eval {$soap->getSnortRules( - -secret => $md5, - -type => "enabled", - )->result}; - return undef unless defined($aref) && (ref($aref) eq 'ARRAY'); - - my $rulesfile = (exists $opts{'r'}) ? $opts{'r'} : $DEFAULTSNORTRULES; - - # create a backup copy of the rules file - my $backupfile = $rulesfile.'.bkp'; - move($rulesfile, $backupfile) if (-e $rulesfile); - - $fh->open("> $rulesfile"); - foreach my $l (@$aref) { - chomp $l; - $l =~ s/\r\n/ /g; - print $fh $l."\n"; - } - $fh->close; - - # test the rules file - my $testcmd = (exists $opts{'T'}) ? $opts{'T'} : $DEFAULTSNORTTESTSCRIPT; - my $testoutput = qx($testcmd 2>&1); - if( $testoutput =~ /Fatal Error/gm) { - # we came across a Fatal Error! - # restore the backup copy of the rules file - move($backupfile, $rulesfile) if (-e $backupfile); - return undef; - } + $self->stopSnort($key, %opts); + sleep(2); + $self->startSnort($key, %opts); - $self->$update_pcap_rules_file($md5, $soap); - - return 1 if (kill('HUP', $pid) > 0); - return undef; + return undef; } =head2 $rv = snortStatus() |