diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
commit | 5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973 (patch) | |
tree | 89b5c319d2f14352e25260d5fbf3ec67f85ca636 | |
parent | 9dfc491513676fa005f68cc764c4db37f0b3094f (diff) | |
download | acf-alpine-baselayout-5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973.tar.bz2 acf-alpine-baselayout-5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973.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/alpine-baselayout/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | cron-model.lua | 3 | ||||
-rw-r--r-- | health-model.lua | 8 | ||||
-rw-r--r-- | password-model.lua | 2 | ||||
-rw-r--r-- | syslog-model.lua | 2 |
4 files changed, 6 insertions, 9 deletions
diff --git a/cron-model.lua b/cron-model.lua index f900302..65d4393 100644 --- a/cron-model.lua +++ b/cron-model.lua @@ -107,9 +107,6 @@ function create_job(newjob) end if success then - if not posix.stat(baseurl..newjob.value.period.value) then - posix.mkdir(baseurl..newjob.value.period.value) - end fs.create_file(baseurl..newjob.value.period.value.."/"..newjob.value.name.value) else newjob.errtxt = "Failed to create new job" diff --git a/health-model.lua b/health-model.lua index 641a804..e012bf1 100644 --- a/health-model.lua +++ b/health-model.lua @@ -71,7 +71,7 @@ get_storage = function (self) storage.hd.value[name].used = string.match(line, name.."%s*%S*%s*%S*%s*%S*%s*(%S*)%%") end end - storage.partitions = cfe({ value=fs.read_file("/proc/partitions"), label="Partitions" }) + storage.partitions = cfe({ value=fs.read_file("/proc/partitions") or "", label="Partitions" }) return cfe({ type="group", value=storage }) end @@ -90,14 +90,14 @@ end get_proc = function (self) local proc = {} - proc.processor = cfe({ value=fs.read_file("/proc/cpuinfo"), label="Processor" }) - proc.memory = cfe({ value=fs.read_file("/proc/meminfo"), label="Memory" }) + proc.processor = cfe({ value=fs.read_file("/proc/cpuinfo") or "", label="Processor" }) + proc.memory = cfe({ value=fs.read_file("/proc/meminfo") or "", label="Memory" }) return cfe({ type="group", value=proc }) end get_networkstats = function () local stats = cfe({ type="structure", value={}, label="Network Stats", timestamp=os.time() }) - local result = fs.read_file("/proc/net/dev") + local result = fs.read_file("/proc/net/dev") or "" -- parse the result local i=0 for line in string.gmatch(result, "[^\n]+\n?") do diff --git a/password-model.lua b/password-model.lua index ba74e45..7dd9cd6 100644 --- a/password-model.lua +++ b/password-model.lua @@ -18,7 +18,7 @@ update_password = function (pw) pw.value.password.errtxt = "Invalid or non matching password" success = false end - local filecontent = "\n"..fs.read_file("/etc/shadow") + local filecontent = "\n"..(fs.read_file("/etc/shadow") or "") if pw.value.user.value == "" or not string.find(filecontent, "\n"..pw.value.user.value..":") then pw.value.user.errtxt = "Unknown user" success = false diff --git a/syslog-model.lua b/syslog-model.lua index 38920b3..ac6904f 100644 --- a/syslog-model.lua +++ b/syslog-model.lua @@ -180,7 +180,7 @@ end function getconfig() local config = {} if (fs.is_file(configfile)) then - local configcontent = format.opts_to_table(string.sub((format.parse_ini_file(fs.read_file(configfile), "", "SYSLOGD_OPTS") or ""),2,-2)) + local configcontent = format.opts_to_table(string.sub((format.parse_ini_file(fs.read_file(configfile) or "", "", "SYSLOGD_OPTS") or ""),2,-2)) config = makeconfig(configcontent) else config = makeconfig() |