From 132e2e1c9f843d45740e13c3f6a5ab6c2203992e Mon Sep 17 00:00:00 2001 From: phildd Date: Fri, 24 Aug 2012 18:07:31 +0545 Subject: Make arpwatch work on 21 and nanobsd On 2.1 arpwatch was putting its log file (arp.dat) into a "pbi" folder where it was installed. arpwatch_reports.php didn't know anything about that, so didn't find it. On nanobsd the usr pbi location is RO anyway. So, arp.dat moved to /var/log Some code added to touch the file from rc.d/arpwatch.sh - arpwatch complains if the file does not exist when it starts. --- config/arpwatch.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/config/arpwatch.xml b/config/arpwatch.xml index 0553eb58..c88480bd 100644 --- a/config/arpwatch.xml +++ b/config/arpwatch.xml @@ -89,11 +89,13 @@ function sync_package_arpwatch() { global $config; - conf_mount_rw(); - config_lock(); + conf_mount_rw(); + config_lock(); + $log_file = "/var/log/arp.dat"; $int = $config['installedpackages']['arpwatch']['config'][0]['interface']; $int = convert_friendly_interface_to_real_interface_name($int); - $start = "/usr/local/sbin/arpwatch -d -i {$int} > /var/log/arpwatch.reports 2>&1 &"; + $start = "touch {$log_file}\n"; + $start .= "/usr/local/sbin/arpwatch -d -f {$log_file} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; $stop = "/usr/bin/killall arpwatch"; write_rcfile(array( "file" => "arpwatch.sh", @@ -102,9 +104,9 @@ ) ); restart_service("arpwatch"); - conf_mount_ro(); - config_unlock(); - } + conf_mount_ro(); + config_unlock(); + } sync_package_arpwatch(); -- cgit v1.2.3 From 12e7b0af81dc97fa6952a9b3e78e140a7644eb5a Mon Sep 17 00:00:00 2001 From: phildd Date: Fri, 24 Aug 2012 18:09:40 +0545 Subject: Look for arp.dat in /var/log As per change in arpwatch.xml, arp.dat is in /var/log --- config/arpwatch_reports.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/arpwatch_reports.php b/config/arpwatch_reports.php index 1bdb5233..d66b1a46 100755 --- a/config/arpwatch_reports.php +++ b/config/arpwatch_reports.php @@ -3,7 +3,7 @@ /* $Id$ - diag_logs.php + arpwatch_reports.php Copyright (C) 2005 Colin Smith All rights reserved. @@ -31,7 +31,7 @@ require("guiconfig.inc"); -$logfile = "/usr/local/arpwatch/arp.dat"; +$logfile = "/var/log/arp.dat"; if ($_POST['clear']) { stop_service("arpwatch"); -- cgit v1.2.3 From 5f9d501f8f823902de7b5d0e05790b17e58410ec Mon Sep 17 00:00:00 2001 From: phildd Date: Fri, 24 Aug 2012 18:24:00 +0545 Subject: Fix arpwatch so selected interface happens first time See: http://forum.pfsense.org/index.php/topic,51007.0.html After selecting an interface for arpwatch, the first time you "save" the selection is written to the config file, but arpwatch.sh gets written with the previous value. arpwatch starts on some other interface. You have to press save twice. This fixes the problem - code as per the forum suggestion and it works nicely for me. --- config/arpwatch.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/arpwatch.xml b/config/arpwatch.xml index c88480bd..c9434075 100644 --- a/config/arpwatch.xml +++ b/config/arpwatch.xml @@ -92,7 +92,11 @@ conf_mount_rw(); config_lock(); $log_file = "/var/log/arp.dat"; - $int = $config['installedpackages']['arpwatch']['config'][0]['interface']; + 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 -d -f {$log_file} -i {$int} > /var/log/arpwatch.reports 2>&1 &"; -- cgit v1.2.3