Date: Fri, 4 Jul 2014 02:34:49 GMT From: pedrosouza@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r270421 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua Message-ID: <201407040234.s642YnkJ097102@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pedrosouza Date: Fri Jul 4 02:34:49 2014 New Revision: 270421 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=270421 Log: Added password.lua Added: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/password.lua Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/core.lua Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/core.lua ============================================================================== --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/core.lua Fri Jul 4 02:27:33 2014 (r270420) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/core.lua Fri Jul 4 02:34:49 2014 (r270421) @@ -72,4 +72,8 @@ core.setSafeMode(false); core.setSingleUser(false); core.setVerbose(false); +end + +function core.autoboot() + loader.perform("autoboot"); end \ No newline at end of file Added: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/password.lua ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/password.lua Fri Jul 4 02:34:49 2014 (r270421) @@ -0,0 +1,49 @@ +include("/boot/core.lua"); +password = {}; + +function password.read() + local str = ""; + local n = 0; + + repeat + ch = io.getchar(); + if ch == 13 then break; end + + if ch == 8 then + if n > 0 then + n = n - 1; + print("\008"); + str = string.sub(str, 1, n); + end + else + print("*"); + str = str .. string.char(ch); + n = n + 1; + end + until n == 16 + return str; +end + +function password.check() + local boot_pwd = loader.getenv("bootlock_password"); + if boot_pwd ~= nil then + while true do + print("Boot password: "); + if boot_pwd == password.read() then break; end + print("\nloader: incorrect password!\n"); + loader.delay(3*1000*1000); + end + end + + local pwd = loader.getenv("password"); + if (pwd == nil) then return; end + + core.autoboot(); + + while true do + print("Password: "); + if pwd == password.read() then break; end + print("\nloader: incorrect password!\n"); + loader.delay(3*1000*1000); + end +end \ No newline at end of file
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407040234.s642YnkJ097102>