summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
committerTed Trask <ttrask01@yahoo.com>2009-01-13 16:01:06 +0000
commitacca38ff8d4f52d4e28fed68f8c88618d9e036d3 (patch)
tree4595b1f4b73248eeba25abe6be217dc4f1aef339
parent7d0b9a6f0de10e47a1ec8ba9e628516b185a41b7 (diff)
downloadacf-openntpd-acca38ff8d4f52d4e28fed68f8c88618d9e036d3.tar.bz2
acf-openntpd-acca38ff8d4f52d4e28fed68f8c88618d9e036d3.tar.xz
Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value.
git-svn-id: svn://svn.alpinelinux.org/acf/openntpd/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--openntpd-model.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/openntpd-model.lua b/openntpd-model.lua
index a66160c..cbb0ab7 100644
--- a/openntpd-model.lua
+++ b/openntpd-model.lua
@@ -72,7 +72,7 @@ function read_config ()
config.listen = cfe({ type="list", value={}, label="Addresses to listen on", descr="List of IP addresses/hostnames to listen on. '*' means listen on all local addresses." })
config.setstimeonstartup = cfe({ type="boolean", value=false, label="Set time on startup" })
- local conf = format.parse_linesandwords(fs.read_file(configfile))
+ local conf = format.parse_linesandwords(fs.read_file(configfile) or "")
for i,line in ipairs(conf) do
if line[1] == "server" then
table.insert(config.server.value, line[2])
@@ -83,7 +83,7 @@ function read_config ()
end
end
- local opts = string.sub(format.parse_ini_file(fs.read_file(confdfile), "", "NTPD_OPTS"), 2, -2)
+ local opts = string.sub(format.parse_ini_file(fs.read_file(confdfile) or "", "", "NTPD_OPTS"), 2, -2)
if format.opts_to_table(opts, "-s") then
config.setstimeonstartup.value = true
end
@@ -99,7 +99,7 @@ function update_config(config)
local reverseservers = {} for i,val in ipairs(config.value.servers.value) do reverseservers[val] = i end
local reverselisten = {} for i,val in ipairs(config.value.listen.value) do reverselisten[val] = i end
- local configcontent = string.gsub(fs.read_file(configfile), "\n+$", "")
+ local configcontent = string.gsub(fs.read_file(configfile) or "", "\n+$", "")
local configlines = format.parse_linesandwords(configcontent)
for i=#configlines,1,-1 do
if configlines[i][1] == "server" then