diff options
-rw-r--r-- | freeradius3-model.lua | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/freeradius3-model.lua b/freeradius3-model.lua index f56951c..c7ac6e7 100644 --- a/freeradius3-model.lua +++ b/freeradius3-model.lua @@ -144,19 +144,26 @@ local get_passwd_files = function() configtable,errtxt = get_config() end if configtable then - -- Find the files by searching for modules / passwd + -- Find the files by searching for [modules] / passwd files = {} configs = {} + + function checkpasswd(value) + for k,third in ipairs(value) do + if string.find(third.name, "^filename$") then + files[#files+1] = third.value + configs[#configs+1] = value + end + end + end + for i,first in ipairs(configtable) do - if string.find(first.name, "^modules$") then + if string.find(first.name, "^passwd ") then + checkpasswd(first.value) + elseif string.find(first.name, "^modules$") then for j,second in ipairs(first.value) do if string.find(second.name, "^passwd ") then - for k,third in ipairs(second.value) do - if string.find(third.name, "^filename$") then - files[#files+1] = third.value - configs[#configs+1] = second.value - end - end + checkpasswd(second.value) end end end @@ -352,24 +359,31 @@ local get_macauth_files = function() configtable,errtxt = get_config() end if configtable then - -- Find the files by searching for modules / files / usersfile where key="%{Calling-Station-Id}" + -- Find the files by searching for [modules] / files / usersfile where key="%{Calling-Station-Id}" macauthfiles = {} + + function checkfiles(value) + local key,file + for k,third in ipairs(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 + macauthfiles[#macauthfiles+1] = file + break + end + end + end + for i,first in ipairs(configtable) do - if string.find(first.name, "^modules$") then + if string.find(first.name, "^files ") then + checkfiles(first.value) + elseif 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 - macauthfiles[#macauthfiles+1] = file - break - end - end + checkfiles(second.value) end end end |