return os.execute(cmd)
end
+--- Retrieve information about currently mounted file systems.
+-- @return Table containing mount information
+function mounts()
+ local data = {}
+ local k = {"fs", "blocks", "used", "available", "percent", "mountpoint"}
+ local ps = luci.util.execi("df")
+
+ if not ps then
+ return
+ else
+ ps()
+ end
+
+ for line in ps do
+ local row = {}
+
+ local j = 1
+ for value in line:gmatch("[^%s]+") do
+ row[k[j]] = value
+ j = j + 1
+ end
+
+ if row[k[1]] then
+ table.insert(data, row)
+ end
+ end
+
+ return data
+end
+
--- Retrieve environment variables. If no variable is given then a table
-- containing the whole environment is returned otherwise this function returns
-- the corresponding string value for the given name or nil if no such variable
return devices
end
+
+--- Return information about available network interfaces.
+-- @return Table containing all current interface names and their information
+function net.deviceinfo()
+ local devices = {}
+ for line in io.lines("/proc/net/dev") do
+ local name, data = line:match("^ *(.-): *(.*)$")
+ if name and data then
+ devices[name] = luci.util.split(data, " +", nil, true)
+ end
+ end
+ return devices
+end
+
+
-- Determine the MAC address belonging to the given IP address.
-- @param ip IPv4 address
-- @return String containing the MAC address or nil if it cannot be found
function user.checkpasswd(username, password)
local account = user.getuser(username)
- -- FIXME: detect testing environment
- if luci.fs.stat("/etc/shadow") and not luci.fs.access("/etc/shadow", "r") then
- return true
- elseif account then
+ if account then
if account.passwd == "!" then
return true
else