diff options
-rw-r--r-- | etc/inc/pfsense-utils.inc | 101 | ||||
-rw-r--r-- | etc/phpshellsessions/gitsync | 2 | ||||
-rwxr-xr-x | etc/rc.bootup | 12 | ||||
-rwxr-xr-x | etc/rc.initial | 2 |
4 files changed, 28 insertions, 89 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 413df79..2a3abdf 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -902,78 +902,6 @@ function reload_all_sync() { send_event("service restart webgui"); } -function auto_login() { - global $config; - - if(isset($config['system']['disableconsolemenu'])) - $status = false; - else - $status = true; - - $gettytab = file_get_contents("/etc/gettytab"); - $getty_split = explode("\n", $gettytab); - $getty_update_needed = false; - $getty_search_str = ":ht:np:sp#115200"; - $getty_al_str = ":al=root:"; - $getty_al_search_str = $getty_search_str . $getty_al_str; - /* Check if gettytab is already OK, if so then do not rewrite it. */ - foreach($getty_split as $gs) { - if(stristr($gs, $getty_search_str)) { - if($status == true) { - if(!stristr($gs, $getty_al_search_str)) { - $getty_update_needed = true; - } - } else { - if(stristr($gs, $getty_al_search_str)) { - $getty_update_needed = true; - } - } - } - } - - if (!$getty_update_needed) { - return; - } - - conf_mount_rw(); - $fd = false; - $tries = 0; - while (!$fd && $tries < 100) { - $fd = fopen("/etc/gettytab", "w"); - $tries++; - - } - if (!$fd) { - conf_mount_ro(); - if ($status) { - log_error(gettext("Enabling auto login was not possible.")); - } else { - log_error(gettext("Disabling auto login was not possible.")); - } - return; - } - foreach($getty_split as $gs) { - if(stristr($gs, $getty_search_str)) { - if($status == true) { - fwrite($fd, " ".$getty_al_search_str."\n"); - } else { - fwrite($fd, " ".$getty_search_str."\n"); - } - } else { - fwrite($fd, "{$gs}\n"); - } - } - fclose($fd); - - if ($status) { - log_error(gettext("Enabled console auto login, console menu is NOT password protected.")); - } else { - log_error(gettext("Disabled console auto login, console menu is password protected.")); - } - - conf_mount_ro(); -} - function setup_serial_port($when="save", $path="") { global $g, $config; conf_mount_rw(); @@ -1047,24 +975,35 @@ function setup_serial_port($when="save", $path="") { $ttys = file_get_contents("/etc/ttys"); $ttys_split = explode("\n", $ttys); $fd = fopen("/etc/ttys", "w"); + $on_off = ((isset($config['system']['enableserial']) || $g['enableserial_force']) ? 'on' : 'off'); + if (isset($config['system']['disableconsolemenu'])) { + $console_type = 'Pc'; + $serial_type = 'std.' . $serialspeed; + } else { + $console_type = 'al.Pc'; + $serial_type = 'al.' . $serialspeed; + } foreach($ttys_split as $tty) { - if(stristr($tty, "ttyd0") or stristr($tty, "ttyu0")) { - if(isset($config['system']['enableserial']) || $g['enableserial_force']) { - fwrite($fd, "ttyu0 \"/usr/libexec/getty bootupcli\" cons25 on secure\n"); - } else { - fwrite($fd, "ttyu0 \"/usr/libexec/getty bootupcli\" cons25 off secure\n"); - } - } else { + if (stristr($tty, "ttyv0")) + fwrite($fd, "ttyv0 \"/usr/libexec/getty {$console_type}\" xterm on secure\n"); + else if (stristr($tty, "ttyu0")) + fwrite($fd, "ttyu0 \"/usr/libexec/getty {$seral_type}\" xterm {$on_off} secure\n"); + else fwrite($fd, $tty . "\n"); - } } + unset($on_off, $console_type, $serial_type); fclose($fd); - auto_login(); + reload_ttys(); conf_mount_ro(); return; } +function reload_ttys() { + // Send a HUP signal to init will make it reload /etc/ttys + posix_kill(1, SIGHUP); +} + function print_value_list($list, $count = 10, $separator = ",") { $list = implode($separator, array_slice($list, 0, $count)); if(count($list) < $count) { diff --git a/etc/phpshellsessions/gitsync b/etc/phpshellsessions/gitsync index 58f5ba5..6c39006 100644 --- a/etc/phpshellsessions/gitsync +++ b/etc/phpshellsessions/gitsync @@ -393,7 +393,7 @@ function post_cvssync_commands() { /* lock down console if necessary */ echo "===> Locking down the console if needed...\n"; - auto_login(); + reload_ttys(); echo "===> Signaling PHP and Lighty restart..."; $fd = fopen("/tmp/restart_lighty", "w"); diff --git a/etc/rc.bootup b/etc/rc.bootup index 612ff22..265effb 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -61,19 +61,19 @@ function rescue_detect_keypress() { } // If R or I was pressed do our logic here if (in_array($key, array("r", "R"))) { - putenv("TERM=cons25"); + putenv("TERM=xterm"); echo "\n\nRecovery mode selected...\n"; - passthru("/usr/bin/env TERM=cons25 /bin/tcsh -c /scripts/lua_installer_rescue"); + passthru("/usr/bin/env TERM=xterm /bin/tcsh -c /scripts/lua_installer_rescue"); } elseif (in_array($key, array("i", "I"))) { - putenv("TERM=cons25"); + putenv("TERM=xterm"); echo "\n\nInstaller mode selected...\n"; - passthru("/usr/bin/env TERM=cons25 /bin/tcsh -c /scripts/lua_installer"); + passthru("/usr/bin/env TERM=xterm /bin/tcsh -c /scripts/lua_installer"); if(file_exists("/tmp/install_complete")) { passthru("/etc/rc.reboot"); exit; } } elseif (in_array($key, array("!", "~"))) { - putenv("TERM=cons25"); + putenv("TERM=xterm"); echo "\n\nRecovery shell selected...\n"; echo "\n"; touch("/tmp/donotbootup"); @@ -375,7 +375,7 @@ services_snmpd_configure(); system_set_harddisk_standby(); /* lock down console if necessary */ -auto_login(); +reload_ttys(); /* load graphing functions */ enable_rrd_graphing(); diff --git a/etc/rc.initial b/etc/rc.initial index c57c0db..6b9885e 100755 --- a/etc/rc.initial +++ b/etc/rc.initial @@ -161,7 +161,7 @@ case ${opmode} in ;; 99) if [ -e /dev/ukbd0 ]; then - env TERM=cons25 /scripts/lua_installer + env TERM=xterm /scripts/lua_installer else /scripts/lua_installer fi |