Update of /cvsroot/netpass/NetPass-Snort/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4698
Modified Files:
npsnortd.pl
Log Message:
Index: npsnortd.pl
===================================================================
RCS file: /cvsroot/netpass/NetPass-Snort/bin/npsnortd.pl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- npsnortd.pl 10 Aug 2005 20:14:50 -0000 1.1.1.1
+++ npsnortd.pl 16 Aug 2005 21:23:28 -0000 1.2
@@ -70,8 +70,9 @@
my $DEFAULTPORT = 20008;
my $DEFAULTSNORTLOG = "/opt/snort/logs/snort.log";
my $TIMEOUT = 300;
+my $DEFAULTSNORTPID = "/var/run/snort_dag0.pid";
-getopts('s:S:p:P:r:l:f:t:qDh?', \%opts);
+getopts('s:S:p:P:r:l:f:t:b:qDh?', \%opts);
pod2usage(2) if exists $opts{'h'} || exists $opts{'?'};
pod2usage(2) if !exists $opts{'s'} || !exists $opts{'S'};
@@ -98,7 +99,21 @@
# process snort logs from here on in
my $logfile = (exists $opts{'l'}) ? $opts{'l'} : $DEFAULTSNORTLOG;
-die "Unable to open $logfile" unless -e $logfile;
+
+if (!-e $logfile) {
+ # if logfile doesnt exist touch it
+ my $fh = new FileHandle("> $logfile");
+ $fh->close();
+
+ my $pidfile = (exists $opts{'p'}) ? $opts{'p'} : $DEFAULTSNORTPID;
+ if (-e $pidfile) {
+ my $fh = new FileHandle($pidfile);
+ my $pid = $fh->getline;
+ $fh->close;
+ chomp $pid;
+ kill(0, $pid) if $pid =~ /^\d+$/;
+ }
+}
my $fh = new File::Tail (
name => $logfile,
|