From 82faa5dc652a3890113797e11ec7e57d1bfdcf56 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 16 Jan 2009 15:28:51 +0000 Subject: Fixed tinydns bug caused by 1596 with write_file_with_audit, fixed bug in creating file when directory missing. git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1680 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-controller.lua | 2 +- tinydns-model.lua | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tinydns-controller.lua b/tinydns-controller.lua index 7155612..ef409a2 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -17,7 +17,7 @@ function startstop(self) end function config(self) - return controllerfunctions.handle_form(self, self.model.getconfig, self.model.setconfig, self.clientdata, "Save", "Edit Configuration", "Configuration Saved") + return controllerfunctions.handle_form(self, self.model.getconfig, function(value) return self.model.setconfig(self, value) end, self.clientdata, "Save", "Edit Configuration", "Configuration Saved") end function newfile(self) diff --git a/tinydns-model.lua b/tinydns-model.lua index 0fa92f1..6b77acc 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -181,13 +181,13 @@ function getconfig() return cfe({ type="group", value=config, label="TinyDNS Configuration" }) end -function setconfig(conf) +function setconfig(self, conf) local test, errtxt = validator.is_ipv4(conf.value.listen.value) if not test then conf.value.listen.errtxt = errtxt conf.errtxt = "Failed to set configuration" else - write_file_with_audit(configfile, format.update_ini_file(fs.read_file(configfile) or "","","IP",conf.value.listen.value)) + modelfunctions.write_file_with_audit(self, configfile, format.update_ini_file(fs.read_file(configfile) or "","","IP",conf.value.listen.value)) end return conf @@ -284,8 +284,7 @@ function createconfigfile(self, configfile, userid) if (posix.stat(path)) then configfile.value.filename.errtxt = "File already exists" else - local file = io.open(path, "w") - file:close() + fs.create_file(path) configfile.errtxt = nil -- We have to add this file to the allowed list, if there is one -- cgit v1.2.3