summaryrefslogtreecommitdiffstats
path: root/snort-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-03-03 14:55:02 +0000
committerMika Havela <mika.havela@gmail.com>2008-03-03 14:55:02 +0000
commitf14ce45bcdcbbe99cb5693966019d0deb39371e5 (patch)
tree72d6db9d18f64c9f938c43000481595316e79389 /snort-model.lua
parent1c331f9c3a09d3f50c98a129db3a5dd77abc348e (diff)
downloadacf-snort-f14ce45bcdcbbe99cb5693966019d0deb39371e5.tar.bz2
acf-snort-f14ce45bcdcbbe99cb5693966019d0deb39371e5.tar.xz
Some changes to get 'save' button to work in expert-tab
git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@785 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'snort-model.lua')
-rw-r--r--snort-model.lua59
1 files changed, 48 insertions, 11 deletions
diff --git a/snort-model.lua b/snort-model.lua
index 02c5a1e..3666e6e 100644
--- a/snort-model.lua
+++ b/snort-model.lua
@@ -10,14 +10,13 @@ require("daemoncontrol")
require("format")
local processname = "snort"
-
local configfile = "/etc/snort/snort.conf"
-- ################################################################################
-- LOCAL FUNCTIONS
local function get_version()
- local cmd = "snort -V 2>&1 | grep Version | sed 's/.*ersion\ /snort-/'"
+ local cmd = "/sbin/apk_version -v -s " .. processname .. " | cut -d ' ' -f 1"
local cmd_output = io.popen( cmd )
local cmd_output_result = cmd_output:read("*a") or ""
cmd_output:close()
@@ -29,22 +28,60 @@ end
function getstatus ()
local status = {}
- status["version"] = string.match(get_version(), "^(%S*)" )
- status["enabled"] = procps.pidof("snort")
+
+ status.version = cfe({
+ name = "version",
+ label="Program version",
+ value=get_version(),
+ })
+
+ status.status = cfe({
+ name="status",
+ label="Program status",
+ value=procps.pidof(processname) or "",
+ })
+
return status
end
function get_filedetails()
- local filedetails = {}
local path = configfile
- filedetails.details = fs.stat(path)
- filedetails.content = fs.read_file(path)
- return filedetails
+ local filedetails = fs.stat(path)
+ local file = {}
+
+ file["filename"] = cfe({
+ name="filename",
+ label="File name",
+ value=path,
+ })
+ file["filesize"] = cfe({
+ name="filesize",
+ label="File size",
+ value=filedetails.size or 0,
+ })
+ file["mtime"] = cfe({
+ name="mtime",
+ label="File date",
+ value=filedetails.mtime or "---",
+ })
+ file["filecontent"] = cfe({
+ type="longtext",
+ name="filecontent",
+ label="File content",
+ value=fs.read_file(path),
+ })
+ return file
end
-function startstop_service ( self, state )
- local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, state)
- return cmdmessage
+
+-- action should be a CFE
+function startstop_service ( self, action )
+ local cmd = action.value
+ local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol("snort", cmd)
+ action.descr=cmdmessage
+ action.errtxt=cmderror
+ -- Reporting back (true|false, the original acition)
+ return cmdresult,action
end
function read_alert()