From: Jo-Philipp Wich Date: Thu, 23 Jul 2009 03:32:30 +0000 (+0000) Subject: luci-0.9: merge r5027 - r5112 X-Git-Tag: 0.9.0~158 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1937aad8967f224f78920667045a4b5bcbb1e040;p=oweals%2Fluci.git luci-0.9: merge r5027 - r5112 --- diff --git a/Makefile b/Makefile index 13438848e..905206701 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ all: build build: gccbuild luabuild gccbuild: + make -C libs/lmo CC="cc" CFLAGS="" LDFLAGS="" host-install for i in $(MODULES); do \ make -C$$i compile || { \ echo "*** Compilation of $$i failed!"; \ @@ -28,6 +29,7 @@ i18nbuild: clean: rm -rf docs + make -C libs/lmo host-clean for i in $(MODULES); do make -C$$i clean; done diff --git a/applications/luci-ddns/luasrc/controller/ddns.lua b/applications/luci-ddns/luasrc/controller/ddns.lua index 6adbbb0ca..7a81d9adf 100644 --- a/applications/luci-ddns/luasrc/controller/ddns.lua +++ b/applications/luci-ddns/luasrc/controller/ddns.lua @@ -17,7 +17,7 @@ module("luci.controller.ddns", package.seeall) function index() require("luci.i18n") luci.i18n.loadc("ddns") - if not luci.fs.access("/etc/config/ddns") then + if not nixio.fs.access("/etc/config/ddns") then return end @@ -29,4 +29,4 @@ function index() local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddnsmini", {autoapply=true}), luci.i18n.translate("ddns"), 60) page.i18n = "ddns" page.dependent = true -end \ No newline at end of file +end diff --git a/applications/luci-hd_idle/luasrc/controller/hd_idle.lua b/applications/luci-hd_idle/luasrc/controller/hd_idle.lua index 5dfbe16ea..57ff10d7c 100644 --- a/applications/luci-hd_idle/luasrc/controller/hd_idle.lua +++ b/applications/luci-hd_idle/luasrc/controller/hd_idle.lua @@ -18,7 +18,7 @@ module("luci.controller.hd_idle", package.seeall) function index() require("luci.i18n") luci.i18n.loadc("hd_idle") - if not luci.fs.access("/etc/config/hd-idle") then + if not nixio.fs.access("/etc/config/hd-idle") then return end diff --git a/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua b/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua index b59df829f..60817db83 100644 --- a/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua +++ b/applications/luci-hd_idle/luasrc/model/cbi/hd_idle.lua @@ -13,7 +13,7 @@ $Id$ ]]-- -require("luci.fs") +require("nixio.fs") m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc")) @@ -24,8 +24,8 @@ s:option(Flag, "enabled", translate("enable", "Enable")) disk = s:option(Value, "disk", translate("disk")) disk.rmempty = true -for _, dev in ipairs(luci.fs.glob("/dev/[sh]d[a-z]")) do - disk:value(luci.fs.basename(dev)) +for _, dev in nixio.fs.glob("/dev/[sh]d[a-z]") do + disk:value(nixio.fs.basename(dev)) end s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10 diff --git a/applications/luci-initmgr/luasrc/controller/init.lua b/applications/luci-initmgr/luasrc/controller/init.lua index fbbc7270f..c7ef43f83 100644 --- a/applications/luci-initmgr/luasrc/controller/init.lua +++ b/applications/luci-initmgr/luasrc/controller/init.lua @@ -15,7 +15,7 @@ $Id$ module("luci.controller.init", package.seeall) function index() - if not luci.fs.access("/etc/rc.common") then + if not nixio.fs.access("/etc/rc.common") then return end diff --git a/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua b/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua index 7beaa144f..57fe5ee38 100644 --- a/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua +++ b/applications/luci-mmc_over_gpio/luasrc/controller/mmc_over_gpio.lua @@ -18,7 +18,7 @@ module("luci.controller.mmc_over_gpio", package.seeall) function index() require("luci.i18n") luci.i18n.loadc("mmc_over_gpio") - if not luci.fs.access("/etc/config/mmc_over_gpio") then + if not nixio.fs.access("/etc/config/mmc_over_gpio") then return end diff --git a/applications/luci-ntpc/luasrc/controller/ntpc.lua b/applications/luci-ntpc/luasrc/controller/ntpc.lua index 929064468..0d656a48f 100644 --- a/applications/luci-ntpc/luasrc/controller/ntpc.lua +++ b/applications/luci-ntpc/luasrc/controller/ntpc.lua @@ -17,7 +17,7 @@ module("luci.controller.ntpc", package.seeall) function index() require("luci.i18n") luci.i18n.loadc("ntpc") - if not luci.fs.access("/etc/config/ntpclient") then + if not nixio.fs.access("/etc/config/ntpclient") then return end diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua index 652f6b9d2..837873adf 100644 --- a/applications/luci-olsr/luasrc/controller/olsr.lua +++ b/applications/luci-olsr/luasrc/controller/olsr.lua @@ -1,7 +1,7 @@ module("luci.controller.olsr", package.seeall) function index() - if not luci.fs.access("/etc/config/olsrd") then + if not nixio.fs.access("/etc/config/olsrd") then return end @@ -182,7 +182,7 @@ function fetch_txtinfo(otable) local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable) if #rawdata == 0 then - if luci.fs.access("/proc/net/ipv6_route", "r") then + if nixio.fs.access("/proc/net/ipv6_route", "r") then rawdata = luci.sys.httpget("http://[::1]:2006/"..otable) if #rawdata == 0 then return nil diff --git a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua index 03f18a818..f81a4a4b4 100644 --- a/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua +++ b/applications/luci-olsr/luasrc/model/cbi/olsr/olsrdplugins.lua @@ -13,9 +13,8 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.fs") -require("luci.ip") - +local ip = require "luci.ip" +local fs = require "nixio.fs" if arg[1] then mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins")) @@ -44,7 +43,7 @@ if arg[1] then local function Cidr2IpMask(val) if val then for i = 1, #val do - local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i]) + local cidr = ip.IPv4(val[i]) or ip.IPv6(val[i]) if cidr then val[i] = cidr:network():string() .. " " .. cidr:mask():string() end @@ -59,9 +58,9 @@ if arg[1] then local ip, mask = val[i]:gmatch("([^%s]+)%s+([^%s]+)")() local cidr if ip and mask and ip:match(":") then - cidr = luci.ip.IPv6(ip, mask) + cidr = ip.IPv6(ip, mask) elseif ip and mask then - cidr = luci.ip.IPv4(ip, mask) + cidr = ip.IPv4(ip, mask) end if cidr then @@ -220,7 +219,7 @@ else ) -- create a loadplugin section for each found plugin - for k, v in pairs(luci.fs.dir("/usr/lib")) do + for v in fs.dir("/usr/lib") do if v:sub(1, 6) == "olsrd_" then if not plugins[v] then mpi.uci:section( diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua index 834dceb24..13dfd1297 100644 --- a/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua +++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua @@ -12,7 +12,6 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.fs") require("luci.ip") diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua index 1d4cc4d7a..b3e22d480 100644 --- a/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua +++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua @@ -12,7 +12,6 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.fs") require("luci.ip") require("luci.model.uci") diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua index 863be2f13..e71becd06 100644 --- a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua +++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua @@ -12,13 +12,9 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.fs") -require("luci.ip") -require("luci.sys") -require("luci.model.uci") - - -local uci = luci.model.uci.cursor() +local fs = require "nixio.fs" +local sys = require "luci.sys" +local uci = require "luci.model.uci".cursor() local m = Map("openvpn", translate("openvpn")) local s = m:section( TypedSection, "openvpn", translate("openvpn_overview"), translate("openvpn_overview_desc") ) @@ -74,13 +70,11 @@ s:option( Flag, "enable", translate("openvpn_enable") ) local active = s:option( DummyValue, "_active", translate("openvpn_active") ) function active.cfgvalue(self, section) - if luci.fs.isfile("/var/run/openvpn_%s.pid" % section) then - local pid = io.lines("/var/run/openvpn_%s.pid" % section)() - if pid and #pid > 0 and tonumber(pid) ~= nil then - return (luci.sys.process.signal(pid, 0)) - and translatef("openvpn_active_yes", pid) - or translate("openvpn_active_no") - end + local pid = fs.readfile("/var/run/openvpn_%s.pid" % section) + if pid and #pid > 0 and tonumber(pid) ~= nil then + return (sys.process.signal(pid, 0)) + and translatef("openvpn_active_yes", pid) + or translate("openvpn_active_no") end return translate("openvpn_active_no") end diff --git a/applications/luci-p910nd/luasrc/controller/p910nd.lua b/applications/luci-p910nd/luasrc/controller/p910nd.lua index 75b2693d4..13167013c 100644 --- a/applications/luci-p910nd/luasrc/controller/p910nd.lua +++ b/applications/luci-p910nd/luasrc/controller/p910nd.lua @@ -18,7 +18,7 @@ module("luci.controller.p910nd", package.seeall) function index() require("luci.i18n") luci.i18n.loadc("p910nd") - if not luci.fs.access("/etc/config/p910nd") then + if not nixio.fs.access("/etc/config/p910nd") then return end diff --git a/applications/luci-polipo/luasrc/controller/polipo.lua b/applications/luci-polipo/luasrc/controller/polipo.lua index 949f80a62..3d9f7d1ff 100644 --- a/applications/luci-polipo/luasrc/controller/polipo.lua +++ b/applications/luci-polipo/luasrc/controller/polipo.lua @@ -14,7 +14,7 @@ $Id$ module("luci.controller.polipo", package.seeall) function index() - if not luci.fs.access("/etc/config/polipo") then + if not nixio.fs.access("/etc/config/polipo") then return end diff --git a/applications/luci-qos/luasrc/controller/qos.lua b/applications/luci-qos/luasrc/controller/qos.lua index 970dd3d60..af9b11499 100644 --- a/applications/luci-qos/luasrc/controller/qos.lua +++ b/applications/luci-qos/luasrc/controller/qos.lua @@ -14,7 +14,7 @@ $Id$ module("luci.controller.qos", package.seeall) function index() - if not luci.fs.access("/etc/config/qos") then + if not nixio.fs.access("/etc/config/qos") then return end @@ -26,4 +26,4 @@ function index() local page = entry({"mini", "network", "qos"}, cbi("qos/qosmini", {autoapply=true}), "QoS") page.i18n = "qos" page.dependent = true -end \ No newline at end of file +end diff --git a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua index 22dfbea5f..ec450cf6e 100644 --- a/applications/luci-qos/luasrc/model/cbi/qos/qos.lua +++ b/applications/luci-qos/luasrc/model/cbi/qos/qos.lua @@ -11,7 +11,10 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.tools.webadmin") + +local wa = require "luci.tools.webadmin" +local fs = require "nixio.fs" + m = Map("qos") s = m:section(TypedSection, "interface", translate("interfaces")) @@ -46,19 +49,19 @@ t.default = "Normal" srch = s:option(Value, "srchost") srch.rmempty = true srch:value("", translate("all")) -luci.tools.webadmin.cbi_add_knownips(srch) +wa.cbi_add_knownips(srch) dsth = s:option(Value, "dsthost") dsth.rmempty = true dsth:value("", translate("all")) -luci.tools.webadmin.cbi_add_knownips(dsth) +wa.cbi_add_knownips(dsth) l7 = s:option(ListValue, "layer7", translate("service")) l7.rmempty = true l7:value("", translate("all")) -local pats = luci.fs.dir("/etc/l7-protocols") +local pats = fs.dir("/etc/l7-protocols") if pats then - for i,f in ipairs(pats) do + for f in pats do if f:sub(-4) == ".pat" then l7:value(f:sub(1, #f-4)) end diff --git a/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua index ec93694c2..cb7968264 100644 --- a/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua +++ b/applications/luci-qos/luasrc/model/cbi/qos/qosmini.lua @@ -12,7 +12,10 @@ You may obtain a copy of the License at $Id$ ]]-- -require("luci.tools.webadmin") + +local wa = require "luci.tools.webadmin" +local fs = require "nixio.fs" + m = Map("qos") s = m:section(NamedSection, "wan", "interface", translate("m_n_inet")) @@ -37,19 +40,19 @@ t.default = "Normal" srch = s:option(Value, "srchost") srch.rmempty = true srch:value("", translate("all")) -luci.tools.webadmin.cbi_add_knownips(srch) +wa.cbi_add_knownips(srch) dsth = s:option(Value, "dsthost") dsth.rmempty = true dsth:value("", translate("all")) -luci.tools.webadmin.cbi_add_knownips(dsth) +wa.cbi_add_knownips(dsth) l7 = s:option(ListValue, "layer7", translate("service")) l7.rmempty = true l7:value("", translate("all")) -local pats = luci.fs.dir("/etc/l7-protocols") +local pats = fs.dir("/etc/l7-protocols") if pats then - for i,f in ipairs(pats) do + for f in pats do if f:sub(-4) == ".pat" then l7:value(f:sub(1, #f-4)) end diff --git a/applications/luci-samba/luasrc/controller/samba.lua b/applications/luci-samba/luasrc/controller/samba.lua index 75cb65a0b..c2d5d849a 100644 --- a/applications/luci-samba/luasrc/controller/samba.lua +++ b/applications/luci-samba/luasrc/controller/samba.lua @@ -15,7 +15,7 @@ $Id$ module("luci.controller.samba", package.seeall) function index() - if not luci.fs.access("/etc/config/samba") then + if not nixio.fs.access("/etc/config/samba") then return end require("luci.i18n") diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua index 13f9f4121..362ad9def 100644 --- a/applications/luci-splash/luasrc/controller/splash/splash.lua +++ b/applications/luci-splash/luasrc/controller/splash/splash.lua @@ -11,9 +11,18 @@ function index() end function action_dispatch() + local uci = luci.model.uci.cursor_state() local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or "" - local status = luci.util.execl("luci-splash status "..mac)[1] - if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then + local access = false + + uci:foreach("luci_splash", "lease", function(s) + if s.mac and s.mac:lower() == mac then access = true end + end) + uci:foreach("luci_splash", "whitelist", function(s) + if s.mac and s.mac:lower() == mac then access = true end + end) + + if #mac > 0 and access then luci.http.redirect(luci.dispatcher.build_url()) else luci.http.redirect(luci.dispatcher.build_url("splash", "splash")) diff --git a/applications/luci-splash/luasrc/view/admin_status/splash.htm b/applications/luci-splash/luasrc/view/admin_status/splash.htm index 99395200d..4151c66c3 100644 --- a/applications/luci-splash/luasrc/view/admin_status/splash.htm +++ b/applications/luci-splash/luasrc/view/admin_status/splash.htm @@ -18,6 +18,8 @@ local utl = require "luci.util" local ipt = require "luci.sys.iptparser".IptParser() local uci = require "luci.model.uci".cursor_state() local wat = require "luci.tools.webadmin" +local fs = require "nixio.fs" + local clients = { } local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60 local leasefile = "/tmp/dhcp.leases" @@ -94,7 +96,7 @@ uci:foreach("luci_splash", "blacklist", end end) -if luci.fs.access(leasefile) then +if fs.access(leasefile) then for l in io.lines(leasefile) do local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)") if time and mac and ip then diff --git a/applications/luci-splash/root/usr/sbin/luci-splash b/applications/luci-splash/root/usr/sbin/luci-splash index 017cfebfc..1adcb0932 100755 --- a/applications/luci-splash/root/usr/sbin/luci-splash +++ b/applications/luci-splash/root/usr/sbin/luci-splash @@ -29,7 +29,7 @@ function main(argv) limit_down = tonumber(uci:get("luci_splash", "general", "limit_down")) or 0 if ( cmd == "lease" or cmd == "add-rules" or cmd == "remove" or - cmd == "whitelist" or cmd == "blacklist" ) and #argv > 0 + cmd == "whitelist" or cmd == "blacklist" or cmd == "status" ) and #argv > 0 then lock() @@ -59,6 +59,11 @@ function main(argv) elseif whitelist_macs[mac] then add_whitelist_rule(mac) end + elseif mac and cmd == "status" then + print(leased_macs[mac] and "lease" + or whitelist_macs[mac] and "whitelist" + or blacklist_macs[mac] and "blacklist" + or "new") elseif mac and ( cmd == "whitelist" or cmd == "blacklist" or cmd == "lease" ) then if cmd ~= "lease" and leased_macs[mac] then print("Removing %s from leases" % mac) diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-statistics/luasrc/statistics/rrdtool.lua index 911b38bff..eb5c266b0 100644 --- a/applications/luci-statistics/luasrc/statistics/rrdtool.lua +++ b/applications/luci-statistics/luasrc/statistics/rrdtool.lua @@ -22,7 +22,8 @@ require("luci.statistics.i18n") require("luci.model.uci") require("luci.util") require("luci.sys") -require("luci.fs") + +local fs = require "nixio.fs" Graph = luci.util.class() @@ -96,7 +97,7 @@ function Graph._rrdtool( self, def, rrd ) -- prepare directory local dir = def[1]:gsub("/[^/]+$","") - luci.fs.mkdir( dir, true ) + fs.mkdirr( dir ) -- construct commandline local cmdline = "rrdtool graph" @@ -500,7 +501,7 @@ function Graph.render( self, plugin, plugin_instance ) -- check for a whole graph handler local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin - local stat, def = luci.util.copcall( require, plugin_def ) + local stat, def = pcall( require, plugin_def ) if stat and def and type(def.rrdargs) == "function" then @@ -539,7 +540,7 @@ function Graph.render( self, plugin, plugin_instance ) -- check for data type handler local dtype_def = plugin_def .. "." .. dtype - local stat, def = luci.util.copcall( require, dtype_def ) + local stat, def = pcall( require, dtype_def ) if stat and def and type(def.rrdargs) == "function" then diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua index 7e0b60534..883261351 100644 --- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua @@ -16,7 +16,6 @@ $Id$ module("luci.statistics.rrdtool.definitions", package.seeall) require("luci.util") -require("luci.fs") Instance = luci.util.class() diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm index 54ba2b0e2..13e52257e 100644 --- a/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm +++ b/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm @@ -22,7 +22,7 @@ about open tcp connections, interface traffic, iptables rules etc.%>

<%:stat_networkplugins_installed Installed network plugins:%>