Commit 0518c441 authored by Franco Fichtner's avatar Franco Fichtner

captive portal: fix ip_to_mac()

parent a20b5876
......@@ -90,22 +90,25 @@ $passthrumac = isset($cpcfg['passthrumacadd']);
function ip_to_mac($addr)
{
$cmd = '/usr/sbin/arp -n ' . $addr;
$ret = false;
exec($cmd, $out, $ret);
if ($ret) {
log_error('The command `' . $cmd . '\' failed to execute');
} else {
$mac = explode(' ', $out);
$mac = explode(' ', $out[0]);
if (isset($mac[3])) {
return array('macaddr' => $mac[3]);
$ret = $mac[3];
}
}
return $ret;
}
/* find MAC address for client */
if ($macfilter || $passthrumac) {
$tmpres = ip_to_mac($clientip);
if (!is_array($tmpres)) {
if (!$tmpres) {
/* unable to find MAC address - shouldn't happen! - bail out */
captiveportal_logportalauth("unauthenticated","noclientmac",$clientip,"ERROR");
echo "An error occurred. Please check the system logs for more information.";
......@@ -113,7 +116,7 @@ if ($macfilter || $passthrumac) {
ob_flush();
return;
}
$clientmac = $tmpres['macaddr'];
$clientmac = $tmpres;
unset($tmpres);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment