diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-09-29 18:01:28 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-09-29 18:01:28 +0000 |
commit | 70cffc589d8a79c36f8c6847f89b926d761b3f7a (patch) | |
tree | be8d662404cb6d774515ba87d2a0b992ca540893 | |
parent | 6260c183d7adb98281e1b19d30ce10a18bd2b1d7 (diff) | |
download | acf-openntpd-70cffc589d8a79c36f8c6847f89b926d761b3f7a.tar.bz2 acf-openntpd-70cffc589d8a79c36f8c6847f89b926d761b3f7a.tar.xz |
Removed getopts library and added functionality to format library as opts_to_table, table_to_opts, parse_configfile2, update_configfile2, get_section, and set_section. New functions work on strings, not files. Modified all code using getopts to use format instead. Fixed nil string bugs in TCPProxy. Fixed forward only bug in DNSCache.
git-svn-id: svn://svn.alpinelinux.org/acf/openntpd/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | openntpd-model.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/openntpd-model.lua b/openntpd-model.lua index 2c77e39..52bffd3 100644 --- a/openntpd-model.lua +++ b/openntpd-model.lua @@ -3,7 +3,7 @@ module (..., package.seeall) -- Load libraries require("modelfunctions") require("fs") -require("getopts") +require("format") -- Set variables local configfile = "/etc/ntpd.conf" @@ -83,7 +83,8 @@ function read_config () end end - if getopts.getoptsfromfile(confdfile, "", "NTPD_OPTS", true, "-s") then + local opts = string.sub(format.parse_configfile2(fs.read_file(confdfile), "", "NTPD_OPTS"), 2, -2) + if format.opts_to_table(opts, "-s") then config.setstimeonstartup.value = true end @@ -137,7 +138,7 @@ function update_config(config) -- Finally, handle setstimeonstartup local opts = {} if config.value.setstimeonstartup.value then opts["-s"] = "" end - getopts.setoptsinfile(confdfile, "", "NTPD_OPTS", '"'..getopts.table_to_opts(opts)..'"') + fs.write_file(confdfile, format.update_configfile2(fs.read_file(confdfile) or "", "", "NTPD_OPTS", '"'..format.table_to_opts(opts)..'"')) else config.errtxt = "Failed to save config" end |