diff options
author | Ted Trask <ttrask01@yahoo.com> | 2014-09-15 18:08:14 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2014-09-15 18:08:14 +0000 |
commit | 2e34d7b6a7eeea84694a987606758bce3d3994ed (patch) | |
tree | d0ca8ffbfcb2724a031a5e3632fdc6a887ac6914 /freeradius3-model.lua | |
parent | bb693ddd74d12f55487b16eab7da40fc2ff13988 (diff) | |
download | acf-freeradius3-2e34d7b6a7eeea84694a987606758bce3d3994ed.tar.bz2 acf-freeradius3-2e34d7b6a7eeea84694a987606758bce3d3994ed.tar.xz |
Implemented listmacauthfiles action
Points to to-be-implemented editmacauthfile action
Diffstat (limited to 'freeradius3-model.lua')
-rw-r--r-- | freeradius3-model.lua | 45 |
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 |