summaryrefslogtreecommitdiffstats
path: root/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2014-07-01 13:37:42 -0300
committerRenato Botelho <garga@FreeBSD.org>2014-07-01 13:37:42 -0300
commitedb4b65732d76810e5610bcece85571f13969fc0 (patch)
tree82477daac59a01793850182a401fb8d9899e4fa8 /etc/inc/pfsense-utils.inc
parent6f9a191d76aa837d727fe047c67aae5829fede16 (diff)
downloadpfsense-edb4b65732d76810e5610bcece85571f13969fc0.zip
pfsense-edb4b65732d76810e5610bcece85571f13969fc0.tar.gz
Fix #3647 and other improvements:
- Remove auto_login(), now gettytab is a constant file - Add reload_ttys(), that will send a SIGHUP to init and make it reload /etc/ttys - Change serial speed on /etc/ttys when necessary - Change console and serial auto_login on /etc/ttys when necessary - Change default type from cons25 to xterm
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r--etc/inc/pfsense-utils.inc101
1 files changed, 20 insertions, 81 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) {
OpenPOWER on IntegriCloud