From owner-svn-soc-all@FreeBSD.ORG Sat Aug 2 16:39:05 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 B5BEB2B4; Sat, 2 Aug 2014 16:39:05 +0000 (UTC) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E25FA2223; Sat, 2 Aug 2014 16:39:04 +0000 (UTC) Received: by mail-wi0-f179.google.com with SMTP id f8so2835364wiw.0 for ; Sat, 02 Aug 2014 09:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=f/Xb0iFPH/FXNpQaeWrdJSGfSVIDMidDzmBbEFm5+3g=; b=bNmHdHIevkaWToZYvoEWkLBNbdRw8bUzDKzKZ3PPftTaoSSgdzO0/8SLzxV89hCgHH BMIGyDnISiPfB+M5QyYA1RnfGmOKzu6KCpcuhWC6wdwPkWb7ipl6dyCl9o6DUKMsiEd+ VntDl1AMX36JzYJvYtDmbsrXqFgWdJ08ocw+kD7q5yYgTQyu9mEh7cXXdbqqAfMWkEiV Ik36GrcGytu37vqL7KtLdExM02NmOF8BxvIwST+4KQsHTHyzx/Fbvr3GOU6E3Af6Odra mR8YI1iPwSbqBVIaus3aYs6S64HErBAhVHAhJ4DolGzaScshQ2zrpsPc0spkq7ly6Vyb mh6Q== MIME-Version: 1.0 X-Received: by 10.194.121.6 with SMTP id lg6mr18910531wjb.116.1406997543188; Sat, 02 Aug 2014 09:39:03 -0700 (PDT) Received: by 10.194.185.239 with HTTP; Sat, 2 Aug 2014 09:39:03 -0700 (PDT) In-Reply-To: <20140802053708.GB98217@FreeBSD.org> References: <201407301950.s6UJovS1023444@socsvn.freebsd.org> <20140802053708.GB98217@FreeBSD.org> Date: Sat, 2 Aug 2014 13:39:03 -0300 Message-ID: Subject: Re: socsvn commit: r271623 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua From: Pedro Arthur To: "Wojciech A. Koszek" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18 Cc: svn-soc-all@freebsd.org, pedrosouza@freebsd.org 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: Sat, 02 Aug 2014 16:39:05 -0000 Thanks for the tips, I'll start checking the password code to not be bypassed. 2014-08-02 2:37 GMT-03:00 Wojciech A. Koszek : > On Wed, Jul 30, 2014 at 07:50:57PM +0000, pedrosouza@freebsd.org wrote: > > Author: pedrosouza > > Date: Wed Jul 30 19:50:56 2014 > > New Revision: 271623 > > URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271623 > > > > Log: > > Added boot menu shortcuts > > > > Pedro, > > I walked through all your last commits. > > All your work looks pretty good. I don't see anything fundamentally wrong > in > code your wrote. If I were to give feedback, in the order of priority: > > The most crucial part would be to make sure password checking can't be > ommited. Thus we should try to do rigorous testing there. We should also > check if by doing strange things we can crash the Lua in a way that would > skip password checking. Make sure we catch all exceptions and error > conditions there. > > To make this code easily mergable, we should probably target > src/sys/lua/. This way you can make 'lua*' utilities available to > users. Alternatively: src/sys/contrib/lua/. > > It should be plain Lua source code, so that upgrading to new Luas as they > get released would be as simple as unpacking the .tar.bz2 there. The > FreeBSD > wrapper for Lua loader could live in src/sys/boot/lua. > > Think whether you also feel 80x25 rule for Lua code should be preserved. At > some point we could also start lua.style.8 man page. > > Thanks for all this work. It's nice to see coming nicely along. > > Wojciech > > > Modified: > > soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua > > soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > > > > Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua > > > ============================================================================== > > --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 > 18:47:31 2014 (r271622) > > +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Wed Jul 30 > 19:50:56 2014 (r271623) > > @@ -8,13 +8,16 @@ > > screen.setcursor(x, y); > > print("Boot Menu"); > > for k, v in pairs(opts) do > > - screen.setcursor(x, y + v.index); > > - local name = v.name; > > - > > - if (name == nil) then > > - name = v.getName(); > > + -- skip alias > > + if k ~= "alias" then > > + screen.setcursor(x, y + v.index); > > + local name = v.name; > > + > > + if (name == nil) then > > + name = v.getName(); > > + end > > + print(k .. " - " .. name); > > end > > - print(k .. " - " .. name); > > end > > end > > > > @@ -29,6 +32,7 @@ > > menu.drawbox(4, 10, 40, 10); > > drawer.drawbrand(); > > drawer.drawlogo(); > > + screen.defcursor(); > > local ch = string.char(io.getchar()); > > if (opts[ch] ~= nil) then > > local ret = opts[ch].func(); > > @@ -36,6 +40,17 @@ > > print("Exiting menu!\n"); > > return; > > end > > + else > > + --try alias key > > + if opts.alias ~= nil then > > + if opts.alias[ch] ~= nil then > > + local ret = opts.alias[ch].func(); > > + if (ret) then > > + print("Exiting menu!\n"); > > + return; > > + end > > + end > > + end > > end > > end > > end > > @@ -65,26 +80,39 @@ > > end > > > > menu.options = { > > - ["1"] = {index = 1, name = "Boot Multi user", func = function > () core.setSingleUser(false); loader.perform("boot"); end}, > > - ["2"] = {index = 2, name = "Boot Single user", func = function > () core.setSingleUser(true); loader.perform("boot"); end}, > > - ["3"] = {index = 3, name = "Escape to lua interpreter", func = > function () return true; end}, > > - ["4"] = {index = 4, name = "Reboot", func = function > () loader.perform("reboot"); end}, > > - ["5"] = {index = 5, name = "Boot Options", func = function > () menu.run(boot_options); return false; end} > > + -- Boot multi user > > + ["1"] = {index = 1, name = color.highlight("B").."oot Multi user", > func = function () core.setSingleUser(false); loader.perform("boot"); end}, > > + -- boot single user > > + ["2"] = {index = 2, name = "Boot "..color.highlight("S").."ingle > user", func = function () core.setSingleUser(true); > loader.perform("boot"); end}, > > + -- escape to interpreter > > + ["3"] = {index = 3, name = color.highlight("E").."scape to lua > interpreter", func = function () return true; end}, > > + -- reboot > > + ["4"] = {index = 4, name = color.highlight("R").."eboot", func = > function () loader.perform("reboot"); end}, > > + -- boot options > > + ["5"] = {index = 5, name = "Boot "..color.highlight("O").."ptions", > func = function () menu.run(boot_options); return false; end} > > +}; > > + > > +menu.options.alias = { > > + ["b"] = menu.options["1"], > > + ["s"] = menu.options["2"], > > + ["e"] = menu.options["3"], > > + ["r"] = menu.options["4"], > > + ["o"] = menu.options["5"] > > }; > > > > function OnOff(str, b) > > if (b) then > > - return str .. color.escapef(color.GREEN)..": > On"..color.escapef(color.WHITE); > > + return str .. > color.escapef(color.GREEN).."On"..color.escapef(color.WHITE); > > else > > - return str .. color.escapef(color.RED)..": > Off"..color.escapef(color.WHITE); > > + return str .. > color.escapef(color.RED).."Off"..color.escapef(color.WHITE); > > end > > end > > > > boot_options = { > > ["1"] = {index = 1, name = "Back to menu", func = function () > return true; end }, > > ["2"] = {index = 2, name = "Load System defaults", func = function > () core.setDefaults(); return false; end }, > > - ["3"] = {index = 3, getName = function () return OnOff("ACPI > ", core.acpi); end, func = function () core.setACPI(); return false; end }, > > - ["4"] = {index = 4, getName = function () return OnOff("Safe Mode > ", core.sm); end, func = function () core.setSafeMode(); return false; > end }, > > - ["5"] = {index = 5, getName = function () return OnOff("Single > user", core.su); end, func = function () core.setSingleUser(); return > false; end }, > > - ["6"] = {index = 6, getName = function () return OnOff("Verbose > ", core.verbose); end, func = function () core.setVerbose(); return false; > end } > > + ["3"] = {index = 3, getName = function () return OnOff("ACPI > :", core.acpi); end, func = function () core.setACPI(); return false; end }, > > + ["4"] = {index = 4, getName = function () return OnOff("Safe Mode > :", core.sm); end, func = function () core.setSafeMode(); return > false; end }, > > + ["5"] = {index = 5, getName = function () return OnOff("Single > user:", core.su); end, func = function () core.setSingleUser(); return > false; end }, > > + ["6"] = {index = 6, getName = function () return OnOff("Verbose > :", core.verbose); end, func = function () core.setVerbose(); return > false; end } > > } > > \ No newline at end of file > > > > Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > > > ============================================================================== > > --- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > Wed Jul 30 18:47:31 2014 (r271622) > > +++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua > Wed Jul 30 19:50:56 2014 (r271623) > > @@ -32,6 +32,10 @@ > > return "\027[0;37;40m"; > > end > > > > +function color.highlight(str) > > + return "\027[1m"..str.."\027[0m"; > > +end > > + > > function screen.clear() > > print("\027[H\027[J"); > > end > > @@ -53,5 +57,5 @@ > > end > > > > function screen.defcursor() > > - print("\027[24;0H"); > > + print("\027[25;0H"); > > end > > \ No newline at end of file > > _______________________________________________ > > svn-soc-all@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/svn-soc-all > > To unsubscribe, send any mail to "svn-soc-all-unsubscribe@freebsd.org" > > -- > Wojciech A. Koszek > wkoszek@FreeBSD.czest.pl > http://FreeBSD.czest.pl/~wkoszek/ >