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:29:21 +0000 |
commit | 7757fa24b1231b6247599bd913142537a9e8e8b5 (patch) | |
tree | 4034250d8b7fda4fa1b703f3cf5c0bf5e481b5f6 /freeradius3-model.lua | |
parent | 075a3004502f4a195354bc8f8332a8336c3c82a1 (diff) | |
download | acf-freeradius3-7757fa24b1231b6247599bd913142537a9e8e8b5.tar.bz2 acf-freeradius3-7757fa24b1231b6247599bd913142537a9e8e8b5.tar.xz |
Adjust passwd and macauth to check for files config at root
(cherry picked from commit a9e25de22f10a5521bd141bdebe76175ebec7a53)
Diffstat (limited to 'freeradius3-model.lua')
-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 84bd7e5..d0731e2 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 |