git: ec86d763d1c9 - main - sys/tools/syscalls: desupport capabilities.conf

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Wed, 30 Oct 2024 21:08:58 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=ec86d763d1c94648419aeb931683dcb37bf72656

commit ec86d763d1c94648419aeb931683dcb37bf72656
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-10-22 17:59:23 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-10-30 21:04:31 +0000

    sys/tools/syscalls: desupport capabilities.conf
    
    We haven't used this since commit be67ea40c5a0 in 2021 so stop carrying
    it forward.
    
    Also remove support for setting the list in syscalls.conf via the
    capenabled variable.  This was last used by cloudabi (removed in 2021
    by commit cf0ee8738e31).
---
 sys/tools/syscalls/config.lua                | 51 +---------------------------
 sys/tools/syscalls/core/syscall.lua          | 11 ++----
 sys/tools/syscalls/main.lua                  |  1 -
 sys/tools/syscalls/scripts/init_sysent.lua   |  1 -
 sys/tools/syscalls/scripts/libsys_h.lua      |  1 -
 sys/tools/syscalls/scripts/syscall_h.lua     |  1 -
 sys/tools/syscalls/scripts/syscall_mk.lua    |  1 -
 sys/tools/syscalls/scripts/syscalls.lua      |  1 -
 sys/tools/syscalls/scripts/syscalls_map.lua  |  1 -
 sys/tools/syscalls/scripts/sysproto_h.lua    |  1 -
 sys/tools/syscalls/scripts/systrace_args.lua |  1 -
 11 files changed, 4 insertions(+), 67 deletions(-)

diff --git a/sys/tools/syscalls/config.lua b/sys/tools/syscalls/config.lua
index 92098a709854..fcf4c2217959 100644
--- a/sys/tools/syscalls/config.lua
+++ b/sys/tools/syscalls/config.lua
@@ -47,10 +47,8 @@ local config = {
 	ptr_intptr_t_cast = "intptr_t",
 	obsol = {},
 	unimpl = {},
-	capabilities_conf = "capabilities.conf",
 	compat_set = "native",
 	mincompat = 0,
-	capenabled = {},
 	-- System calls that require ABI-specific handling.
 	syscall_abi_change = {},
 	-- System calls that appear to require handling, but don't.
@@ -222,8 +220,7 @@ function config.merge(fh)
 				-- Match for pipe, that's how abi_flags
 				-- is formatted.
 				config[k] = util.setFromString(v, "[^|]+")
-			elseif k:find("capenabled") or
-			    k:find("syscall_abi_change") or
+			elseif k:find("syscall_abi_change") or
 			    k:find("syscall_no_abi_change") or
 			    k:find("obsol") or
 			    k:find("unimpl") then
@@ -263,50 +260,4 @@ function config.mergeCompat()
 	end
 end
 
--- Parses the provided capabilities.conf. Returns a string (comma separated
--- list) as its formatted in capabilities.conf, or NIL and a message if no file
--- was provided.
-local function grabCapenabled(file, open_fail_ok)
-	local capentries = {}
-	local commentExpr = "#.*"
-
-	if file == nil then
-		return nil, "No file given"
-	end
-
-	local fh, msg, errno = io.open(file)
-	if fh == nil then
-		if not open_fail_ok then
-			util.abort(errno, msg)
-		end
-		return nil, msg
-	end
-
-	for nextline in fh:lines() do
-		-- Strip any comments.
-		nextline = nextline:gsub(commentExpr, "")
-		if nextline ~= "" then
-			capentries[nextline] = true
-		end
-	end
-
-	assert(fh:close())
-	return capentries
-end
-
--- Merge capability (Capsicum) configuration into the global config.
-function config.mergeCapability()
-	-- We ignore errors here if we're relying on the default configuration.
-	if not config.modifications.capenabled then
-		config.capenabled = grabCapenabled(config.capabilities_conf,
-		    config.modifications.capabilities_conf == nil)
-	elseif config.capenabled ~= "" then
-		-- We have a comma separated list from the format of
-		-- capabilities.conf, split it into a set with boolean values
-		-- for each key.
-		config.capenabled = util.setFromString(config.capenabled,
-		    "[^,]+")
-	end
-end
-
 return config
diff --git a/sys/tools/syscalls/core/syscall.lua b/sys/tools/syscalls/core/syscall.lua
index 7e8c562dad8a..402595b998da 100644
--- a/sys/tools/syscalls/core/syscall.lua
+++ b/sys/tools/syscalls/core/syscall.lua
@@ -48,14 +48,9 @@ end
 function syscall:processCap()
 	self.cap = "0"
 	local stripped = util.stripAbiPrefix(self.name, self.prefix)
-	if config.capenabled ~= nil and (config.capenabled[self.name] ~= nil or
-		config.capenabled[stripped] ~= nil) then
-		self.cap = "SYF_CAPENABLED"
-	else
-		for k, _ in pairs(self.type) do
-			if k == "CAPENABLED" then
-				self.cap = "SYF_CAPENABLED"
-			end
+	for k, _ in pairs(self.type) do
+		if k == "CAPENABLED" then
+			self.cap = "SYF_CAPENABLED"
 		end
 	end
 end
diff --git a/sys/tools/syscalls/main.lua b/sys/tools/syscalls/main.lua
index 8f791eec0943..b15eec095f9c 100755
--- a/sys/tools/syscalls/main.lua
+++ b/sys/tools/syscalls/main.lua
@@ -40,7 +40,6 @@ local sysfile, configfile = arg[1], arg[2]
 
 config.merge(configfile)
 config.mergeCompat()
-config.mergeCapability()
 
 local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
 
diff --git a/sys/tools/syscalls/scripts/init_sysent.lua b/sys/tools/syscalls/scripts/init_sysent.lua
index 106c51be5f8a..66683250b482 100755
--- a/sys/tools/syscalls/scripts/init_sysent.lua
+++ b/sys/tools/syscalls/scripts/init_sysent.lua
@@ -180,7 +180,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed syscall table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/libsys_h.lua b/sys/tools/syscalls/scripts/libsys_h.lua
index 18ffc68fded6..75627f08750f 100755
--- a/sys/tools/syscalls/scripts/libsys_h.lua
+++ b/sys/tools/syscalls/scripts/libsys_h.lua
@@ -98,7 +98,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed syscall table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/syscall_h.lua b/sys/tools/syscalls/scripts/syscall_h.lua
index ce5ffcec4b94..5f8d8fb66889 100755
--- a/sys/tools/syscalls/scripts/syscall_h.lua
+++ b/sys/tools/syscalls/scripts/syscall_h.lua
@@ -84,7 +84,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed system call table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/syscall_mk.lua b/sys/tools/syscalls/scripts/syscall_mk.lua
index d4347a050cf1..68438ee8d90c 100755
--- a/sys/tools/syscalls/scripts/syscall_mk.lua
+++ b/sys/tools/syscalls/scripts/syscall_mk.lua
@@ -77,7 +77,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed syscall table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/syscalls.lua b/sys/tools/syscalls/scripts/syscalls.lua
index b1a3d1020f88..38ed396a73ae 100755
--- a/sys/tools/syscalls/scripts/syscalls.lua
+++ b/sys/tools/syscalls/scripts/syscalls.lua
@@ -96,7 +96,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed syscall table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/syscalls_map.lua b/sys/tools/syscalls/scripts/syscalls_map.lua
index 4108d9f46fcf..57bb5e9da93b 100755
--- a/sys/tools/syscalls/scripts/syscalls_map.lua
+++ b/sys/tools/syscalls/scripts/syscalls_map.lua
@@ -61,7 +61,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed syscall table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/sysproto_h.lua b/sys/tools/syscalls/scripts/sysproto_h.lua
index d4fc30c31292..6770e0548899 100755
--- a/sys/tools/syscalls/scripts/sysproto_h.lua
+++ b/sys/tools/syscalls/scripts/sysproto_h.lua
@@ -229,7 +229,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed system call table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
diff --git a/sys/tools/syscalls/scripts/systrace_args.lua b/sys/tools/syscalls/scripts/systrace_args.lua
index abd5d284d46e..88170b85e737 100755
--- a/sys/tools/syscalls/scripts/systrace_args.lua
+++ b/sys/tools/syscalls/scripts/systrace_args.lua
@@ -255,7 +255,6 @@ if script then
 
 	config.merge(configfile)
 	config.mergeCompat()
-	config.mergeCapability()
 
 	-- The parsed system call table.
 	local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}