diff options
author | Ted Trask <ttrask01@yahoo.com> | 2017-02-22 14:23:41 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2017-02-22 15:41:05 +0000 |
commit | 0aca3eec9586aa1ba46355731c4334c447da0288 (patch) | |
tree | d3422edd41894a01e8ef3c43942cf4f76b9e9868 | |
parent | 5f394ca87d695fcb4ee46930ef2f93907a858639 (diff) | |
download | acf-freeradius3-0aca3eec9586aa1ba46355731c4334c447da0288.tar.bz2 acf-freeradius3-0aca3eec9586aa1ba46355731c4334c447da0288.tar.xz |
Adjust passwd and macauth to check for files config at root
(cherry picked from commit a9e25de22f10a5521bd141bdebe76175ebec7a53)
-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 fd799a1..6530b05 100644 --- a/freeradius3-model.lua +++ b/freeradius3-model.lua @@ -109,19 +109,26 @@ local get_passwd_files = function() local configs local result,errtxt = get_config() if result 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 @@ -314,24 +321,31 @@ local get_macauth_files = function() local result,errtxt = get_config() if result 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 |