mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
ssh settings alignment. Fixes #8974
Remove redundant settings stored in the wrong place
Store all ssh settings in the same place
Initialize this array before use
(cherry picked from commit ec439957ce)
This commit is contained in:
parent
1be9e2a0e5
commit
3b73574b86
@ -4450,7 +4450,7 @@ function filter_get_antilockout_ports($wantarray = false) {
|
||||
$lockoutports[] = "80";
|
||||
}
|
||||
|
||||
if (isset($config['system']['enablesshd'])) {
|
||||
if (isset($config['system']['ssh']['enable'])) {
|
||||
$lockoutports[] = empty($config['system']['ssh']['port']) ? "22" : $config['system']['ssh']['port'];
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ $g = array(
|
||||
"disablecrashreporter" => false,
|
||||
"crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php",
|
||||
"debug" => false,
|
||||
"latest_config" => "18.8",
|
||||
"latest_config" => "18.9",
|
||||
"minimum_ram_warning" => "101",
|
||||
"minimum_ram_warning_text" => "128 MB",
|
||||
"wan_interface_name" => "wan",
|
||||
|
||||
@ -351,7 +351,7 @@ function get_services() {
|
||||
$services[] = $pconfig;
|
||||
}
|
||||
|
||||
if (isset($config['system']['enablesshd'])) {
|
||||
if (isset($config['system']['ssh']['enable'])) {
|
||||
$pconfig = array();
|
||||
$pconfig['name'] = "sshd";
|
||||
$pconfig['description'] = gettext("Secure Shell Daemon");
|
||||
|
||||
@ -5919,6 +5919,21 @@ function upgrade_187_to_188() {
|
||||
}
|
||||
}
|
||||
|
||||
function upgrade_188_to_189() {
|
||||
global $config;
|
||||
|
||||
/* Migrate ssh setting to new location */
|
||||
if (isset($config['system']['enablesshd'])) {
|
||||
$config['system']['ssh']['enable'] = "enabled";
|
||||
unset($config['system']['enablesshd']);
|
||||
}
|
||||
/* Remove accidentally duplicated ssh config
|
||||
* See https://redmine.pfsense.org/issues/8974 */
|
||||
if (isset($config['system']['sshd'])) {
|
||||
$config['system']['sshd'];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Special function that is called independent of current config version. It's
|
||||
* a workaround to have config_upgrade running on older versions after next
|
||||
|
||||
@ -19,14 +19,15 @@
|
||||
*/
|
||||
|
||||
global $config;
|
||||
echo "Starting enablesshd...";
|
||||
echo "Enabling sshd...";
|
||||
require("config.inc");
|
||||
echo ".";
|
||||
$config = parse_config(true);
|
||||
echo ".";
|
||||
$config['system']['enablesshd'] = true;
|
||||
init_config_arr(array('system', 'ssh'));
|
||||
$config['system']['ssh']['enable'] = "enabled";
|
||||
echo ".";
|
||||
write_config("pfSsh.php enabled sshd");
|
||||
echo "\nEnabling SSHD, please wait...";
|
||||
echo "\nRestarting sshd, please wait...";
|
||||
send_event("service reload sshd");
|
||||
echo "\n\n";
|
||||
|
||||
@ -28,11 +28,11 @@ require_once("filter.inc");
|
||||
|
||||
$fp = fopen('php://stdin', 'r');
|
||||
|
||||
if (isset($config['system']['enablesshd'])) {
|
||||
if (isset($config['system']['ssh']['enable'])) {
|
||||
echo "SSHD is currently enabled. Would you like to disable? [y/n]? ";
|
||||
$yn = chop(fgets($fp));
|
||||
if ($yn[0] == "y") {
|
||||
unset($config['system']['enablesshd']);
|
||||
unset($config['system']['ssh']['enable']);
|
||||
echo "\nWriting configuration...";
|
||||
write_config(gettext("Disabled SSHD from console menu."));
|
||||
echo " done.\n";
|
||||
@ -48,7 +48,8 @@ if (isset($config['system']['enablesshd'])) {
|
||||
echo "SSHD is currently disabled. Would you like to enable? [y/n]? ";
|
||||
$yn = chop(fgets($fp));
|
||||
if ($yn[0] == "y") {
|
||||
$config['system']['enablesshd'] = true;
|
||||
init_config_arr(array('system', 'ssh'));
|
||||
$config['system']['ssh']['enable'] = "enabled";
|
||||
echo "\nWriting configuration...";
|
||||
write_config(gettext("Enabled SSHD from console menu."));
|
||||
echo " done.\n";
|
||||
|
||||
@ -26,7 +26,7 @@ require_once("config.inc");
|
||||
require_once("functions.inc");
|
||||
require_once("shaper.inc");
|
||||
|
||||
if (!isset($config['system']['enablesshd'])) {
|
||||
if (!isset($config['system']['ssh']['enable'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ $show_help_text = <<<EOF
|
||||
print_r(get_wireless_modes(\"ath0\"));
|
||||
|
||||
/* to enable SSH */
|
||||
\$config['system']['enablesshd'] = true;
|
||||
\$config['system']['ssh']['enable'] = "enabled";
|
||||
|
||||
/* change OPTX to the OPT interface name such as BACKHAUL */
|
||||
\$config['interfaces']['optx']['wireless']['standard'] = "11a";
|
||||
|
||||
@ -36,6 +36,9 @@ require_once("functions.inc");
|
||||
require_once("filter.inc");
|
||||
require_once("shaper.inc");
|
||||
|
||||
init_config_arr(array('system', 'webgui'));
|
||||
init_config_arr(array('system', 'ssh'));
|
||||
|
||||
$pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
|
||||
$pconfig['webguiport'] = $config['system']['webgui']['port'];
|
||||
$pconfig['max_procs'] = ($config['system']['webgui']['max_procs']) ? $config['system']['webgui']['max_procs'] : 2;
|
||||
@ -53,7 +56,7 @@ $pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
|
||||
$pconfig['enableserial'] = $config['system']['enableserial'];
|
||||
$pconfig['serialspeed'] = $config['system']['serialspeed'];
|
||||
$pconfig['primaryconsole'] = $config['system']['primaryconsole'];
|
||||
$pconfig['enablesshd'] = $config['system']['enablesshd'];
|
||||
$pconfig['enablesshd'] = $config['system']['ssh']['enable'];
|
||||
$pconfig['sshport'] = $config['system']['ssh']['port'];
|
||||
$pconfig['sshdkeyonly'] = $config['system']['ssh']['sshdkeyonly'];
|
||||
$pconfig['quietlogin'] = isset($config['system']['webgui']['quietlogin']);
|
||||
@ -104,14 +107,6 @@ if ($_POST) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['sshdkeyonly'] == "enabled") {
|
||||
$config['system']['ssh']['sshdkeyonly'] = "enabled";
|
||||
} else if ($_POST['sshdkeyonly'] == "both") {
|
||||
$config['system']['ssh']['sshdkeyonly'] = "both";
|
||||
} else if (isset($config['system']['ssh']['sshdkeyonly'])) {
|
||||
unset($config['system']['ssh']['sshdkeyonly']);
|
||||
}
|
||||
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
@ -241,11 +236,19 @@ if ($_POST) {
|
||||
unset($config['system']['webgui']['althostnames']);
|
||||
}
|
||||
|
||||
$sshd_enabled = $config['system']['enablesshd'];
|
||||
$sshd_enabled = $config['system']['ssh']['enable'];
|
||||
if ($_POST['enablesshd']) {
|
||||
$config['system']['enablesshd'] = "enabled";
|
||||
$config['system']['ssh']['enable'] = "enabled";
|
||||
} else {
|
||||
unset($config['system']['enablesshd']);
|
||||
unset($config['system']['ssh']['enable']);
|
||||
}
|
||||
|
||||
if ($_POST['sshdkeyonly'] == "enabled") {
|
||||
$config['system']['ssh']['sshdkeyonly'] = "enabled";
|
||||
} else if ($_POST['sshdkeyonly'] == "both") {
|
||||
$config['system']['ssh']['sshdkeyonly'] = "both";
|
||||
} else if (isset($config['system']['ssh']['sshdkeyonly'])) {
|
||||
unset($config['system']['ssh']['sshdkeyonly']);
|
||||
}
|
||||
|
||||
$sshd_keyonly = $config['system']['sshd']['sshdkeyonly'];
|
||||
@ -264,7 +267,7 @@ if ($_POST) {
|
||||
unset($config['system']['ssh']['port']);
|
||||
}
|
||||
|
||||
if (($sshd_enabled != $config['system']['enablesshd']) ||
|
||||
if (($sshd_enabled != $config['system']['ssh']['enable']) ||
|
||||
($sshd_keyonly != $config['system']['ssh']['sshdkeyonly']) ||
|
||||
($sshd_port != $config['system']['ssh']['port'])) {
|
||||
$restart_sshd = true;
|
||||
@ -617,7 +620,7 @@ if ($restart_sshd) {
|
||||
killbyname("sshd");
|
||||
log_error(gettext("secure shell configuration has changed. Stopping sshd."));
|
||||
|
||||
if ($config['system']['enablesshd']) {
|
||||
if ($config['system']['ssh']['enable']) {
|
||||
log_error(gettext("secure shell configuration has changed. Restarting sshd."));
|
||||
send_event("service restart sshd");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user