From 9c7c3db17d1f67f0ffcacc58e4e4dd57a61594cf Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 21 Oct 2013 00:34:22 +0000 Subject: Remove all calls to 'module' in preparation for move to Lua 5.2 Use mymodule parameter for module definition. This was also helpful in revealing places where the code relied on the global environment. --- snort-controller.lua | 13 +++++++------ snort-model.lua | 16 +++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/snort-controller.lua b/snort-controller.lua index 1ee4a63..8a25321 100644 --- a/snort-controller.lua +++ b/snort-controller.lua @@ -1,20 +1,21 @@ -module (..., package.seeall) +local mymodule = {} -default_action = "status" +mymodule.default_action = "status" -function status(self) +function mymodule.status(self) return self.model.getstatus() end -function details(self) +function mymodule.details(self) return self.model.read_alert() end -function startstop(self) +function mymodule.startstop(self) return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end -function expert(self) +function mymodule.expert(self) return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Configuration", "Configuration Set") end +return mymodule diff --git a/snort-model.lua b/snort-model.lua index c8c7d83..6c633a3 100644 --- a/snort-model.lua +++ b/snort-model.lua @@ -1,5 +1,5 @@ -- acf model for displaying logfiles recusivly -module (..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -17,19 +17,19 @@ local alertfile = "/var/log/snort/alert" -- ################################################################################ -- PUBLIC FUNCTIONS -function getstatus() +function mymodule.getstatus() return modelfunctions.getstatus(processname, packagename, "Snort Status") end -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) return modelfunctions.get_startstop(processname) end -function startstop_service(self, startstop, action) +function mymodule.startstop_service(self, startstop, action) return modelfunctions.startstop_service(startstop, action) end -function read_alert() +function mymodule.read_alert() local alertpriority = {} local liboutput = fs.read_file_as_array(alertfile) if (liboutput) then @@ -77,10 +77,12 @@ function read_alert() return cfe({ type="structure", value=sorted_table, label="Snort Alerts" }) end -function get_filedetails() +function mymodule.get_filedetails() return modelfunctions.getfiledetails(configfile) end -function update_filedetails(self, filedetails) +function mymodule.update_filedetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, {configfile}) end + +return mymodule -- cgit v1.2.3