From 2764edeac9b4b54096f7a3c5eaa5b202e0c32f01 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 11 Sep 2008 14:31:28 +0000 Subject: Modified dansguardian. Changed advanced to listfiles and expert to listconfigfiles. Made general and edit be normal forms. Removed categories, which didn't work. git-svn-id: svn://svn.alpinelinux.org/acf/dansguardian/trunk@1465 ab2d0c66-481e-0410-8bed-d214d4d58bed --- dansguardian-advanced-html.lsp | 46 ----- dansguardian-category-html.lsp | 56 ------ dansguardian-controller.lua | 118 +----------- dansguardian-edit-html.lsp | 19 +- dansguardian-editcategories-html.lsp | 98 ---------- dansguardian-expert-html.lsp | 1 - dansguardian-general-html.lsp | 40 ++-- dansguardian-html.lsp | 34 ++++ dansguardian-model.lua | 353 +++++++++++------------------------ dansguardian.menu | 5 +- dansguardian.roles | 2 +- 11 files changed, 169 insertions(+), 603 deletions(-) delete mode 100644 dansguardian-advanced-html.lsp delete mode 100644 dansguardian-category-html.lsp mode change 100644 => 120000 dansguardian-edit-html.lsp delete mode 100644 dansguardian-editcategories-html.lsp delete mode 120000 dansguardian-expert-html.lsp create mode 100644 dansguardian-html.lsp diff --git a/dansguardian-advanced-html.lsp b/dansguardian-advanced-html.lsp deleted file mode 100644 index 24dd8fb..0000000 --- a/dansguardian-advanced-html.lsp +++ /dev/null @@ -1,46 +0,0 @@ -<% -require("viewfunctions") - local form, viewlibrary = ... - local data = form.option - local service = form.service - local config = form.service.config - -%> - -<% ---[[ DEBUG INFORMATION -io.write("

DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -%> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("status") -end %> - -

Configuration

-<% if (#service.cfgerr > 0) then %> -

Errors

-
Config errors
-
<% io.write( service.cfgerr ) %>
-
-<% end %> - - - - - - - - -<% - for k,v in ipairs( config.files ) do - io.write( "\n" ) - end -%> -
FileSizeLast Modified
" .. v.path .. "" .. (v.size or "--") .."" .. (v.mtime or "--") .."
- -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("startstop") -end %> diff --git a/dansguardian-category-html.lsp b/dansguardian-category-html.lsp deleted file mode 100644 index 2f94048..0000000 --- a/dansguardian-category-html.lsp +++ /dev/null @@ -1,56 +0,0 @@ -<% -require("viewfunctions") - local form, viewlibrary = ... -%> - -<% ---[[ DEBUG INFORMATION -io.write("

DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -%> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("status") -end %> - -

Modify Categories

- -

Category list

-
-
-<% -local myform = form["service"]["config"]["categories"] -for k,v in ipairs( myform ) do - io.write("
"..v.name.."
\n") - io.write("
") - if (v.option) then - for k1,v1 in pairs(v.option) do - io.write("" ) --- for k2,v2 in pairs(v1) do - --io.write(html.form(v1.type(v1))) --- io.write("") --- end - io.write("\n") - end - io.write("\n" ) - end - io.write("
".. v1.name .. "[ Edit ]") --- io.write("[ " ..html.link(v2) .. " ] ") --- io.write(tostring(v2)) --- io.write("
") ---io.write( "
" .. v .. "\n" ) -end -%> -
-
- - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("startstop") -end %> diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua index 97e2849..37470bd 100644 --- a/dansguardian-controller.lua +++ b/dansguardian-controller.lua @@ -15,123 +15,17 @@ startstop = function( self ) end general = function( self ) - - local service = {} - - -- Add a cmd button to the view - service.cmdsave = cfe({ name="cmdsave", - label="Save/Apply above settings", - value="Save", - type="submit", - }) - - if self.clientdata.cmdsave then - local conf = self.clientdata - local config = { filterip = conf.filterip, filterport = conf.filterport, - proxyip = conf.proxyip, proxyport = conf.proxyport, - accessdeniedaddress = conf.accessdeniedaddress, - naughtynesslimit = conf.naughtynesslimit - } - self.model.update_general_config( config ) - service.cmdsave.descr="* Changes has been saved!" - end - - service.config, service.cfgerr = self.model.get_general_config() - - return ( cfe ({ service = service }) ) + return controllerfunctions.handle_form(self, self.model.read_general_config, self.model.update_general_config, self.clientdata, "Save", "Edit General Configuration", "General Configuration Set") end -advanced = function( self ) - - local service = {} - - local option = { script = self.conf.script, - prefix = self.conf.prefix, - controller = self.conf.controller, - action = self.conf.action, - extra = "" - } - - service.config, service.cfgerr = self.model.get_advanced_config() - - return ( cfe ({ option = option, service = service }) ) +listfiles = function( self ) + return self.model.list_files() end -expert = function( self ) - return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.updateconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Set") +listconfigfiles = function( self ) + return self.model.list_config_files() end edit = function( self ) - - if not self.clientdata.name then - redirect( self ) - end - - local service = { message="", status="", config="" } - - if self.clientdata.cmd then - if self.clientdata.cmd == "save" then - self.model.update_edit_config( self.clientdata.name, self.clientdata.config ) - redirect( self, "advanced" ) - end - end - - service.config, service.cfgerr = self.model.get_edit_config( self.clientdata.name ) - service.name = self.clientdata.name - - if service.cfgerr == "Hacker" then - redirect( self ) - end - - return ( cfe ({ service = service }) ) -end - -category = function( self ) - - local service = { message="", status="", config="", cfgerr="" } - - service.config = {} - service.config.categories = cfe({ - name="categories", - label="Categories available", - value={}, - }) - - service.config.categories = self.model.get_categories() - return ( cfe ({ service = service }) ) -end - -editcategories = function( self ) - - local info = self.model.get_category(self.clientdata.category, self.clientdata.object) - if not (info) then - redirect(self, "category") - end - - -- Add a cmd button to the view - info.cmdsave = cfe({ name="cmdsave", - label="Save/Apply above settings", - value="Save", - type="submit", - disabled="yes", - errtxt="This button is not configured to work", - }) - - info.cmddelete = cfe({ name="cmddelete", - label="Permanently remove object", - value="Delete", - type="submit", - disabled="yes", - errtxt="This button is not configured to work", - }) - - local option = { script = self.conf.script, - prefix = self.conf.prefix, - controller = self.conf.controller, - action = self.conf.action, - extra = "" - } - - return ( cfe ({ option = option, info = info, mhdebug=self.clientdata }) ) + return controllerfunctions.handle_form(self, function() return self.model.get_file(self.clientdata.filename) end, self.model.update_file, self.clientdata, "Save", "Edit File", "File Saved") end - diff --git a/dansguardian-edit-html.lsp b/dansguardian-edit-html.lsp deleted file mode 100644 index 99cf55a..0000000 --- a/dansguardian-edit-html.lsp +++ /dev/null @@ -1,18 +0,0 @@ -<% - local form = ... - local service = form.service - -%> -

Content Filter (<% io.write( service.name ) %>)

- -
-

<% io.write( service.cfgerr ) %>

-

These parameters define the interface and port that Dansguardian uses to accept connections.

- - - - -

Save Changes

-
Save the content of the above box
-
- diff --git a/dansguardian-edit-html.lsp b/dansguardian-edit-html.lsp new file mode 120000 index 0000000..15b1930 --- /dev/null +++ b/dansguardian-edit-html.lsp @@ -0,0 +1 @@ +../filedetails-html.lsp \ No newline at end of file diff --git a/dansguardian-editcategories-html.lsp b/dansguardian-editcategories-html.lsp deleted file mode 100644 index 63087bf..0000000 --- a/dansguardian-editcategories-html.lsp +++ /dev/null @@ -1,98 +0,0 @@ -<% local form = ... -require("viewfunctions") -%> -<% ---[[ DEBUG INFORMATION -io.write("

DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(form)) -io.write("
") ---]] -%> - -

INFO

-
-<% -local myform = form.info -local tags = { "configfile","mtime","category", "name", "activestatus", } -displayinfo(myform,tags,"viewonly") -%> -
- -

CONFIGURE

-

General

-
-<% -local myform = form.info -local tags = { "activate" } -displayinfo(myform,tags) -%> -
- -

Details

-<% -local myform = form.info -io.write('') -io.write(html.form[myform.filecontent.type](myform.filecontent)) -%> - -

Save

-
-<% -local myform = form.info -local tags = { "cmdsave" } -displayinfo(myform,tags) -%> -
- -

Delete

-

You can delete this object. This will result in erazing instead of deactivating it.

-

When deleting a object, you will not be able to get it back! If you are unsure, it's better to only deactivate this object instead of deleting it.

-
-<% -local myform = form.info -local tags = { "cmddelete" } -displayinfo(myform,tags) -%> -
- -<% --[[ %> -
-

CONFIGURATION

-

Expert config

-

File details

-
-<% -local myform = form.file -local tags = { "filename", "filesize", "mtime", "sumerrors", } -displayinfo(myform,tags,"viewonly") -%> -
- -

FILE CONTENT

-<% -local myform = form.file -io.write('') -io.write(html.form[myform.filecontent.type](myform.filecontent)) -%> - -

SAVE AND APPLY ABOVE SETTINGS

-
-<% -local tags = { "cmddelete", "cmdsave", } -displayinfo(myform,tags) -%> -
- -<% --- Management buttons -local myform = form.management -local tags = { "start", "stop", "restart" } -if (myform) then - io.write("

MANAGEMENT

\n
") - displaymanagement(myform,tags) - io.write("
") -end -%> -
-<% --]] %> - diff --git a/dansguardian-expert-html.lsp b/dansguardian-expert-html.lsp deleted file mode 120000 index 207f324..0000000 --- a/dansguardian-expert-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../expert-html.lsp \ No newline at end of file diff --git a/dansguardian-general-html.lsp b/dansguardian-general-html.lsp index 6c0ca60..e7bd1af 100644 --- a/dansguardian-general-html.lsp +++ b/dansguardian-general-html.lsp @@ -1,9 +1,6 @@ <% require("viewfunctions") local form, viewlibrary = ... - local service = form.service - local config = form.service.config - %> <% @@ -20,14 +17,23 @@ end %>

Configuration

+<% + if form.descr then io.write('

' .. string.gsub(form.descr, "\n", "
") .. "

\n") end + if form.errtxt then io.write('

' .. string.gsub(form.errtxt, "\n", "
") .. "

\n") end + for field,val in pairs(form.value) do + val.name = field + end +%>

General

These parameters define the interface and port that Dansguardian uses to accept connections.

-
filterip
-
filterport
+<% + displayformitem(form.value.filterip) + displayformitem(form.value.filterport) +%>

Proxy service

@@ -36,8 +42,10 @@ These parameters define the ip address and port that Dansguardian should forward

-
proxyip
-
proxyport
+<% + displayformitem(form.value.proxyip) + displayformitem(form.value.proxyport) +%>

Filter Actions

@@ -48,23 +56,15 @@ The author recommends 50 for "young children", 100 for "older children" and 160

-
accessdeniedaddress
-
naughtynesslimit
+<% + displayformitem(form.value.accessdeniedaddress) + displayformitem(form.value.naughtynesslimit) +%>

Save Changes

-<% -local myform = form.service -local tags = { "cmdsave", } -displayinfo(myform,tags) -%> -<% if (service) and (service.cfgerr) and (#service.cfgerr > 0) then %> -
Config status
<% io.write(service.cfgerr ) %>
-<% end %> -
Process information
This process runs as a service. When you make and save changes, the configuration -files for the service are changed. However, the changes will not be applied -until you restart the service.
+
diff --git a/dansguardian-html.lsp b/dansguardian-html.lsp new file mode 100644 index 0000000..83b17eb --- /dev/null +++ b/dansguardian-html.lsp @@ -0,0 +1,34 @@ +<% local view, viewlibrary, page_info = ... +require("viewfunctions") +%> + +<% +--[[ DEBUG INFORMATION +io.write("

DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +%> + +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("status") +end %> + +

Configuration

+ + + + + + + +<% + for k,v in ipairs( view.value ) do + io.write( "\n" ) + end +%> +
FileSizeLast Modified
" .. v.filename .. "" .. v.size .."" .. v.mtime .."
+ +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("startstop") +end %> diff --git a/dansguardian-model.lua b/dansguardian-model.lua index 7fb76a1..f24748e 100644 --- a/dansguardian-model.lua +++ b/dansguardian-model.lua @@ -3,12 +3,9 @@ module (..., package.seeall) -- Load libraries require("modelfunctions") -require "posix" -require "format" -require("processinfo") -require("procps") +require("getopts") +--require "posix" require("fs") -require("daemoncontrol") require("validator") -- Set variables @@ -16,7 +13,9 @@ dansguardiancfg = "/etc/dansguardian/dansguardian.conf" dansguardiancfg2 = "/etc/dansguardian/dansguardianf1.conf" local processname = "dansguardian" local packagename = "dansguardian" -local baseurl = "/etc/dansguardian" -- Without trailing / +local baseurl = "/etc/dansguardian" + +--[[ local categoryfiles = { ['weighted'] = tostring(baseurl .. "/weightedphraselist"), ['banned'] = tostring(baseurl .. "/bannedphraselist"), @@ -42,7 +41,39 @@ local categoryfilecontent = { ['banned'] = get_includes_from_file(categoryfiles['banned']), ['exception'] = get_includes_from_file(categoryfiles['exception']), } +--]] + +local validate_general_config = function( config ) + local success = true + if config.value.filterip.value ~= "" and not validator.is_ipv4(config.value.filterip.value) then + config.value.filterip.errtxt = "Invalid IP address" + success = false + end + if not validator.is_port(config.value.filterport.value) then + config.value.filterport.errtxt = "Invalid port" + success = false + end + if not validator.is_ipv4(config.value.proxyip.value) then + config.value.proxyip.errtxt = "Invalid IP address" + success = false + end + if not validator.is_port(config.value.proxyport.value) then + config.value.proxyport.errtxt = "Invalid port" + success = false + end + -- FIXME don't know how to validate accessdeniedaddress + if not validator.is_integer(config.value.naughtynesslimit.value) then + config.value.naughtynesslimit.errtxt = "Invalid number" + success = false + end + + return success, config +end +local is_valid_filename = function(filename) + local dirname = dirname(filename) + return validator.is_valid_filename(filename) and string.match(dirname, baseurl) and not string.match(dirname, "%.%.") +end -- ################################################################################ -- PUBLIC FUNCTIONS @@ -55,274 +86,100 @@ startstop_service = function( action ) return modelfunctions.startstop_service(processname, action) end -get_general_config = function() +read_general_config = function() + local retval = { filterip = cfe({ label="Filter IP", descr="Leave blank to listen on all IPs" }), + filterport = cfe({ label="Filter Port" }), + proxyip = cfe({ label="Proxy IP" }), + proxyport = cfe({ label="Proxy Port" }), + accessdeniedaddress = cfe({ label="AccessDeniedAddress" }), + naughtynesslimit = cfe({ label="NaughtynessLimit" }) + } - local retval = {} - local error = "" - - retval = { filterip = { label="Filter IP", type="text", value="" }, - filterport = { label="Filter Port", type="text", value="" }, - proxyip = { label="Proxy IP", type="text", value="" }, - proxyport = { label="Proxy Port", type="text", value="" }, - accessdeniedaddress = { label="AccessDeniedAddress", type="text", value="" }, - naughtynesslimit = { label="NaughtynessLimit", type="text", value="" } - } - - local fptr = io.open( dansguardiancfg, "r" ) - if fptr ~= nil then - local line = fptr:read( "*l" ) - while line ~= nil do - if string.sub( line, 1, 1 ) ~= "#" then - if string.sub( line, 1, 8 ) == "filterip" then - retval.filterip.value = get_cfg_value( line ) - elseif string.sub( line, 1, 10 ) == "filterport" then - retval.filterport.value = get_cfg_value( line ) - elseif string.sub( line, 1, 7 ) == "proxyip" then - retval.proxyip.value = get_cfg_value( line ) - elseif string.sub( line, 1, 9 ) == "proxyport" then - retval.proxyport.value = get_cfg_value( line ) - elseif string.sub( line, 1, 19 ) == "accessdeniedaddress" then - retval.accessdeniedaddress.value = get_cfg_value( line ) - end - end - line = fptr:read( "*l" ) -- read one config file - end - fptr:close() - else - error = "Failed to open " .. dansguardiancfg .. " file!" + local config = getopts.getoptsfromfile(dansguardiancfg, "") + if config then + if config.filterip then retval.filterip.value = config.filterip end + if config.filterport then retval.filterport.value = config.filterport end + if config.proxyip then retval.proxyip.value = config.proxyip end + if config.proxyport then retval.proxyport.value = config.proxyport end + if config.accessdeniedaddress then retval.accessdeniedaddress.value = string.sub(config.accessdeniedaddress, 2, -2) end end - local fptr2 = io.open( dansguardiancfg2, "r" ) - if fptr2 ~= nil then - local line = fptr2:read( "*l" ) - while line ~= nil do - if string.sub( line, 1, 1 ) ~= "#" then - if string.sub( line, 1, 16 ) == "naughtynesslimit" then - retval.naughtynesslimit.value = get_cfg_value( line ) - end - end - line = fptr2:read( "*l" ) -- read one config file line - end - fptr2:close() - else - error = "Failed to open " .. dansguardiancfg2 .. " file!" + config = getopts.getoptsfromfile(dansguardiancfg2, "") + if config then + if config.naughtynesslimit then retval.naughtynesslimit.value = config.naughtynesslimit end end - return retval, error -end - -getconfigfile = function() - return modelfunctions.getfiledetails(dansguardiancfg) + return cfe({ type="group", value=retval, label="Dansguardian General Config" }) end -get_edit_config = function( name ) - - local retval = "" - local error = "" - - if not is_valid_configfile( name ) then - return "", "Hacker" - end - - local fptr = io.open( "/etc/dansguardian/" .. name ) - if fptr ~= nil then - retval = fptr:read( "*a" ) - fptr:close() - if retval == nil then - retval = "" - error = "Failed to read /etc/dansguardian/" .. name .. " file!" - end - else - error = "Failed to open /etc/dansguardian/" .. name .. " file!" +update_general_config = function( config ) + local success, config = validate_general_config(config) + + if success then + local a,b,c + local text = fs.read_file(dansguardiancfg) + a,b,c,text = getopts.setoptsinfile(text, "", "filterip", config.value.filterip.value) + a,b,c,text = getopts.setoptsinfile(text, "", "filterport", config.value.filterport.value) + a,b,c,text = getopts.setoptsinfile(text, "", "proxyip", config.value.proxyip.value) + a,b,c,text = getopts.setoptsinfile(text, "", "proxyport", config.value.proxyport.value) + a,b,c,text = getopts.setoptsinfile(text, "", "accessdeniedaddress", "'"..config.value.accessdeniedaddress.value.."'") + fs.write_file(dansguardiancfg, string.gsub(text, "\n+$", "")) + getopts.setoptsinfile(dansguardiancfg2, "", "naughtynesslimit", config.value.naughtynesslimit.value) + else + config.errtxt = "Failed to set config" end - return retval, error + return config end -update_edit_config = function( name, config ) - - local retval = "" - - if not is_valid_configfile( name ) then - return "", "Hacker" - end - - local fptr = io.open( "/etc/dansguardian/" .. name, "wb+" ) - if fptr ~= nil then - fptr:write( format.dostounix( config ) ) - fptr:close() - retval = "" +get_file = function(filename) + local retval + if is_valid_filename(filename) then + retval = modelfunctions.getfiledetails(filename) else - error = "Failed to open /etc/dansguardian/" .. name .. " file!" + retval = modelfunctions.getfiledetails("") + retval.value.filename.value = filename end - - return retval -end - -update_general_config = function( config ) - - local retval = "" - local tmpfilename = os.tmpname() - local tmpfile = -1 - local cfgptr = -1 - local line = "" - tmpfile = io.open( tmpfilename, "wb+" ) - if tmpfile == nil then - return "Failed to create temporary config file!" - end - - cfgptr = io.open( dansguardiancfg, "r" ) - if cfgptr == nil then - tmpfile:close() - os.remove( tmpfilename ) - return "Failed to open " .. dansguardiancfg .. "!" - end - - line = cfgptr:read( "*l" ) - while line ~= nil do - if string.sub( line, 1, 8 ) == "filterip" then - tmpfile:write( "filterip = " .. config.filterip .. "\n" ) - elseif string.sub( line, 1, 10 ) == "filterport" then - tmpfile:write( "filterport = " .. config.filterport .. "\n" ) - elseif string.sub( line, 1, 7 ) == "proxyip" then - tmpfile:write( "proxyip = " .. config.proxyip .. "\n" ) - elseif string.sub( line, 1, 9 ) == "proxyport" then - tmpfile:write( "proxyport = " .. config.proxyport .. "\n" ) - elseif string.sub( line, 1, 19 ) == "accessdeniedaddress" then - tmpfile:write( "accessdeniedaddress = " .. config.accessdeniedaddress .. "\n" ) - else - tmpfile:write( line .. "\n" ) - end - line = cfgptr:read( "*l" ) - end - - tmpfile:close() - cfgptr:close() - os.rename( tmpfilename, dansguardiancfg ) - - --- step 2 - dansguardiancfg2 - - tmpfile = io.open( tmpfilename, "wb+" ) - if tmpfile == nil then - return "Failed to create temporary config file!" - end - - cfgptr = io.open( dansguardiancfg2, "r" ) - if cfgptr == nil then - tmpfile:close() - os.remove( tmpfilename ) - return "Failed to open " .. dansguardiancfg2 .. "!" - end - - line = cfgptr:read( "*l" ) - while line ~= nil do - if string.sub( line, 1, 16 ) == "naughtynesslimit" then - tmpfile:write( "naughtynesslimit = " .. config.naughtynesslimit .. "\n" ) - else - tmpfile:write( line .. "\n" ) - end - line = cfgptr:read( "*l" ) - end - - tmpfile:close() - cfgptr:close() - os.rename( tmpfilename, dansguardiancfg2 ) - return retval end -updateconfigfile = function( filedetails ) - filedetails.value.filename.value = dansguardiancfg - return modelfunctions.setfiledetails(dansguardiancfg) -end - -get_cfg_value = function( str ) - - local retval = "" - local pos = 1 - local found = false - local found2 = false - - while not found and pos < #str -1 do - if string.sub( str, pos, pos ) == "=" then - found = true - end - pos = pos + 1 - end - - if found then - pos = pos - 1 - while not found2 and pos < #str -1 do - if string.sub( str, pos+1, pos+1 ) ~= " " then - found2 = true - end - pos = pos + 1 - end - end - - if found2 then - retval = string.sub( str, pos ) +update_file = function(filedetails) + local retval + if is_valid_filename(filedetails.value.filename.value) then + retval = modelfunctions.setfiledetails(filedetails) + else + retval.value.filename.errtxt = "Invalid filename" + retval.errtxt = "Failed to save file" end - - return retval -end - -get_advanced_config = function() - local retval = { files = {} } - local errmsg = "" - - get_file_tree( retval.files, "/etc/dansguardian", "" ) - - return retval, errmsg + return retval end -get_file_tree = function( treetable, dir, prefix ) - - local entries = posix.dir( dir ) - local k = "" - local v = "" - for k,v in ipairs( entries ) do - local attrs = posix.stat( dir .. "/" .. v ) - if attrs.type == "regular" and string.sub( v, -4) ~= ".gif" then - local path = dir .. "/" .. v - local filedetails = fs.stat(path) - filedetails.path = prefix .. v - table.insert( treetable, filedetails ) - end - end - - entries = posix.dir( dir ) - for k,v in ipairs( entries ) do - local attrs = posix.stat( dir .. "/" .. v ) - if attrs.type == "directory" and v~= "." and v~= ".." then - get_file_tree( treetable, dir .. "/" .. v, prefix .. v .. "/" ) +list_files = function() + local retval = {} + for file in fs.find(null, baseurl) do + local details = fs.stat(file) + if details.type == "regular" and not string.match(file, "logrotation$") and not string.match(file, "%.conf$") and not string.match(file, "%.gif$") then + details.filename = file + table.insert(retval, details) end end - - return + return cfe({ type="structure", value=retval, label="List of Dansguardian files" }) end -is_valid_configfile = function( name ) - - local retval = false - local ftable = {} - local k - local v - - - get_file_tree( ftable, "/etc/dansguardian", "" ) - - for k,v in ipairs( ftable ) do - if v.path == name then - retval = true - end - end - - return retval +list_config_files = function() + local list = {} + local details = fs.stat(dansguardiancfg) + details.filename = dansguardiancfg + list[1] = details + details = fs.stat(dansguardiancfg2) + details.filename = dansguardiancfg2 + list[2] = details + return cfe({ type="list", value=list, label="List of Dansguardian config files" }) end +--[[ get_categories = function() local retval = {} @@ -412,4 +269,4 @@ get_category = function(category, object) return retval end - +--]] diff --git a/dansguardian.menu b/dansguardian.menu index a679ad7..61381b9 100644 --- a/dansguardian.menu +++ b/dansguardian.menu @@ -2,6 +2,5 @@ # Cat Group Tab Action Applications 20Content_Filter Status status Applications 20Content_Filter Basic general -Applications 20Content_Filter Advanced advanced -Applications 20Content_Filter Category category -Applications 20Content_Filter Expert expert +Applications 20Content_Filter Advanced listfiles +Applications 20Content_Filter Expert listconfigfiles diff --git a/dansguardian.roles b/dansguardian.roles index e19712f..adcbb49 100644 --- a/dansguardian.roles +++ b/dansguardian.roles @@ -1,2 +1,2 @@ READ=dansguardian:status -UPDATE=dansguardian:general,dansguardian:advanced,dansguardian:expert,dansguardian:edit,dansguardian:category,dansguardian:editcategories,dansguardian:startstop +UPDATE=dansguardian:general,dansguardian:listfiles,dansguardian:listconfigfiles,dansguardian:edit,dansguardian:startstop -- cgit v1.2.3