From dbf1f135f134ed6e51cf8b7be12b36a461ec4ab8 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 17 Jan 2008 16:17:52 +0000 Subject: Added functionallity to remove items from include/exclude list git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@609 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lbu-config-html.lsp | 8 +++++--- lbu-controller.lua | 12 +++++++++++- lbu-model.lua | 25 +++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lbu-config-html.lsp b/lbu-config-html.lsp index 2dba128..6cd1bb6 100644 --- a/lbu-config-html.lsp +++ b/lbu-config-html.lsp @@ -13,6 +13,7 @@

CONFIG

+

Advanced config

Storage media

@@ -38,7 +39,7 @@
Delete selected include-item
-
(see above)
+
(see above)
@@ -52,7 +53,7 @@
Delete selected exclude-item
-
(see above)
+
(see above)

Security/Encryption

@@ -79,8 +80,9 @@

Save and apply above settings

Apply settings
-
+
+

MANAGEMENT

diff --git a/lbu-controller.lua b/lbu-controller.lua index 853219b..cdb0bc6 100644 --- a/lbu-controller.lua +++ b/lbu-controller.lua @@ -25,9 +25,19 @@ status = function (self) end config = function (self) - local cmd = self.clientdata.cmd + if (self.clientdata.cmd_delete_excluded) then + cmdresult = self.model:lbuincexcl("exclude", self.clientdata.lbu_excluded, "remove") + end + if (self.clientdata.cmd_delete_included) then + cmdresult = self.model:lbuincexcl("include", self.clientdata.lbu_included, "remove") + end + if (self.clientdata.config_submit) then + cmdresult = self.model:editconfig(self.clientdata) + end local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller return ( {status = self.model:getstatus(), + cmdresult = cmdresult, + clientdata = self.clientdata, config = self.model:getconfig(), url = url, } ) end diff --git a/lbu-model.lua b/lbu-model.lua index 7757332..c3d20c4 100644 --- a/lbu-model.lua +++ b/lbu-model.lua @@ -51,8 +51,8 @@ end local function getincexl(state) local incexl = {} if (string.lower(state) == "include") or (string.lower(state) == "exclude") then - local f = io.popen("/sbin/lbu " .. state .. " -l 2>&1", "r") - if not (f) then return ciphers end + local f = io.popen("/sbin/lbu " .. string.lower(state) .. " -l 2>&1", "r") + if not (f) then return incexl end for line in f:lines() do table.insert(incexl,tostring(line)) end @@ -108,6 +108,27 @@ function getconfig () -- config["debug"] = getciphers() return config end + +function lbuincexcl(self,state,value,addremove) + local incexl = nil +-- local addremove + if (string.lower(addremove or "") == "add") then + addremove = "" + elseif (string.lower(addremove or "") == "remove") then + addremove = "-r" + else + return "Function setincexl() - Invalid option! Use add|remove when calling this function!" + end + if (string.lower(state) == "include") or (string.lower(state) == "exclude") then + local f = io.popen("/sbin/lbu " .. string.lower(state) .. " " .. addremove .. " -v " .. value .." 2>&1", "r") + if not (f) then return incexl end + incexl = f:read("*a") + f:close() + else + return "Function setincexl() - Invalid command! Use include|exclude when calling this function!" + end + return incexl +end -- ################################################################################ -- OLD FUNCTIONS -- cgit v1.2.3