From owner-svn-soc-all@FreeBSD.ORG Fri Jul 4 02:34:50 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 832D83DB for ; Fri, 4 Jul 2014 02:34:50 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54EE5215A for ; Fri, 4 Jul 2014 02:34:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s642Yo3C097434 for ; Fri, 4 Jul 2014 02:34:50 GMT (envelope-from pedrosouza@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.8/8.14.8/Submit) id s642YnkJ097102 for svn-soc-all@FreeBSD.org; Fri, 4 Jul 2014 02:34:49 GMT (envelope-from pedrosouza@FreeBSD.org) Date: Fri, 4 Jul 2014 02:34:49 GMT Message-Id: <201407040234.s642YnkJ097102@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pedrosouza@FreeBSD.org using -f From: pedrosouza@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r270421 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jul 2014 02:34:50 -0000 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