aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2013-10-01 16:36:05 -0400
committerjim-p <jimp@pfsense.org>2013-10-01 16:36:30 -0400
commite9a1dee7011badfeb464c5b10d7721b42389858e (patch)
treeafe0750df54fab285feb7bea5c8deae52bcd1d36 /config
parent237ff43cb71026b0a912ae772a0916e69b9bdedd (diff)
downloadpfsense-packages-e9a1dee7011badfeb464c5b10d7721b42389858e.tar.gz
pfsense-packages-e9a1dee7011badfeb464c5b10d7721b42389858e.tar.bz2
pfsense-packages-e9a1dee7011badfeb464c5b10d7721b42389858e.zip
Add e-mail capability to the arpwatch package. Only works on 2.1+
Diffstat (limited to 'config')
-rw-r--r--config/arpwatch.xml26
-rw-r--r--config/sm.php41
2 files changed, 63 insertions, 4 deletions
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 @@
/* ========================================================================== */
]]>
</copyright>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
+ <description>ARP Monitoring Daemon</description>
+ <requirements>None</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>arpwatch</name>
- <version>2.1.a13</version>
+ <version>2.1.a14 pkg v1.1</version>
<title>arpwatch: Settings</title>
<aftersaveredirect>pkg_edit.php?xml=arpwatch.xml&amp;id=0</aftersaveredirect>
<menu>
@@ -77,6 +77,11 @@
<chmod>a+rx</chmod>
<item>http://www.pfsense.com/packages/config/arpwatch_reports.php</item>
</additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/sbin/</prefix>
+ <chmod>a+rx</chmod>
+ <item>http://www.pfsense.com/packages/config/sm.php</item>
+ </additional_files_needed>
<fields>
<field>
<fielddescr>Listening Interface</fielddescr>
@@ -84,11 +89,18 @@
<description>Choose the desired listening interface here.</description>
<type>interfaces_selection</type>
</field>
+ <field>
+ <fielddescr>Enable E-mail Notifications</fielddescr>
+ <fieldname>enable_email</fieldname>
+ <type>checkbox</type>
+ <description>Sends an E-mail notification for each new station and ARP change as they are seen.&lt;br/&gt;NOTE: Only works on pfSense 2.1 or later.&lt;br/&gt;Configure SMTP and address settings in System &gt; Advanced on the Notifications tab</description>
+ </field>
</fields>
<custom_php_global_functions>
<![CDATA[
function sync_package_arpwatch() {
global $config;
+ $pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
conf_mount_rw();
config_lock();
$log_file = "/var/log/arp.dat";
@@ -97,9 +109,14 @@
} else {
$int = $config['installedpackages']['arpwatch']['config'][0]['interface'];
}
+ $mail = "";
+ if(($pf_version > 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>&amp;1 &amp;";
+ $start .= "/usr/local/sbin/arpwatch -d -f {$log_file} -i {$int} {$mail} > /var/log/arpwatch.reports 2>&amp;1 &amp;";
$stop = "/usr/bin/killall arpwatch";
write_rcfile(array(
"file" => "arpwatch.sh",
@@ -121,6 +138,7 @@
<custom_php_install_command>
<![CDATA[
unlink_if_exists("/usr/local/etc/rc.d/arpwatch.sh");
+ @link("/usr/sbin/sm.php", "/usr/sbin/sendmail");
]]>
</custom_php_install_command>
</packagegui>
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
+<?php
+require_once("config.inc");
+require_once("globals.inc");
+require_once("notices.inc");
+
+$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
+if (($pf_version < 2.1)) {
+ $error = "Sending e-mail on this version of pfSense is not supported. Please use pfSense 2.1 or later";
+ log_error($error);
+ echo "{$error}\n";
+ return;
+}
+
+$options = getopt("s::");
+
+$message = "";
+
+if($options['s'] <> "") {
+ $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