Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARPwatch improvements. Issue #10770 #912

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net-mgmt/pfSense-pkg-arpwatch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PORTNAME= pfSense-pkg-arpwatch
PORTVERSION= 0.2.0
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= net-mgmt
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
17 changes: 11 additions & 6 deletions net-mgmt/pfSense-pkg-arpwatch/files/usr/local/pkg/arpwatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ function arpwatch_install_command() {
.' '.$disable_zero
.' '.$enable_zeropad
.' -f '.escapeshellarg($arp_file)
.' -i '.escapeshellarg($ifname)
.' -w '.escapeshellarg($notifications_recipient)
."\n";
.' -i '.escapeshellarg($ifname);
if (!empty($notifications_recipient)) {
$rc['start'] .= ' -w '.escapeshellarg($notifications_recipient);
}
$rc['start'] .= "\n";
}
}

Expand Down Expand Up @@ -108,7 +110,8 @@ function arpwatch_validate_input($post, &$input_errors) {
}
}

if (filter_var($post['notifications_recipient'], FILTER_VALIDATE_EMAIL) === false) {
if (!empty($post['notifications_recipient']) &&
(filter_var($post['notifications_recipient'], FILTER_VALIDATE_EMAIL) === false)) {
$input_errors[] = gettext("{$post['notifications_recipient']} is not a valid email address.");
}

Expand Down Expand Up @@ -167,7 +170,8 @@ function arpwatch_parse_database() {
$oui = strtolower(substr($mac, 0, 8));
$matches = array();

if (preg_match("/^$oui\s+(.*)$/m", file_get_contents(ARPWATCH_LOCAL_DIR.'/ethercodes.dat'), $matches)) {
if (file_exists(ARPWATCH_LOCAL_DIR.'/ethercodes.dat') &&
preg_match("/^$oui\s+(.*)$/m", file_get_contents(ARPWATCH_LOCAL_DIR.'/ethercodes.dat'), $matches)) {
$vendor = $matches[1];
} else {
$vendor = 'unknown';
Expand Down Expand Up @@ -228,7 +232,8 @@ $fd = fopen('php://stdin','r');
$message = stream_get_contents($fd);
fclose($fd);

if (false !== $message) {
if ((false !== $message) && ((false === strpos($message, ': Cron ')) ||
($config['installedpackages']['arpwatch']['config'][0]['cron_disable'] != 'on'))) {
$subject = array();
preg_match('/^Subject: (.*)$/m', $message, $subject);
init_config_arr(array('installedpackages', 'arpwatch', 'config', 0, 'row'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@
<description>The email address that will receive notifications (warning: may send a lot of notifications in busy networks).</description>
<type>input</type>
<size>50</size>
<required/>
</field>
<field>
<fielddescr>Disable Cron emails</fielddescr>
<fieldname>disable_cron</fieldname>
<type>checkbox</type>
<description>Disables Cron email notifications from other packages.</description>
<default_value>on</default_value>
</field>
<field>
<fielddescr>Zero padded ethernet addresses</fielddescr>
Expand Down