summaryrefslogtreecommitdiffstats
path: root/squid-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2011-07-20 14:26:02 +0000
committerTed Trask <ttrask01@yahoo.com>2011-07-20 14:26:02 +0000
commita919b6b5fe537a7406d4081b7de8c4cb9e305743 (patch)
treef70eb78da876bc73a1a6088695a12b10739f0d11 /squid-model.lua
parent10fc2373e150a42f7904b67d21564145678efe0f (diff)
downloadacf-squid-a919b6b5fe537a7406d4081b7de8c4cb9e305743.tar.bz2
acf-squid-a919b6b5fe537a7406d4081b7de8c4cb9e305743.tar.xz
Prevent config from uncommenting multiple access_log or cache_dir lines, report error instead
Diffstat (limited to 'squid-model.lua')
-rw-r--r--squid-model.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/squid-model.lua b/squid-model.lua
index 43c333e..2523462 100644
--- a/squid-model.lua
+++ b/squid-model.lua
@@ -195,17 +195,18 @@ end
update_config = function(newconfig)
local success, newconfig = validate_config(newconfig)
+
+ local lastport, lastlog, lastcache, lastauth
+ local didports = {}
+ local didlog, didcache
+ local didauths = {}
+ local lines = {}
+
if success then
configcontent = configcontent or fs.read_file(squidconf) or ""
-
- local lastport, lastlog, lastcache, lastauth
- local didports = {}
- local didlog, didcache
- local didauths = {}
local reverseports = {} for i,port in ipairs(newconfig.value.httpports.value) do reverseports[port] = i end
local reverseauths = {} for i,auth in ipairs(newconfig.value.authmethod.value) do reverseauths[auth] = i end
- local lines = {}
-- first loop to comment out / uncomment existing lines
local linenum = 0
for line in string.gmatch(configcontent, "([^\n]*)\n?") do
@@ -226,6 +227,10 @@ update_config = function(newconfig)
if (newconfig.value.accesslog.value and second == "none")
or (not newconfig.value.accesslog.value and second ~= "none") then
line = "# "..line
+ elseif didlog then
+ success = false
+ newconfig.value.accesslog.errtxt = "There are multiple access_log lines"
+ break
else
didlog = true
end
@@ -235,6 +240,10 @@ update_config = function(newconfig)
if (newconfig.value.diskcache.value and second == "null")
or (not newconfig.value.diskcache.value and second ~= "null") then
line = "# "..line
+ elseif didcache then
+ success = false
+ newconfig.value.diskcache.errtxt = "There are multiple cache_dir lines"
+ break
else
didcache = true
end
@@ -252,7 +261,8 @@ update_config = function(newconfig)
end
lines[#lines+1] = line
end
-
+ end
+ if success then
-- We've gone through the file, now check to see if everything is done
local tobedone = {}
local line