summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukehamburg <luke.hamburg@gmail.com>2017-02-08 10:35:52 -0500
committerRenato Botelho <renato@netgate.com>2017-02-10 15:57:53 -0200
commitc2f4b75978698f282b8caa93c276acdff870939b (patch)
tree8ae43d25a2cd919571c31481b5fc427bc1098288
parent307243e7b7cb88283740ae29a2d6150cc59bc573 (diff)
downloadpfsense-c2f4b75978698f282b8caa93c276acdff870939b.zip
pfsense-c2f4b75978698f282b8caa93c276acdff870939b.tar.gz
3rd try!
- incorporate suggestions from @rbgarga with slight modification (cherry picked from commit 6c2f093000b05285546e81dd1a578fc9b573b72b)
-rw-r--r--src/etc/inc/util.inc17
-rw-r--r--src/usr/local/www/services_dhcp_edit.php2
2 files changed, 8 insertions, 11 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index 418ad51..a205cdb 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -1850,24 +1850,23 @@ function alias_expand_urltable($name) {
/* obtain MAC address given an IP address by looking at the ARP/NDP table */
function arp_get_mac_by_ip($ip) {
- unset($arp_ndp_output);
+ unset($macaddr);
+ $retval = 1;
switch (is_ipaddr($ip)) {
case 4:
mwexec("/sbin/ping -c 1 -t 1 " . escapeshellarg($ip), true);
- exec("/usr/sbin/arp -n " . escapeshellarg($ip) . " | /usr/bin/awk '{print $4}'", $arp_ndp_output);
+ $macaddr = exec("/usr/sbin/arp -n " . escapeshellarg($ip) . " | /usr/bin/awk '{print $4}'", $output, $retval);
break;
case 6:
mwexec("/sbin/ping6 -c 1 -X 1 " . escapeshellarg($ip), true);
- exec("/usr/sbin/ndp -n " . escapeshellarg($ip) . " | /usr/bin/tail -n+2 | /usr/bin/awk '{print $2}'", $arp_ndp_output);
+ $macaddr = exec("/usr/sbin/ndp -n " . escapeshellarg($ip) . " | /usr/bin/awk '{print $2}'", $output, $retval);
break;
}
- if ($arp_ndp_output[0]) {
- $macaddr = $arp_ndp_output[0];
- if (is_macaddr($macaddr)) {
- return $macaddr;
- }
+ if ($retval == 0 && is_macaddr($macaddr)) {
+ return $macaddr;
+ } else {
+ return false;
}
- return false;
}
/* return a fieldname that is safe for xml usage */
diff --git a/src/usr/local/www/services_dhcp_edit.php b/src/usr/local/www/services_dhcp_edit.php
index 22bfbcf..ecdd015 100644
--- a/src/usr/local/www/services_dhcp_edit.php
+++ b/src/usr/local/www/services_dhcp_edit.php
@@ -404,8 +404,6 @@ if ($_POST) {
// Get our MAC address
$ip = $_SERVER['REMOTE_ADDR'];
-
-unset($mymac);
$mymac = arp_get_mac_by_ip($ip);
$iflist = get_configured_interface_with_descr();
OpenPOWER on IntegriCloud