diff options
author | Phil Davis <phil.davis@world.inf.org> | 2013-01-03 12:47:13 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@world.inf.org> | 2013-01-03 12:47:13 +0545 |
commit | adc0f2fe63c53182012d8d928181156c9bc6855e (patch) | |
tree | 257e9796362d43009399cab54c4d3aace3be03e2 /etc/inc/pfsense-utils.inc | |
parent | 5d6495a7a4ec58d2c17b97064f82ec672428a5b6 (diff) | |
download | pfsense-adc0f2fe63c53182012d8d928181156c9bc6855e.zip pfsense-adc0f2fe63c53182012d8d928181156c9bc6855e.tar.gz |
Minimise rewriting of /etc/gettytab
See forum http://forum.pfsense.org/index.php/topic,57325.0.html
Avoid possible problems with having a partial /etc/gettytab file by not rewriting it at every boot.
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index c352f53..9ebf3c1 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -914,6 +914,29 @@ function auto_login() { $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; @@ -924,21 +947,32 @@ function auto_login() { } if (!$fd) { conf_mount_ro(); - log_error(gettext("Enabling auto login was not possible.")); + 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, ":ht:np:sp#115200") ) { + if(stristr($gs, $getty_search_str)) { if($status == true) { - fwrite($fd, " :ht:np:sp#115200:al=root:\n"); + fwrite($fd, " ".$getty_al_search_str."\n"); } else { - fwrite($fd, " :ht:np:sp#115200:\n"); + 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(); } |