Project

General

Profile

« Previous | Next » 

Revision d99f9393

Added by Phil Davis over 12 years ago

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.
This version is for RELENG_2_0 branch.
Tested on Alix nanobsd system running 2.0.2

View differences:

etc/inc/pfsense-utils.inc
933 933

  
934 934
	$gettytab = file_get_contents("/etc/gettytab");
935 935
	$getty_split = split("\n", $gettytab);
936
	$getty_update_needed = false;
937
	$getty_search_str = ":ht:np:sp#115200";
938
	$getty_al_str = ":al=root:";
939
	$getty_al_search_str = $getty_search_str . $getty_al_str;
940
	/* Check if gettytab is already OK, if so then do not rewrite it. */
941
	foreach($getty_split as $gs) {
942
		if(stristr($gs, $getty_search_str)) {
943
			if($status == true) {
944
				if(!stristr($gs, $getty_al_search_str)) {
945
					$getty_update_needed = true;
946
				}
947
			} else {
948
				if(stristr($gs, $getty_al_search_str)) {
949
					$getty_update_needed = true;
950
				}
951
			}
952
		}
953
	}
954

  
955
	if (!$getty_update_needed) {
956
		return;
957
	}
958

  
936 959
	conf_mount_rw();
937 960
	$fd = false;
938 961
	$tries = 0;
......
943 966
	}
944 967
	if (!$fd) {
945 968
		conf_mount_ro();
946
		log_error("Enabling auto login was not possible.");
969
		if ($status) {
970
			log_error(gettext("Enabling auto login was not possible."));
971
		} else {
972
			log_error(gettext("Disabling auto login was not possible."));
973
		}
947 974
		return;
948 975
	}
949 976
	foreach($getty_split as $gs) {
950
		if(stristr($gs, ":ht:np:sp#115200") ) {
977
		if(stristr($gs, $getty_search_str)) {
951 978
			if($status == true) {
952
				fwrite($fd, "	:ht:np:sp#115200:al=root:\n");
979
				fwrite($fd, "	".$getty_al_search_str."\n");
953 980
			} else {
954
				fwrite($fd, "	:ht:np:sp#115200:\n");
981
				fwrite($fd, "	".$getty_search_str."\n");
955 982
			}
956 983
		} else {
957 984
			fwrite($fd, "{$gs}\n");
958 985
		}
959 986
	}
960 987
	fclose($fd);
988

  
989
	if ($status) {
990
		log_error(gettext("Enabled console auto login, console menu is NOT password protected."));
991
	} else {
992
		log_error(gettext("Disabled console auto login, console menu is password protected."));
993
	}
994
	
961 995
	conf_mount_ro();
962 996
}
963 997

  

Also available in: Unified diff