summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-04 13:34:35 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-04 13:34:35 +0000
commit68ade567b5cf06b108e91b0b35b6a2c87b33357c (patch)
treea5e0b68a13d0211f0c21e26d2e97e2882e5eea65
parent28b2f161ead0e80d600af2663d3b5b36f1607458 (diff)
downloadacf-snort-68ade567b5cf06b108e91b0b35b6a2c87b33357c.tar.bz2
acf-snort-68ade567b5cf06b108e91b0b35b6a2c87b33357c.tar.xz
Show config errors in expert-tab.
git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@930 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--snort-model.lua55
1 files changed, 43 insertions, 12 deletions
diff --git a/snort-model.lua b/snort-model.lua
index 06809b7..8a4450a 100644
--- a/snort-model.lua
+++ b/snort-model.lua
@@ -72,36 +72,67 @@ function getstatus ()
return status
end
-function get_filedetails()
- local path = configfile
- local filedetails = fs.stat(path)
+function get_filedetails(self,num)
+ local path
+ if (num == "2") then
+ path = configfile2
+ else
+ path = configfile
+ end
local file = {}
+ local filedetails = {}
+ local config = {}
+ local filenameerrtxt
+ if (path) and (fs.is_file(path)) then
+ filedetails = fs.stat(path)
+ config = getconfig(path)
+ else
+ config = {}
+ config.filename = {}
+ config["filename"]["errtxt"]="Config file '".. path .. "' is missing!"
+ end
- file["filename"] = cfe({
- name="filename",
+ file["filename" .. (num or "")] = cfe({
+ name="filename" .. (num or ""),
label="File name",
value=path,
+ errtxt=filenameerrtxt
})
- file["filesize"] = cfe({
- name="filesize",
+ file["filesize" .. (num or "")] = cfe({
+ name="filesize" .. (num or ""),
label="File size",
value=filedetails.size or 0,
})
- file["mtime"] = cfe({
- name="mtime",
+ file["mtime" .. (num or "")] = cfe({
+ name="mtime" .. (num or ""),
label="File date",
value=filedetails.mtime or "---",
})
- file["filecontent"] = cfe({
+ file["filecontent" .. (num or "")] = cfe({
type="longtext",
- name="filecontent",
+ name="filecontent" .. (num or ""),
label="File content",
value=fs.read_file(path),
})
+
+ -- Sum all errors into one cfe
+ local sumerrors = ""
+ for k,v in pairs(config) do
+ if (config[k]) and (config[k]["errtxt"]) and (config[k]["errtxt"] ~= "") then
+ sumerrors = sumerrors .. config[k]["errtxt"] .. "\n"
+ end
+ end
+ if (sumerrors ~= "") then
+ file["sumerrors" .. (num or "")] = cfe ({
+ name="sumerrors" .. (num or ""),
+ label = "Configuration errors",
+ errtxt = string.match(sumerrors, "(.-)\n$"),
+ })
+ end
+
return file
end
-
-- action should be a CFE
function startstop_service ( self, action )
local cmd = action.value