Bug #2454
closedCaptive portal return wrong authentication URL
90%
Description
Since the last update "Built On: Sun May 13 02:42:10 EDT 2012" our captive portal doesn't work anymore.
The redirection URL seems to be wrong.
Instead of a thing like : "10.0.54.1:8000/index.php?zone=myzonename&..."
We have :
"hostnameDomainName/index.php?zone=1&..." ( moreover there's a dot missing between the hostname and the domain name in the URL)
So Pfsense seems not being able to find the correct zonename of the portal and the correct ip of the interface...
Here, the redirect URL I get :
pfsense hostname : mypfsense
pfsense domain : internal.mycorp.com
And I use the default config of the captive portal.
A colleague found a temporary fix :
Original /etc/inc/captiveportal.inc
Code: function portal_ip_from_client_ip($cliip) { global $config, $cpzone; $interfaces = explode(",", $config['captiveportal'][$cpzone]['interface']); foreach ($interfaces as $cpif) { $ip = get_interface_ip($cpif); $sn = get_interface_subnet($cpif); if (ip_in_subnet($cliip, "{$ip}/{$sn}")) return $ip; }
New one
Code: function portal_ip_from_client_ip($cliip) { global $config, $cpzone; foreach ($config['captiveportal'] as $cpkey => $cp) { $cpzone = $cpkey; $interfaces = explode(",", $config['captiveportal'][$cpzone]['interface']); foreach ($interfaces as $cpif) { $ip = get_interface_ip($cpif); $sn = get_interface_subnet($cpif); if (ip_in_subnet($cliip, "{$ip}/{$sn}")) return $ip; } }
Original /usr/local/captiveportal/index.php
Code: $cpzone = $_REQUEST['zone']; $cpcfg = $config['captiveportal'][$cpzone]; $orig_host = $_ENV['HTTP_HOST']; $orig_request = $_REQUEST['redirurl']; $clientip = $_SERVER['REMOTE_ADDR']; if (!$clientip) { /* not good - bail out */ log_error("Captive portal could not determine client's IP address."); $error_message = "An error occurred. Please check the system logs for more information."; portal_reply_page($redirurl, "error", $errormsg); exit; }
New One
Code: $orig_host = $_ENV['HTTP_HOST']; $orig_request = $_REQUEST['redirurl']; $clientip = $_SERVER['REMOTE_ADDR']; global $cpzone; #$cpzone = $_REQUEST['zone']; $ifip = portal_ip_from_client_ip($clientip); $cpcfg = $config['captiveportal'][$cpzone]; if (!$clientip) { /* not good - bail out */ log_error("Captive portal could not determine client's IP address."); $error_message = "An error occurred. Please check the system logs for more information."; portal_reply_page($redirurl, "error", $errormsg); exit; }