From e9a1dee7011badfeb464c5b10d7721b42389858e Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 1 Oct 2013 16:36:05 -0400 Subject: Add e-mail capability to the arpwatch package. Only works on 2.1+ --- config/arpwatch.xml | 26 ++++++++++++++++++++++---- config/sm.php | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 config/sm.php diff --git a/config/arpwatch.xml b/config/arpwatch.xml index e8faa3b0..18c75029 100644 --- a/config/arpwatch.xml +++ b/config/arpwatch.xml @@ -41,11 +41,11 @@ /* ========================================================================== */ ]]> - Describe your package here - Describe your package requirements here + ARP Monitoring Daemon + None Currently there are no FAQ items provided. arpwatch - 2.1.a13 + 2.1.a14 pkg v1.1 arpwatch: Settings pkg_edit.php?xml=arpwatch.xml&id=0 @@ -77,6 +77,11 @@ a+rx http://www.pfsense.com/packages/config/arpwatch_reports.php + + /usr/sbin/ + a+rx + http://www.pfsense.com/packages/config/sm.php + Listening Interface @@ -84,11 +89,18 @@ Choose the desired listening interface here. interfaces_selection + + Enable E-mail Notifications + enable_email + checkbox + Sends an E-mail notification for each new station and ARP change as they are seen.<br/>NOTE: Only works on pfSense 2.1 or later.<br/>Configure SMTP and address settings in System > Advanced on the Notifications tab + 2.0) && (isset($_POST['enable_email']) || ($config['installedpackages']['arpwatch']['config'][0]['enable_email'] == "on"))) { + if (!empty($config['notifications']['smtp']['notifyemailaddress'])) + $mail = " -m {$config['notifications']['smtp']['notifyemailaddress']}"; + } $int = convert_friendly_interface_to_real_interface_name($int); $start = "touch {$log_file}\n"; - $start .= "/usr/local/sbin/arpwatch -d -f {$log_file} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; + $start .= "/usr/local/sbin/arpwatch -d -f {$log_file} -i {$int} {$mail} > /var/log/arpwatch.reports 2>&1 &"; $stop = "/usr/bin/killall arpwatch"; write_rcfile(array( "file" => "arpwatch.sh", @@ -121,6 +138,7 @@ diff --git a/config/sm.php b/config/sm.php new file mode 100644 index 00000000..e2c56fc4 --- /dev/null +++ b/config/sm.php @@ -0,0 +1,41 @@ +#!/usr/local/bin/php -q + "") { + $subject = $options['s']; +} + + +$in = file("php://stdin"); +foreach($in as $line){ + if ( (substr($line, 0, 6) == "From: ") + || (substr($line, 0, 6) == "Date: ") + || (substr($line, 0, 4) == "To: ")) + continue; + if (empty($subject) && (substr($line, 0, 9) == "Subject: ")) { + $subject = substr($line, 9); + continue; + } + $message .= "$line"; +} + +if (!empty($subject)) + send_smtp_message($message, $subject); +else + send_smtp_message($message); +?> \ No newline at end of file -- cgit v1.2.3