summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-05-15 20:15:32 +0000
committerTed Trask <ttrask01@yahoo.com>2008-05-15 20:15:32 +0000
commitd8afa977ce3587ee2819c44d545753aa0cc38760 (patch)
tree82ea6d0e957959ba1a2777f090cffac9f941734c /syslog-model.lua
parent7d9b0d93dd7c3dee3acd4da629b4f519eafe0f7b (diff)
downloadacf-alpine-baselayout-d8afa977ce3587ee2819c44d545753aa0cc38760.tar.bz2
acf-alpine-baselayout-d8afa977ce3587ee2819c44d545753aa0cc38760.tar.xz
For cfe.type='form', use cfe.option as the command to save the form data i.e. can be used as button name. Modified pages that use 'form' to also use 'option'.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1122 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua64
1 files changed, 36 insertions, 28 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index a77986b..c105dd4 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -55,6 +55,38 @@ local writeconfig = function (config)
return cmdmessage, cmderror
end
+local validateconfig = function(config)
+ local success = true
+ -- Validate entries and create error strings
+ if not validator.is_valid_filename(config.value.logfile.value, "/var/log") then
+ config.value.logfile.errtxt = "Not a valid file name in /var/log"
+ success = false
+ end
+ if not validator.is_integer_in_range(config.value.loglevel.value, 1, 8) then
+ config.value.loglevel.errtxt = "Out of range!"
+ success = false
+ end
+ if config.value.maxsize.value ~= "" and not validator.is_integer(config.value.maxsize.value) then
+ config.value.maxsize.errtxt = "Must be an integer"
+ success = false
+ end
+ if config.value.numrotate.value ~= "" and not validator.is_integer_in_range(config.value.numrotate.value, 0, 99) then
+ config.value.numrotate.errtxt = "Out of range!"
+ success = false
+ end
+ if config.value.localandnetworklog.value == true and config.value.remotelogging.value == "" then
+ config.value.localandnetworklog.errtxt = "Logging to local and network is not possible unless you define a host for remote logging"
+ success = false
+ end
+ local hostport = format.string_to_table(config.value.remotelogging.value, ":")
+ if hostport[2] and not (validator.is_port(hostport[2])) then
+ config.value.remotelogging.errtxt = "Not a valid port"
+ success = false
+ end
+
+ return success, config
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -189,32 +221,7 @@ function updateconfig (clientdata)
end
end
- -- Validate entries and create error strings
- if not validator.is_valid_filename(config.value.logfile.value, "/var/log") then
- config.value.logfile.errtxt = "Not a valid file name in /var/log"
- success = false
- end
- if not validator.is_integer_in_range(config.value.loglevel.value, 1, 8) then
- config.value.loglevel.errtxt = "Out of range!"
- success = false
- end
- if config.value.maxsize.value ~= "" and not validator.is_integer(config.value.maxsize.value) then
- config.value.maxsize.errtxt = "Must be an integer"
- success = false
- end
- if config.value.numrotate.value ~= "" and not validator.is_integer_in_range(config.value.numrotate.value, 0, 99) then
- config.value.numrotate.errtxt = "Out of range!"
- success = false
- end
- if config.value.localandnetworklog.value == true and config.value.remotelogging.value == "" then
- config.value.localandnetworklog.errtxt = "Logging to local and network is not possible unless you define a host for remote logging"
- success = false
- end
- local hostport = format.string_to_table(config.value.remotelogging.value, ":")
- if hostport[2] and not (validator.is_port(hostport[2])) then
- config.value.remotelogging.errtxt = "Not a valid port"
- success = false
- end
+ success, config = validateconfig(config)
if success == true then
config.descr, config.errtxt = writeconfig(config)
@@ -226,7 +233,8 @@ function updateconfig (clientdata)
end
function update_filecontent (self, modifications)
- local path = configfile
- fs.write_file(path, format.dostounix(modifications))
+ -- FIXME add validation before writing
+ fs.write_file(configfile, format.dostounix(modifications))
+ return get_filedetails()
end