summaryrefslogtreecommitdiffstats
path: root/freeradius3-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'freeradius3-model.lua')
-rw-r--r--freeradius3-model.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/freeradius3-model.lua b/freeradius3-model.lua
index d3c9ca8..1606971 100644
--- a/freeradius3-model.lua
+++ b/freeradius3-model.lua
@@ -296,6 +296,36 @@ local update_passwd_entry_private = function(self, entry, create)
return entry
end
+local get_macauth_files = function()
+ local files
+ local result,errtxt = get_config()
+ if result then
+ -- Find the files by searching for modules / files / usersfile where key="%{Calling-Station-Id}"
+ files = {}
+ for i,first in ipairs(configtable) do
+ if string.find(first.name, "^modules$") then
+ for j,second in ipairs(first.value) do
+ if string.find(second.name, "^files ") then
+ local key,file
+ for k,third in ipairs(second.value) do
+ if string.find(third.name, "^usersfile$") then
+ file = third.value
+ elseif string.find(third.name, "^key$") and string.find(third.value, format.escapemagiccharacters("%{Calling-Station-Id}")) then
+ key = true
+ end
+ if key and file then
+ files[#files+1] = file
+ break
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return files, errtxt
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -557,4 +587,19 @@ function mymodule.update_passwd(self, passwd)
return passwd
end
+function mymodule.list_macauth_files()
+ local retval = {}
+ local files,errtxt = get_macauth_files()
+ if files then
+ for i,file in ipairs(files) do
+ local details = fs.stat(file)
+ details.filename = file
+ table.insert(retval, details)
+ end
+ table.sort(retval, function(a,b) return a.filename < b.filename end)
+ end
+
+ return cfe({ type="structure", value=retval, label="List of Freeradius MAC authentication files", errtxt=errtxt })
+end
+
return mymodule