diff options
author | Ted Trask <ttrask01@yahoo.com> | 2017-02-22 14:23:41 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2017-02-22 14:23:41 +0000 |
commit | a9e25de22f10a5521bd141bdebe76175ebec7a53 (patch) | |
tree | 7c21e5889ba537d4308fa1802e6fd0a37b7e3392 | |
parent | 97a93a241431868e7c03f8b59de02a0c904e534f (diff) | |
download | acf-freeradius3-a9e25de22f10a5521bd141bdebe76175ebec7a53.tar.bz2 acf-freeradius3-a9e25de22f10a5521bd141bdebe76175ebec7a53.tar.xz |
Adjust passwd and macauth to check for files config at root
-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 |