From owner-svn-soc-all@FreeBSD.ORG Sat Aug 2 06:02:14 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 2F1A558E; Sat, 2 Aug 2014 06:02:14 +0000 (UTC) Received: from freebsd.czest.pl (freebsd.czest.pl [212.87.224.105]) (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 61DA52F76; Sat, 2 Aug 2014 06:02:10 +0000 (UTC) Received-SPF: pass (freebsd.czest.pl: domain of wkoszek@freebsd.czest.pl designates 212.87.224.105 as permitted sender) receiver=freebsd.czest.pl; client-ip=212.87.224.105; helo=freebsd.czest.pl; envelope-from=wkoszek@freebsd.czest.pl; x-software=spfmilter 0.97 http://www.acme.com/software/spfmilter/ with libspf-unknown; Received: from freebsd.czest.pl (freebsd.czest.pl [212.87.224.105]) by freebsd.czest.pl (8.14.5/8.14.5) with ESMTP id s725b8Dm022960; Sat, 2 Aug 2014 05:37:08 GMT (envelope-from wkoszek@freebsd.czest.pl) Received: (from wkoszek@localhost) by freebsd.czest.pl (8.14.5/8.14.5/Submit) id s725b8sX022959; Sat, 2 Aug 2014 05:37:08 GMT (envelope-from wkoszek) Date: Sat, 2 Aug 2014 05:37:08 +0000 From: "Wojciech A. Koszek" To: pedrosouza@freebsd.org Subject: Re: socsvn commit: r271623 - soc2014/pedrosouza/lua_loader/head/sys/boot/lua Message-ID: <20140802053708.GB98217@FreeBSD.org> References: <201407301950.s6UJovS1023444@socsvn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201407301950.s6UJovS1023444@socsvn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on freebsd.czest.pl X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (freebsd.czest.pl [212.87.224.105]); Sat, 02 Aug 2014 05:37:12 +0000 (UTC) Cc: svn-soc-all@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 06:02:14 -0000 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/