From owner-svn-src-head@freebsd.org Sat Feb 24 20:00:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FFFBF0ADC9; Sat, 24 Feb 2018 20:00:32 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AAEB174028; Sat, 24 Feb 2018 20:00:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A28C52A1AB; Sat, 24 Feb 2018 20:00:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1OK0Vr8063603; Sat, 24 Feb 2018 20:00:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1OK0VxW063602; Sat, 24 Feb 2018 20:00:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802242000.w1OK0VxW063602@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 24 Feb 2018 20:00:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329923 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329923 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Feb 2018 20:00:32 -0000 Author: kevans Date: Sat Feb 24 20:00:31 2018 New Revision: 329923 URL: https://svnweb.freebsd.org/changeset/base/329923 Log: lualoader: Strip config.parse of its I/O privileges config.parse is now purely a parser, rather than a whole proccessor. The standard process for loading a config file has been split out into config.processFile. This clears the way for having nextboot read its own config file and decide there whether it should parse the rest of the file. Modified: head/stand/lua/config.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Sat Feb 24 19:51:18 2018 (r329922) +++ head/stand/lua/config.lua Sat Feb 24 20:00:31 2018 (r329923) @@ -134,7 +134,8 @@ local function check_nextboot() return text:match("^nextboot_enable=\"NO\"") == nil end - if not config.parse(nextboot_file, true, check_nextboot_enabled) then + if not config.processFile(nextboot_file, true, check_nextboot_enabled) + then -- This only fails if it actually hit a parse error print("Failed to parse nextboot configuration: '" .. nextboot_file .. "'") @@ -326,10 +327,7 @@ function config.loadmod(mod, silent) return status end --- silent runs will not return false if we fail to open the file --- check_and_halt, if it's set, will be executed on the full text of the config --- file. If it returns false, we are to halt immediately. -function config.parse(name, silent, check_and_halt) +function config.processFile(name, silent, check_and_halt) if silent == nil then silent = false end @@ -345,6 +343,14 @@ function config.parse(name, silent, check_and_halt) return true end end + + return config.parse(text) +end + +-- silent runs will not return false if we fail to open the file +-- check_and_halt, if it's set, will be executed on the full text of the config +-- file. If it returns false, we are to halt immediately. +function config.parse(text) local n = 1 local status = true @@ -473,7 +479,7 @@ function config.load(file) file = "/boot/defaults/loader.conf" end - if not config.parse(file) then + if not config.processFile(file) then print("Failed to parse configuration: '" .. file .. "'") end @@ -483,7 +489,7 @@ function config.load(file) -- These may or may not exist, and that's ok. Do a -- silent parse so that we complain on parse errors but -- not for them simply not existing. - if not config.parse(name, true) then + if not config.processFile(name, true) then print("Failed to parse configuration: '" .. name .. "'") end