* Copyright (C) 2014-2015 Deciso B.V. * Copyright (C) 2005-2010 Scott Ullrich * Copyright (C) 2008 Shrew Soft Inc. * Copyright (C) 2003-2004 Manuel Kasper * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ require_once("guiconfig.inc"); require_once("filter.inc"); require_once("system.inc"); require_once("services.inc"); if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = array(); $pconfig['webguiinterfaces'] = !empty($config['system']['webgui']['interfaces']) ? explode(',', $config['system']['webgui']['interfaces']) : array(); $pconfig['webguiproto'] = $config['system']['webgui']['protocol']; $pconfig['webguiport'] = $config['system']['webgui']['port']; $pconfig['ssl-certref'] = $config['system']['webgui']['ssl-certref']; $pconfig['compression'] = isset($config['system']['webgui']['compression']) ? $config['system']['webgui']['compression'] : null; $pconfig['ssl-ciphers'] = !empty($config['system']['webgui']['ssl-ciphers']) ? explode(':', $config['system']['webgui']['ssl-ciphers']) : array(); $pconfig['disablehttpredirect'] = isset($config['system']['webgui']['disablehttpredirect']); $pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']); $pconfig['usevirtualterminal'] = isset($config['system']['usevirtualterminal']); $pconfig['disableintegratedauth'] = !empty($config['system']['disableintegratedauth']); $pconfig['sudo_allow_wheel'] = $config['system']['sudo_allow_wheel']; $pconfig['nodnsrebindcheck'] = isset($config['system']['webgui']['nodnsrebindcheck']); $pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']); $pconfig['althostnames'] = $config['system']['webgui']['althostnames']; $pconfig['serialspeed'] = $config['system']['serialspeed']; $pconfig['primaryconsole'] = $config['system']['primaryconsole']; $pconfig['secondaryconsole'] = $config['system']['secondaryconsole']; $pconfig['enablesshd'] = $config['system']['ssh']['enabled']; $pconfig['sshport'] = $config['system']['ssh']['port']; $pconfig['sshinterfaces'] = !empty($config['system']['ssh']['interfaces']) ? explode(',', $config['system']['ssh']['interfaces']) : array(); $pconfig['passwordauth'] = isset($config['system']['ssh']['passwordauth']); $pconfig['sshdpermitrootlogin'] = isset($config['system']['ssh']['permitrootlogin']); $pconfig['quietlogin'] = isset($config['system']['webgui']['quietlogin']); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors = array(); $pconfig = $_POST; /* input validation */ if (!empty($pconfig['webguiport'])) { if (!is_port($pconfig['webguiport'])) { $input_errors[] = gettext('You must specify a valid web GUI port number'); } } if (!empty($pconfig['althostnames'])) { $althosts = explode(" ", $pconfig['althostnames']); foreach ($althosts as $ah) { if (!is_hostname($ah)) { $input_errors[] = sprintf(gettext("Alternate hostname %s is not a valid hostname."), htmlspecialchars($ah)); } } } if (!empty($pconfig['sshport'])) { if (!is_port($pconfig['sshport'])) { $input_errors[] = gettext("You must specify a valid port number"); } } if (count($input_errors) == 0) { $newinterfaces = !empty($pconfig['webguiinterfaces']) ? implode(',', $pconfig['webguiinterfaces']) : ''; $newciphers = !empty($pconfig['ssl-ciphers']) ? implode(':', $pconfig['ssl-ciphers']) : ''; $restart_webgui = $config['system']['webgui']['protocol'] != $pconfig['webguiproto'] || $config['system']['webgui']['port'] != $pconfig['webguiport'] || $config['system']['webgui']['ssl-certref'] != $pconfig['ssl-certref'] || $config['system']['webgui']['compression'] != $pconfig['compression'] || $config['system']['webgui']['ssl-ciphers'] != $newciphers || $config['system']['webgui']['interfaces'] != $newinterfaces || ($pconfig['disablehttpredirect'] == "yes") != !empty($config['system']['webgui']['disablehttpredirect']); $config['system']['webgui']['protocol'] = $pconfig['webguiproto']; $config['system']['webgui']['port'] = $pconfig['webguiport']; $config['system']['webgui']['ssl-certref'] = $pconfig['ssl-certref']; $config['system']['webgui']['ssl-ciphers'] = $newciphers; $config['system']['webgui']['interfaces'] = $newinterfaces; $config['system']['webgui']['compression'] = $pconfig['compression']; if ($pconfig['disablehttpredirect'] == "yes") { $config['system']['webgui']['disablehttpredirect'] = true; } elseif (isset($config['system']['webgui']['disablehttpredirect'])) { unset($config['system']['webgui']['disablehttpredirect']); } if ($pconfig['quietlogin'] == "yes") { $config['system']['webgui']['quietlogin'] = true; } elseif (isset($config['system']['webgui']['quietlogin'])) { unset($config['system']['webgui']['quietlogin']); } if ($pconfig['disableconsolemenu'] == "yes") { $config['system']['disableconsolemenu'] = true; } elseif (isset($config['system']['disableconsolemenu'])) { unset($config['system']['disableconsolemenu']); } if (!empty($pconfig['usevirtualterminal'])) { $config['system']['usevirtualterminal'] = true; } elseif (isset($config['system']['usevirtualterminal'])) { unset($config['system']['usevirtualterminal']); } if (!empty($pconfig['disableintegratedauth'])) { $config['system']['disableintegratedauth'] = true; } elseif (isset($config['system']['disableintegratedauth'])) { unset($config['system']['disableintegratedauth']); } if (!empty($pconfig['sudo_allow_wheel'])) { $config['system']['sudo_allow_wheel'] = $pconfig['sudo_allow_wheel']; } elseif (isset($config['system']['sudo_allow_wheel'])) { unset($config['system']['sudo_allow_wheel']); } if (is_numeric($pconfig['serialspeed'])) { $config['system']['serialspeed'] = $pconfig['serialspeed']; } elseif (isset($config['system']['serialspeed'])) { unset($config['system']['serialspeed']); } if (!empty($pconfig['primaryconsole'])) { $config['system']['primaryconsole'] = $pconfig['primaryconsole']; } elseif (isset($config['system']['primaryconsole'])) { unset($config['system']['primaryconsole']); } if (!empty($pconfig['secondaryconsole'])) { $config['system']['secondaryconsole'] = $pconfig['secondaryconsole']; } elseif (isset($config['system']['secondaryconsole'])) { unset($config['system']['secondaryconsole']); } if ($pconfig['nodnsrebindcheck'] == "yes") { $config['system']['webgui']['nodnsrebindcheck'] = true; } elseif (isset($config['system']['webgui']['nodnsrebindcheck'])) { unset($config['system']['webgui']['nodnsrebindcheck']); } if ($pconfig['nohttpreferercheck'] == "yes") { $config['system']['webgui']['nohttpreferercheck'] = true; } elseif (isset($config['system']['webgui']['nohttpreferercheck'])) { unset($config['system']['webgui']['nohttpreferercheck']); } if (!empty($pconfig['althostnames'])) { $config['system']['webgui']['althostnames'] = $pconfig['althostnames']; } elseif (isset($config['system']['webgui']['althostnames'])) { unset($config['system']['webgui']['althostnames']); } /* always store setting to prevent installer auto-start */ $config['system']['ssh']['noauto'] = 1; $config['system']['ssh']['interfaces'] = !empty($pconfig['sshinterfaces']) ? implode(',', $pconfig['sshinterfaces']) : null; if (!empty($pconfig['enablesshd'])) { $config['system']['ssh']['enabled'] = 'enabled'; } elseif (isset($config['system']['ssh']['enabled'])) { unset($config['system']['ssh']['enabled']); } if (!empty($pconfig['passwordauth'])) { $config['system']['ssh']['passwordauth'] = true; } elseif (isset($config['system']['ssh']['passwordauth'])) { unset($config['system']['ssh']['passwordauth']); } if (!empty($pconfig['sshport'])) { $config['system']['ssh']['port'] = $_POST['sshport']; } elseif (isset($config['system']['ssh']['port'])) { unset($config['system']['ssh']['port']); } if (!empty($pconfig['sshdpermitrootlogin'])) { $config['system']['ssh']['permitrootlogin'] = true; } elseif (isset($config['system']['ssh']['permitrootlogin'])) { unset($config['system']['ssh']['permitrootlogin']); } if ($restart_webgui) { $http_host_port = explode("]", $_SERVER['HTTP_HOST']); /* IPv6 address check */ if (strstr($_SERVER['HTTP_HOST'], "]")) { if (count($http_host_port) > 1) { array_pop($http_host_port); $host = str_replace(array("[", "]"), "", implode(":", $http_host_port)); $host = "[{$host}]"; } else { $host = str_replace(array("[", "]"), "", implode(":", $http_host_port)); $host = "[{$host}]"; } } else { list($host) = explode(":", $_SERVER['HTTP_HOST']); } $prot = $config['system']['webgui']['protocol']; $port = $config['system']['webgui']['port']; if (!empty($port)) { $url = "{$prot}://{$host}:{$port}/system_advanced_admin.php"; } else { $url = "{$prot}://{$host}/system_advanced_admin.php"; } } write_config(); $savemsg = get_std_save_message(); filter_configure(); system_login_configure(); system_hosts_generate(); plugins_configure('dns'); services_dhcpd_configure(); configd_run('openssh restart', true); if ($restart_webgui) { configd_run('webgui restart 3', true); } } } $a_cert = isset($config['cert']) ? $config['cert'] : array(); $interfaces = get_configured_interface_with_descr(); $certs_available = false; if (count($a_cert)) { $certs_available = true; } if (empty($pconfig['webguiproto']) || !$certs_available) { $pconfig['webguiproto'] = "http"; } legacy_html_escape_form_data($pconfig); include("head.inc"); ?>
0) { print_input_errors($input_errors); } if (isset($savemsg)) { print_info_box($savemsg); } ?>
/>     />
','') ?>
/>
/>
/>
/>
/>
/>
/>
/>
/>
/>
  " />