+++ /dev/null
-include ../../build/config.mk
-include ../../build/gccconfig.mk
-
-BITLIB_VERSION = 25
-BITLIB_SITE = http://dev.luci.freifunk-halle.net/sources/
-BITLIB_DIR = bitlib-$(BITLIB_VERSION)
-BITLIB_FILE = $(BITLIB_DIR).tar.gz
-BITLIB_URL = $(BITLIB_SITE)/$(BITLIB_FILE)
-
-all: compile
-
-include ../../build/module.mk
-
-$(BITLIB_FILE):
- wget -O $@ $(BITLIB_URL) || rm -f $@
-
-$(BITLIB_DIR)/.prepared: $(BITLIB_FILE)
- rm -rf $(BITLIB_DIR)
- tar xvfz $(BITLIB_FILE)
- test -f $(BITLIB_DIR)/config.h || cp $(BITLIB_DIR)/config.h.in $(BITLIB_DIR)/config.h
- touch $@
-
-compile: $(BITLIB_DIR)/.prepared dist$(LUA_LIBRARYDIR)/bit.so
-
-dist$(LUA_LIBRARYDIR)/bit.so:
- mkdir -p dist$(LUA_LIBRARYDIR)
- $(COMPILE) -DHAVE_CONFIG_H -I$(BITLIB_DIR) -O2 -c $(BITLIB_DIR)/lbitlib.c $(FPIC) $(LUA_CFLAGS) -o $(BITLIB_DIR)/lbitlib.o
- $(LINK) $(SHLIB_FLAGS) $(LDFLAGS) $(BITLIB_DIR)/lbitlib.o $(LUA_SHLIBS) -lm -ldl -o dist$(LUA_LIBRARYDIR)/bit.so
-
-luasource:
-luastrip:
-luacompile:
-compile-all: compile
-
-clean:
- rm -rf $(BITLIB_DIR) $(BITLIB_FILE)
local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type
local io = require"io"
-local posix = require "posix"
+local posix = require "nixio.fs"
local lp = require "luadoc.lp"
local luadoc = require"luadoc"
local package = package
local assert, pairs, tostring, type = assert, pairs, tostring, type
local io = require "io"
-local posix = require "posix"
+local posix = require "nixio.fs"
local luadoc = require "luadoc"
local util = require "luadoc.util"
local tags = require "luadoc.taglet.standard.tags"
-- @return table with documentation
function directory (path, doc)
- for f in posix.files(path) do
+ for f in posix.dir(path) do
local fullpath = path .. "/" .. f
local attr = posix.stat(fullpath)
assert(attr, string.format("error stating file `%s'", fullpath))
- if attr.type == "regular" then
+ if attr.type == "reg" then
doc = file(fullpath, doc)
- elseif attr.type == "directory" and f ~= "." and f ~= ".." then
+ elseif attr.type == "dir" and f ~= "." and f ~= ".." then
doc = directory(fullpath, doc)
end
end
local attr = posix.stat(path)
assert(attr, string.format("error stating path `%s'", path))
- if attr.type == "regular" then
+ if attr.type == "reg" then
doc = file(path, doc)
- elseif attr.type == "directory" then
+ elseif attr.type == "dir" then
doc = directory(path, doc)
end
end)
-- @release $Id: util.lua,v 1.16 2008/02/17 06:42:51 jasonsantos Exp $
-------------------------------------------------------------------------------
-local posix = require "posix"
+local posix = require "nixio.fs"
local type, table, string, io, assert, tostring, setmetatable, pcall = type, table, string, io, assert, tostring, setmetatable, pcall
-------------------------------------------------------------------------------
+++ /dev/null
-luaposix-*
-lua-posix_*
-patches/series
+++ /dev/null
-include ../../build/config.mk
-include ../../build/gccconfig.mk
-
-LUAPOSIX_VERSION = 5.1.4
-LUAPOSIX_SITE = http://dev.luci.freifunk-halle.net/sources/
-LUAPOSIX_DIR = luaposix-$(LUAPOSIX_VERSION)
-LUAPOSIX_FILE = lua-posix_5.1.4.orig.tar.gz
-LUAPOSIX_URL = $(LUAPOSIX_SITE)/$(LUAPOSIX_FILE)
-LUAPOSIX_PATCHDIR = patches
-
-all: compile
-
-include ../../build/module.mk
-
-$(LUAPOSIX_FILE):
- wget -O $@ $(LUAPOSIX_URL) || rm -f $@
-
-$(LUAPOSIX_DIR)/.prepared: $(LUAPOSIX_FILE)
- rm -rf $(LUAPOSIX_DIR)
- tar xvfz $(LUAPOSIX_FILE)
- touch $@
-
-compile: $(LUAPOSIX_DIR)/.prepared
- $(MAKE) -C $(LUAPOSIX_DIR) CC=$(CC) CFLAGS="$(CFLAGS) $(LUA_CFLAGS)" LDFLAGS="$(LDFLAGS) $(LUA_SHLIBS)" OS="$(OS)"
- mkdir -p dist$(LUA_LIBRARYDIR)
- cp $(LUAPOSIX_DIR)/posix.so dist$(LUA_LIBRARYDIR)
-
-luasource:
-luastrip:
-luacompile:
-compile-all: compile
-
-clean:
- rm -rf $(LUAPOSIX_DIR) $(LUAPOSIX_FILE)
- rm -f $(LUAPOSIX_PATCHDIR)/series
define Package/luci-core
$(call Package/luci/libtemplate)
- DEPENDS:=+lua
+ DEPENDS:=+lua +luci-nixio
TITLE:=LuCI core libraries
endef
define Package/luci-nixio
$(call Package/luci/libtemplate)
- TITLE:=NIXIO Socket Library
+ TITLE:=NIXIO POSIX Library
DEPENDS:=
endef
local filestat = luci.fs.stat( filepath )
local baseurl = luci.dispatcher.build_url('admin', 'filebrowser')
- if filestat and filestat.type == "regular" then
+ if filestat and filestat.type == "reg" then
table.remove( path, #path )
filepath = table.concat( path, '/' ) .. '/'
- elseif not ( filestat and filestat.type == "directory" ) then
+ elseif not ( filestat and filestat.type == "dir" ) then
path = { '' }
filepath = '/'
else
<ul>
<% for _, e in luci.util.vspairs(entries) do
local stat = luci.fs.stat(filepath..e)
- if e ~= '.' and e ~= '..' and stat and stat.type == 'directory' then
+ if e ~= '.' and e ~= '..' and stat and stat.type == 'dir' then
-%>
<li class="dir">
<img src="/luci-static/resources/cbi/folder.png" alt="Directory" />
<% for _, e in luci.util.vspairs(entries) do
local stat = luci.fs.stat(filepath..e)
- if stat and stat.type ~= 'directory' then
+ if stat and stat.type ~= 'dir' then
-%>
<li class="file">
<img src="/luci-static/resources/cbi/file.png" alt="File" />
-%>
<%+cbi/valueheader%>
<% if v then %>
- <%:cbi_upload Uploaded File%> (<%=t.byte_format(luci.fs.stat(v).size or 0)%>)
+ <%:cbi_upload Uploaded File%> (<%=t.byte_format(luci.fs.stat(v, "size") or 0)%>)
<input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
<input class="cbi-input-image" type="image" value="<%:cbi_replace%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:cbi_replace%>" title="<%:cbi_replace%>" src="<%=resource%>/cbi/reload.gif" />
<% else %>
]]--
local io = require "io"
+local fs = require "nixio.fs"
local util = require "luci.util"
-local posix = require "posix"
+local nixio = require "nixio"
local debug = require "debug"
local string = require "string"
local package = require "package"
mode = mode or "r--r--r--"
local loader = package.loaders[2]
- local uid = posix.getpid("uid")
+ local uid = nixio.getpid("uid")
- if not posix.stat(cachepath) then
- posix.mkdir(cachepath)
+ if not fs.stat(cachepath) then
+ fs.mkdir(cachepath)
end
local function _encode_filename(name)
end
local function _load_sane(file)
- local stat = posix.stat(file)
+ local stat = fs.stat(file)
if stat and stat.uid == uid and stat.mode == mode then
return loadfile(file)
end
end
local function _write_sane(file, func)
- if posix.getpid("uid") == uid then
+ if nixio.getuid() == uid then
local fp = io.open(file, "w")
if fp then
fp:write(util.get_bytecode(func))
fp:close()
- posix.chmod(file, mode)
+ fs.chmod(file, mode)
end
end
end
local io = require "io"
local os = require "os"
local ltn12 = require "luci.ltn12"
-local posix = require "posix"
+local fs = require "nixio.fs"
+local nutil = require "nixio.util"
local type = type
-- @return Number containing the return code, 0 on sucess or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
-access = posix.access
+access = fs.access
--- Evaluate given shell glob pattern and return a table containing all matching
-- file and directory entries.
-- @return Table containing file and directory entries or nil if no matches
-- @return String containing the error description (if no matches)
-- @return Number containing the os specific errno (if no matches)
-glob = posix.glob
+function glob(...)
+ local iter, code, msg = fs.glob(...)
+ if iter then
+ return nutil.consume(iter)
+ else
+ return nil, code, msg
+ end
+end
--- Checks wheather the given path exists and points to a regular file.
-- @param filename String containing the path of the file to test
-- @return Boolean indicating wheather given path points to regular file
function isfile(filename)
- return posix.stat(filename, "type") == "regular"
+ return fs.stat(filename, "type") == "reg"
end
--- Checks wheather the given path exists and points to a directory.
-- @param dirname String containing the path of the directory to test
-- @return Boolean indicating wheather given path points to directory
function isdirectory(dirname)
- return posix.stat(dirname, "type") == "directory"
+ return fs.stat(dirname, "type") == "dir"
end
--- Read the whole content of the given file into memory.
-- @param filename String containing the path of the file to read
-- @return String containing the file contents or nil on error
-- @return String containing the error message on error
-function readfile(filename)
- local fp, err = io.open(filename)
-
- if fp == nil then
- return nil, err
- end
-
- local data = fp:read("*a")
- fp:close()
- return data
-end
+readfile = fs.readfile
--- Write the contents of given string to given file.
-- @param filename String containing the path of the file to read
-- @param data String containing the data to write
-- @return Boolean containing true on success or nil on error
-- @return String containing the error message on error
-function writefile(filename, data)
- local fp, err = io.open(filename, "w")
-
- if fp == nil then
- return nil, err
- end
-
- fp:write(data)
- fp:close()
-
- return true
-end
+writefile = fs.writefile
--- Copies a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
-function copy(source, dest)
- return ltn12.pump.all(
- ltn12.source.file(io.open(source)),
- ltn12.sink.file(io.open(dest, "w"))
- )
-end
+copy = fs.datacopy
--- Renames a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
-function rename(source, dest)
- local stat, err, code = os.rename(source, dest)
- if code == 18 then
- stat, err, code = copy(source, dest)
- if stat then
- stat, err, code = unlink(source)
- end
- end
- return stat, err, code
-end
+rename = fs.move
--- Get the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function mtime(path)
- return posix.stat(path, "mtime")
+ return fs.stat(path, "mtime")
end
--- Set the last modification time of given file path in Unix epoch format.
-- @return 0 in case of success nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
-utime = posix.utime
+function utime(path, mtime, atime)
+ return fs.utimes(path, atime, mtime)
+end
--- Return the last element - usually the filename - from the given path with
-- the directory component stripped.
-- @param path String containing the path to strip
-- @return String containing the base name of given path
-- @see dirname
-basename = posix.basename
+basename = fs.basename
--- Return the directory component of the given path with the last element
-- stripped of.
-- @param path String containing the path to strip
-- @return String containing the directory component of given path
-- @see basename
-dirname = posix.dirname
+dirname = fs.dirname
--- Return a table containing all entries of the specified directory.
-- @class function
-- @return Table containing file and directory entries or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-dir = posix.dir
+function dir(...)
+ local iter, code, msg = fs.dir(...)
+ if iter then
+ local t = nutil.consume(iter)
+ t[#t+1] = "."
+ t[#t+1] = ".."
+ return t
+ else
+ return nil, code, msg
+ end
+end
--- Create a new directory, recursively on demand.
-- @param path String with the name or path of the directory to create
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function mkdir(path, recursive)
- if recursive then
- local base = "."
-
- if path:sub(1,1) == "/" then
- base = ""
- path = path:gsub("^/+","")
- end
-
- for elem in path:gmatch("([^/]+)/*") do
- base = base .. "/" .. elem
-
- local stat = posix.stat( base )
-
- if not stat then
- local stat, errmsg, errno = posix.mkdir( base )
-
- if type(stat) ~= "number" or stat ~= 0 then
- return stat, errmsg, errno
- end
- else
- if stat.type ~= "directory" then
- return nil, base .. ": File exists", 17
- end
- end
- end
-
- return 0
- else
- return posix.mkdir( path )
- end
+ return recursive and fs.mkdirr(path) or fs.mkdir(path)
end
--- Remove the given empty directory.
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-rmdir = posix.rmdir
+rmdir = fs.rmdir
--- Get information about given file or directory.
-- @class function
-- @return Table containing file or directory properties or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-stat = posix.stat
+stat = fs.stat
--- Set permissions on given file or directory.
-- @class function
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-chmod = posix.chmod
+chmod = fs.chmod
--- Create a hard- or symlink from given file (or directory) to specified target
-- file (or directory) path.
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-link = posix.link
+function link(src, dest, sym)
+ return sym and fs.symlink(src, dest) or fs.link(src, dest)
+end
--- Remove the given file.
-- @class function
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-unlink = posix.unlink
+unlink = fs.unlink
--- Retrieve target of given symlink.
-- @class function
-- @return String containing the link target or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
-readlink = posix.readlink
+readlink = fs.readlink
local function splice_sync(sock, pipeout, pipein, file, cb)
local os = require "os"
- local posix = require "posix"
local ssize = 65536
local smode = nixio.splice_flags("move", "more")
local stat
-- This is probably the only forking http-client ;-)
- local pid, code, msg = posix.fork()
+ local pid, code, msg = nixio.fork()
if not pid then
return pid, code, msg
elseif pid == 0 then
file:close()
if not stat then
- posix.kill(pid)
- posix.wait(pid)
+ nixio.kill(pid, 15)
+ nixio.wait(pid)
return stat, code, msg
else
- pid, msg, code = posix.wait(pid)
+ pid, msg, code = nixio.wait(pid)
if msg == "exited" then
if code == 0 then
return true
local io = require "io"
local os = require "os"
-local posix = require "posix"
+local nixio = require "nixio"
local table = require "table"
local luci = {}
-- @param var Name of the environment variable to retrieve (optional)
-- @return String containg the value of the specified variable
-- @return Table containing all variables if no variable name is given
-getenv = posix.getenv
+getenv = nixio.getenv
--- Get or set the current hostname.
-- @param String containing a new hostname to set (optional)
luci.fs.writefile( "/proc/sys/kernel/hostname", newname .. "\n" )
return newname
else
- return posix.uname("%n")
+ return nixio.uname().nodename
end
end
-- @return String containing the average load value 1 minute ago
-- @return String containing the average load value 5 minutes ago
-- @return String containing the average load value 15 minutes ago
--- @return String containing the active and total number of processes
--- @return String containing the last used pid
function loadavg()
- local loadavg = io.lines("/proc/loadavg")()
- return loadavg:match("^(.-) (.-) (.-) (.-) (.-)$")
+ local info = nixio.sysinfo()
+ return info.loads[1], info.loads[2], info.loads[3]
end
--- Initiate a system reboot.
local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)"))
if not system then
- system = posix.uname("%m")
+ system = nixio.uname().machine
model = cpuinfo:match("model name.-:%s*([^\n]+)")
if not model then
model = cpuinfo:match("Processor.-:%s*([^\n]+)")
return loadavg:match("^(.-) (.-)$")
end
---- LuCI system utilities / POSIX user group related functions.
--- @class module
--- @name luci.sys.group
-group = {}
-
---- Returns information about a POSIX user group.
--- @class function
--- @name getgroup
--- @param group Group ID or name of a system user group
--- @return Table with information about the requested group
-group.getgroup = posix.getgroup
-
--- LuCI system utilities / network related functions.
-- @class module
-- @class function
-- @name process.info
-- @return Number containing the current pid
-process.info = posix.getpid
+function process.info(key)
+ local s = {uid = nixio.getuid(), gid = nixio.getgid()}
+ return not key and s or s[key]
+end
--- Retrieve information about currently running processes.
-- @return Table containing process information
end
--- Set the gid of a process identified by given pid.
--- @param pid Number containing the process id
-- @param gid Number containing the Unix group id
-- @return Boolean indicating successful operation
-- @return String containing the error message if failed
-- @return Number containing the error code if failed
-function process.setgroup(pid, gid)
- return posix.setpid("g", pid, gid)
+function process.setgroup(gid)
+ return nixio.setgid(gid)
end
--- Set the uid of a process identified by given pid.
--- @param pid Number containing the process id
-- @param uid Number containing the Unix user id
-- @return Boolean indicating successful operation
-- @return String containing the error message if failed
-- @return Number containing the error code if failed
-function process.setuser(pid, uid)
- return posix.setpid("u", pid, uid)
+function process.setuser(uid)
+ return nixio.setuid(uid)
end
--- Send a signal to a process identified by given pid.
-- @param sig Signal to send (default: 15 [SIGTERM])
-- @return Boolean indicating successful operation
-- @return Number containing the error code if failed
-process.signal = posix.kill
+process.signal = nixio.kill
--- LuCI system utilities / user related functions.
-- @param uid Number containing the Unix user id
-- @return Table containing the following fields:
-- { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
-user.getuser = posix.getpasswd
+user.getuser = nixio.getpw
--- Test whether given string matches the password of a given system user.
-- @param username String containing the Unix user name
--- @param password String containing the password to compare
+-- @param pass String containing the password to compare
-- @return Boolean indicating wheather the passwords are equal
-function user.checkpasswd(username, password)
- local account = user.getuser(username)
-
- if account then
- local pwd = account.passwd
- local shadowpw
- if #pwd == 1 then
- if luci.fs.stat("/etc/shadow") then
- if not pcall(function()
- for l in io.lines("/etc/shadow") do
- shadowpw = l:match("^%s:([^:]+)" % username)
- if shadowpw then
- pwd = shadowpw
- break
- end
- end
- end) then
- return nil, "Unable to access shadow-file"
- end
- end
-
- if pwd == "!" then
- return true
- end
- end
-
- if pwd and #pwd > 0 and password and #password > 0 then
- return (pwd == posix.crypt(password, pwd))
- end
+function user.checkpasswd(username, pass)
+ local pwe = nixio.getsp and nixio.getsp(username) or nixio.getpw(username)
+ local pwh = pwe and (pwe.pwdp or pwe.passwd)
+ if not pwh or #pwh < 1 or pwh ~= "!" and nixio.crypt(pass, pwh) ~= pwh then
+ return false
+ else
+ return true
end
-
- return false
end
--- Change the password of given user.
if s and not seen[s.ino] then
seen[s.ino] = true
- if s.type == "directory" then
+ if s.type == "dir" then
return true
- elseif s.type == "link" then
+ elseif s.type == "lnk" then
return directory( fs.readlink(val), seen )
end
end
if s and not seen[s.ino] then
seen[s.ino] = true
- if s.type == "regular" then
+ if s.type == "reg" then
return true
- elseif s.type == "link" then
+ elseif s.type == "lnk" then
return file( fs.readlink(val), seen )
end
end
if s and not seen[s.ino] then
seen[s.ino] = true
- if s.type == "character device" or s.type == "block device" then
+ if s.type == "chr" or s.type == "blk" then
return true
- elseif s.type == "link" then
+ elseif s.type == "lnk" then
return device( fs.readlink(val), seen )
end
end
local init = require "luci.init"
local util = require "luci.util"
local http = require "luci.http"
+local nixio = require "nixio", require "nixio.util"
module("luci.dispatcher", package.seeall)
context = util.threadlocal()
if (c and c.index) or not track.notemplate then
local tpl = require("luci.template")
local media = track.mediaurlbase or luci.config.main.mediaurlbase
- if not pcall(tpl.Template, "themes/%s/header" % fs.basename(media)) then
+ if not tpl.Template("themes/%s/header" % fs.basename(media)) then
+ --if not pcall(tpl.Template, "themes/%s/header" % fs.basename(media)) then
media = nil
for name, theme in pairs(luci.config.themes) do
if name:sub(1,1) ~= "." and pcall(tpl.Template,
if cachedate > realdate then
assert(
sys.process.info("uid") == fs.stat(indexcache, "uid")
- and fs.stat(indexcache, "mode") == "rw-------",
+ and fs.stat(indexcache, "modestr") == "rw-------",
"Fatal: Indexcache is not sane!"
)
end
if indexcache then
- fs.writefile(indexcache, util.get_bytecode(index))
- fs.chmod(indexcache, "a-rwx,u+rw")
+ local f = nixio.open(indexcache, "w", 600)
+ f:writeall(util.get_bytecode(index))
+ f:close()
end
end
require("luci.util")
require("luci.sys")
require("luci.config")
+local nixio = require "nixio", require "nixio.util"
+local fs = require "nixio.fs"
luci.config.sauth = luci.config.sauth or {}
for i, file in pairs(files) do
local fname = sessionpath .. "/" .. file
local stat = luci.fs.stat(fname)
- if stat and stat.type == "regular" and stat.atime + sessiontime < now then
+ if stat and stat.type == "reg" and stat.mtime + sessiontime < now then
luci.fs.unlink(fname)
end
end
--- Prepare session storage by creating the session directory.
function prepare()
- luci.fs.mkdir(sessionpath)
- luci.fs.chmod(sessionpath, "a-rwx,u+rwx")
+ fs.mkdir(sessionpath, 700)
if not sane() then
error("Security Exception: Session path is not sane!")
if not sane(sessionpath .. "/" .. id) then
return
end
+ luci.fs.utime(sessionpath .. "/" .. id)
return luci.fs.readfile(sessionpath .. "/" .. id)
end
function sane(file)
return luci.sys.process.info("uid")
== luci.fs.stat(file or sessionpath, "uid")
- and luci.fs.stat(file or sessionpath, "mode")
+ and luci.fs.stat(file or sessionpath, "modestr")
== (file and "rw-------" or "rwx------")
end
if not id:match("^%w+$") then
error("Session ID is not sane!")
end
- luci.fs.writefile(sessionpath .. "/" .. id, data)
- luci.fs.chmod(sessionpath .. "/" .. id, "a-rwx,u+rw")
+
+ local f = nixio.open(sessionpath .. "/" .. id, "w", 600)
+ f:writeall(data)
+ f:close()
end
local string = require "string"
local config = require "luci.config"
local coroutine = require "coroutine"
+local nixio = require "nixio", require "nixio.util"
local tostring, pairs, loadstring = tostring, pairs, loadstring
local setmetatable, loadfile = setmetatable, loadfile
if not fs.mtime(cdir) then
fs.mkdir(cdir, true)
- fs.chmod(fs.dirname(cdir), "a+rxw")
+ fs.chmod(fs.dirname(cdir), 777)
end
assert(tplmt or commt, "No such template: " .. name)
if source then
local compiled, err = compile(source)
- fs.writefile(compiledfile, util.get_bytecode(compiled))
- fs.chmod(compiledfile, "a-rwx,u+rw")
+ local f = nixio.open(compiledfile, "w", 600)
+ f:writeall(util.get_bytecode(compiled))
+ f:close()
self.template = compiled
end
else
assert(
sys.process.info("uid") == fs.stat(compiledfile, "uid")
- and fs.stat(compiledfile, "mode") == "rw-------",
+ and fs.stat(compiledfile, "modestr") == "rw-------",
"Fatal: Cachefile is not sane!"
)
self.template, err = loadfile(compiledfile)
require "os"
require "io"
require "uci"
-require "posix"
+local fs = require "nixio.fs"
-if posix.access("/var/run/olsrd.pid") then
+if fs.access("/var/run/olsrd.pid") then
local stamp, intv
local x = uci.cursor()
end
end)
- if intv and posix.access(stamp) then
+ if intv and fs.access(stamp) then
local systime = os.time()
local wdgtime = tonumber(io.lines(stamp)())