Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Jun 2018 01:38:53 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334907 - head/stand/lua
Message-ID:  <201806100138.w5A1crbu058328@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Sun Jun 10 01:38:52 2018
New Revision: 334907
URL: https://svnweb.freebsd.org/changeset/base/334907

Log:
  lualoader: Process loader_conf_files properly
  
  loader.conf(5) documents loader_conf_files to mean "additional configuration
  files to be processed right after the present file." However, lualoader
  ignored loader_conf_files after processing /boot/defaults/loader.conf.
  
  Rewrite these bits to process loader_conf_files after each loaded file.

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==============================================================================
--- head/stand/lua/config.lua	Sun Jun 10 00:02:56 2018	(r334906)
+++ head/stand/lua/config.lua	Sun Jun 10 01:38:52 2018	(r334907)
@@ -250,7 +250,34 @@ local function loadModule(mod, silent)
 	return status
 end
 
+local function readConfFiles(loaded_files)
+	local f = loader.getenv("loader_conf_files")
+	if f ~= nil then
+		for name in f:gmatch("([%w%p]+)%s*") do
+			if loaded_files[name] ~= nil then
+				goto continue
+			end
 
+			local prefiles = loader.getenv("loader_conf_files")
+
+			print("Loading " .. name)
+			-- 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.processFile(name, true) then
+				print(MSG_FAILPARSECFG:format(name))
+			end
+
+			loaded_files[name] = true
+			local newfiles = loader.getenv("loader_conf_files")
+			if prefiles ~= newfiles then
+				readConfFiles(loaded_files)
+			end
+			::continue::
+		end
+	end
+end
+
 local function readFile(name, silent)
 	local f = io.open(name)
 	if f == nil then
@@ -467,17 +494,8 @@ function config.load(file, reloading)
 		print(MSG_FAILPARSECFG:format(file))
 	end
 
-	local f = loader.getenv("loader_conf_files")
-	if f ~= nil then
-		for name in f:gmatch("([%w%p]+)%s*") do
-			-- 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.processFile(name, true) then
-				print(MSG_FAILPARSECFG:format(name))
-			end
-		end
-	end
+	local loaded_files = {file = true}
+	readConfFiles(loaded_files)
 
 	checkNextboot()
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806100138.w5A1crbu058328>