From 504838113451d91e88142dd3216d0c914b6275da Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 12:30:16 +0200 Subject: arpwatch - code style cleanup - Fix copyright header - Fix chmod - Remove obsolete pfSense version check - Code style cleanup --- config/arpwatch/arpwatch.xml | 75 ++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 31 deletions(-) (limited to 'config/arpwatch') diff --git a/config/arpwatch/arpwatch.xml b/config/arpwatch/arpwatch.xml index a40422d4..820d397d 100644 --- a/config/arpwatch/arpwatch.xml +++ b/config/arpwatch/arpwatch.xml @@ -1,28 +1,30 @@ - - + + ARP Monitoring Daemon - None - Currently there are no FAQ items provided. arpwatch - 2.1.a14 pkg v1.1.1 + 1.1.2 arpwatch: Settings pkg_edit.php?xml=arpwatch.xml&id=0 @@ -71,12 +71,12 @@ installedpackages->package->$packagename->configuration->settings /usr/local/www/ - a+rx + 0755 https://packages.pfsense.org/packages/config/arpwatch/arpwatch_reports.php /usr/sbin/ - a+rx + 0755 https://packages.pfsense.org/packages/config/arpwatch/sm.php @@ -90,33 +90,45 @@ Enable E-mail Notifications enable_email checkbox - Sends an E-mail notification for each new station and ARP change as they are seen <strong>instead of</strong> local reports.<br/>NOTE: Only works on pfSense 2.1 or later. <br/>NOTE 2: Disables local reports which rely on arpwatch debug mode, which does not work with e-mail notifications.<br/>Configure SMTP and address settings in System > Advanced on the Notifications tab + + , instead of local reports.
+ NOTE: Disables local reports which rely on arpwatch debug mode, which does not work with e-mail notifications.
+ 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'])) + if (isset($_POST['enable_email']) || ($config['installedpackages']['arpwatch']['config'][0]['enable_email'] == "on")) { + if (!empty($config['notifications']['smtp']['notifyemailaddress'])) { $mail = " -m \"{$config['notifications']['smtp']['notifyemailaddress']}\""; + } } else { $debug = "-d"; } + + /* Listening interface setup */ + if ($_POST['interface'] != "") { + $int = $_POST['interface']; + } else { + $int = $config['installedpackages']['arpwatch']['config'][0]['interface']; + } $int = convert_friendly_interface_to_real_interface_name($int); - $start = "touch {$log_file}\n"; - $start .= "/usr/local/sbin/arpwatch {$debug} -f {$log_file} {$mail} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; + + /* Create init script */ + $start = "/usr/bin/touch {$log_file}\n"; + $start .= "/usr/local/sbin/arpwatch {$debug} -f {$log_file} {$mail} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; $stop = "/usr/bin/killall arpwatch"; write_rcfile(array( "file" => "arpwatch.sh", @@ -124,6 +136,7 @@ "stop" => $stop ) ); + restart_service("arpwatch"); conf_mount_ro(); config_unlock(); -- cgit v1.2.3 From ae7156d6dc0bb528f423844f989e552b13bed7bd Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 12:39:17 +0200 Subject: arpwatch - code style cleanup - Add missing copyright header - Remove obsolete pfSense version check - Code style cleanup --- config/arpwatch/sm.php | 54 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'config/arpwatch') diff --git a/config/arpwatch/sm.php b/config/arpwatch/sm.php index 2e1cc4a0..4df6cead 100644 --- a/config/arpwatch/sm.php +++ b/config/arpwatch/sm.php @@ -1,33 +1,49 @@ #!/usr/local/bin/php -q "") { +if ($options['s'] <> "") { $subject = $options['s']; } - $in = file("php://stdin"); -foreach($in as $line){ +foreach ($in as $line) { $line = trim($line); - if ( (substr($line, 0, 6) == "From: ") - || (substr($line, 0, 6) == "Date: ") - || (substr($line, 0, 4) == "To: ")) + 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; @@ -35,8 +51,10 @@ foreach($in as $line){ $message .= "$line\n"; } -if (!empty($subject)) +if (!empty($subject)) { send_smtp_message($message, $subject); -else +} else { send_smtp_message($message); -?> \ No newline at end of file +} + +?> -- cgit v1.2.3 From 8d58afa8470e67d59be7e8e6be3f7344bb2b3e15 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 13:03:41 +0200 Subject: arpwatch - code style cleanup - Fix copyright header - Fix nanobsd - Code style - Fix XHTML --- config/arpwatch/arpwatch_reports.php | 132 +++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 62 deletions(-) (limited to 'config/arpwatch') diff --git a/config/arpwatch/arpwatch_reports.php b/config/arpwatch/arpwatch_reports.php index 9b3b1c6c..c1ab376f 100755 --- a/config/arpwatch/arpwatch_reports.php +++ b/config/arpwatch/arpwatch_reports.php @@ -1,61 +1,65 @@ #!/usr/local/bin/php $newmac, - "timestamp" => trim($todo[2]), - "hostname" => trim($todo[3]) ? trim($todo[3]) : "Unknown" - ); + $report[$todo[1]][] = array( + "mac" => $newmac, + "timestamp" => trim($todo[2]), + "hostname" => trim($todo[3]) ? trim($todo[3]) : "Unknown" + ); unset($mac); } } + $pgtitle = "arpwatch: Reports"; include("head.inc"); @@ -64,23 +68,23 @@ include("head.inc"); - - + - - - +
+
-
-
- - - - + + + + - + + + +
arp.dat entries
+
+ + + + @@ -88,14 +92,14 @@ include("head.inc"); $rawentries) { + if ($report) { + foreach ($report as $ip => $rawentries) { $printip = true; $entries = $rawentries; sort($entries); - foreach($entries as $entry) { + foreach ($entries as $entry) { echo ''; - if($printip) { + if ($printip) { echo ''; $stampclass = "listr"; $printip = false; @@ -111,17 +115,21 @@ include("head.inc"); echo ''; } } + } ?> - - - -
arp.dat entries
IP TimestampHostname
' . $ip . '
-
-
- -
-
-
-
+
+
+ +
+
+
+
+ + + -- cgit v1.2.3 From 3d8da8dc48375bde828af21bbbe8b3a0612b2fdd Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 11 Aug 2015 01:51:46 +0200 Subject: arpwatch.xml - remove useless config_(un)lock calls --- config/arpwatch/arpwatch.xml | 2 -- 1 file changed, 2 deletions(-) (limited to 'config/arpwatch') diff --git a/config/arpwatch/arpwatch.xml b/config/arpwatch/arpwatch.xml index 820d397d..2a2045c7 100644 --- a/config/arpwatch/arpwatch.xml +++ b/config/arpwatch/arpwatch.xml @@ -104,7 +104,6 @@ function sync_package_arpwatch() { global $config; conf_mount_rw(); - config_lock(); $log_file = "/var/log/arp.dat"; /* E-mail notifications setup */ @@ -139,7 +138,6 @@ restart_service("arpwatch"); conf_mount_ro(); - config_unlock(); } ]]>
-- cgit v1.2.3 From 3293747df8c455a8e31d81d059694a7a5a1e498d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 11 Aug 2015 02:37:51 +0200 Subject: arpwatch.xml - add custom_php_resync_config_command --- config/arpwatch/arpwatch.xml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'config/arpwatch') diff --git a/config/arpwatch/arpwatch.xml b/config/arpwatch/arpwatch.xml index 2a2045c7..aa6a9ae8 100644 --- a/config/arpwatch/arpwatch.xml +++ b/config/arpwatch/arpwatch.xml @@ -152,4 +152,9 @@ @link("/usr/sbin/sm.php", "/usr/sbin/sendmail"); ]]> + + + -- cgit v1.2.3