diff options
author | robiscool <robrob2626@yahoo.com> | 2012-07-04 13:47:24 -0700 |
---|---|---|
committer | robiscool <robrob2626@yahoo.com> | 2012-07-04 13:47:24 -0700 |
commit | 7f7f469b9db5290a7357aebcbcaf76a8b8615119 (patch) | |
tree | 22f1e0c0c4ff0024ebe2adcfb436c9b14f012f56 /config/snort-dev/snort_startstop.php | |
parent | 0ab68c4441054a94cc0e53bc7cdc57eb6dfee7b4 (diff) | |
download | pfsense-packages-7f7f469b9db5290a7357aebcbcaf76a8b8615119.tar.gz pfsense-packages-7f7f469b9db5290a7357aebcbcaf76a8b8615119.tar.bz2 pfsense-packages-7f7f469b9db5290a7357aebcbcaf76a8b8615119.zip |
snort-dev, redo all code related to snort startup/stop, add snort-dev/snort_startstop.php
Diffstat (limited to 'config/snort-dev/snort_startstop.php')
-rw-r--r-- | config/snort-dev/snort_startstop.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/config/snort-dev/snort_startstop.php b/config/snort-dev/snort_startstop.php new file mode 100644 index 00000000..9bf47f59 --- /dev/null +++ b/config/snort-dev/snort_startstop.php @@ -0,0 +1,65 @@ +#!/usr/local/bin/php -f + +<?php + +require_once("/usr/local/pkg/snort/snort.inc"); +require_once("/etc/inc/config.inc"); + +if (empty($argv) || file_exists("/tmp/snort_startstop.php.pid")) { + exit(); +} + +if (!empty($_GET[snortstart]) && !empty($_GET[snortstop]) || empty($_GET[snortstart]) && empty($_GET[snortstop]) ) { + exit(); +} + + // make shure there are no dup starts + exec("/bin/echo 'Starting snort_startstop.php' > /tmp/snort_startstop.php.pid"); + + // wait until boot is done + $snort_bootupWait = function() use(&$_GET, &$g) { + $i = 0; + exec("/bin/echo {$i} > /tmp/snort_testing.sh.pid"); + while(isset($g['booting']) || file_exists("{$g['varrun_path']}/booting")) { + $i++; + exec("/usr/bin/logger -p daemon.info -i -t SnortBoot 'Snort Boot count...{$i}'"); + exec("/bin/echo {$i} > /tmp/snort_testing.sh.pid"); // remove when finnished testing + sleep(2); + } + }; + $snort_bootupWait(); + + + $snort_bootupCleanStartStop = function($type) use(&$_GET, &$g) { + + $snortstartArray = explode(',', $_GET[$type]); + + foreach($snortstartArray as $iface_pre) { + + if (!empty($iface_pre)) { + $iface = explode('_', $iface_pre); + + if( !empty($iface[0]) && !empty($iface[1]) && is_numeric($iface[2]) ) { + + if($type === 'snortstart') { Running_Start($iface[0], $iface[1], $iface[2]); } + + if($type === 'snortstop') { Running_Stop($iface[0], $iface[1], $iface[2]); } + + } + } + } + }; + + + if (!empty($_GET[snortstart])) { + $snort_bootupCleanStartStop('snortstart'); + } + if (!empty($_GET[snortstop])) { + $snort_bootupCleanStartStop('snortstop'); + } + + // important + @exec("/bin/rm /tmp/snort_startstop.php.pid"); + exit(); + +?> |