diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc index 1e6333c4dc..ea4d8cc2ba 100644 --- a/src/etc/inc/captiveportal.inc +++ b/src/etc/inc/captiveportal.inc @@ -1606,7 +1606,7 @@ function captiveportal_authenticate_user(&$login = '', &$password = '', $clientm foreach ($auth_servers as $authcfg) { if ($authlevel < 3) { $radmac_error = false; - $attributes = array("nas_identifier" => "CaptivePortal-{$cpzone}", + $attributes = array("nas_identifier" => empty($cpcfg["radiusnasid"]) ? "CaptivePortal-{$cpzone}" : $cpcfg["radiusnasid"], "nas_port_type" => RADIUS_ETHERNET, "nas_port" => $pipeno, "framed_ip" => $clientip); @@ -2683,7 +2683,8 @@ function captiveportal_send_server_accounting($type = 'on', $ruleno = null, $use } $nasmac = get_interface_mac(find_ip_interface($nasip)); $racct->putAttribute(RADIUS_NAS_IP_ADDRESS, $nasip, "addr"); - $racct->putAttribute(RADIUS_NAS_IDENTIFIER, "CaptivePortal-{$cpzone}"); + + $racct->putAttribute(RADIUS_NAS_IDENTIFIER, empty($cpcfg["radiusnasid"]) ? "CaptivePortal-{$cpzone}" : $cpcfg["radiusnasid"] ); if (is_int($ruleno)) { $racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET); diff --git a/src/usr/local/www/services_captiveportal.php b/src/usr/local/www/services_captiveportal.php index 08211dcd9e..a9c3e719dd 100644 --- a/src/usr/local/www/services_captiveportal.php +++ b/src/usr/local/www/services_captiveportal.php @@ -180,6 +180,7 @@ if ($a_cp[$cpzone]) { $pconfig['radmac_format'] = $a_cp[$cpzone]['radmac_format']; $pconfig['reverseacct'] = isset($a_cp[$cpzone]['reverseacct']); $pconfig['includeidletime'] = isset($a_cp[$cpzone]['includeidletime']); + $pconfig['radiusnasid'] = $a_cp[$cpzone]['radiusnasid']; $pconfig['page'] = array(); if ($a_cp[$cpzone]['page']['htmltext']) { $pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext']; @@ -312,6 +313,9 @@ if ($_POST['save']) { if (isset($_POST['radacct_enable']) && !in_array($_POST['reauthenticateacct'], array('none', 'stopstart', 'stopstartfreeradius', 'interimupdate'))) { $input_errors[] = gettext("You need to select an option for Accounting Updates !"); } + if (trim($_POST['radiusnasid']) !== "" && !preg_match("/^[\x21-\x7e]{3,253}$/i", trim($_POST['radiusnasid']))) { + $input_errors[] = gettext("The NAS-Identifier must be 3-253 characters long and should only contain ASCII characters."); + } if (!$input_errors) { $newcp =& $a_cp[$cpzone]; @@ -390,6 +394,7 @@ if ($_POST['save']) { $newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false; $newcp['reverseacct'] = $_POST['reverseacct'] ? true : false; $newcp['includeidletime'] = $_POST['includeidletime'] ? true : false; + $newcp['radiusnasid'] = trim($_POST['radiusnasid']); if ($_POST['customhtml']) { $newcp['customhtml'] = true; } else { @@ -916,6 +921,13 @@ $group->add(new Form_Select( "This setting is useful if you want to provide multiple authentication method to your users. If you don't need multiple authentication method, then leave this setting empty."); $section->add($group); +$section->addInput(new Form_Input( + 'radiusnasid', + 'NAS Identifier', + 'text', + $pconfig['radiusnasid'] +))->setHelp('Specify a NAS identifier to override the default value (CaptivePortal-%s)', $cpzone); + $section->addInput(new Form_Checkbox( 'reauthenticate', 'Reauthenticate Users', @@ -1141,6 +1153,7 @@ events.push(function() { hideInput('radmac_format', hide); hideCheckbox('radiusperuserbw', hide); hideCheckbox('radiustraffic_quota', hide); + hideInput('radiusnasid', hide); } function hideHTTPS() {