summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r--modules/luci-base/luasrc/cacheloader.lua12
-rw-r--r--modules/luci-base/luasrc/ccache.lua76
-rw-r--r--modules/luci-base/luasrc/config.lua18
-rw-r--r--modules/luci-base/luasrc/controller/admin/index.lua199
-rw-r--r--modules/luci-base/luasrc/controller/admin/uci.lua70
-rw-r--r--modules/luci-base/luasrc/dispatcher.lua1564
-rw-r--r--modules/luci-base/luasrc/dispatcher.luadoc220
-rw-r--r--modules/luci-base/luasrc/i18n.lua55
-rw-r--r--modules/luci-base/luasrc/i18n.luadoc42
-rw-r--r--modules/luci-base/luasrc/model/uci.lua508
-rw-r--r--modules/luci-base/luasrc/model/uci.luadoc369
-rw-r--r--modules/luci-base/luasrc/sgi/cgi.lua73
-rw-r--r--modules/luci-base/luasrc/sgi/uhttpd.lua99
-rw-r--r--modules/luci-base/luasrc/store.lua6
-rw-r--r--modules/luci-base/luasrc/sys.lua615
-rw-r--r--modules/luci-base/luasrc/sys.luadoc392
-rw-r--r--modules/luci-base/luasrc/sys/zoneinfo.lua19
-rw-r--r--modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua457
-rw-r--r--modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua46
-rw-r--r--modules/luci-base/luasrc/template.lua100
-rw-r--r--modules/luci-base/luasrc/version.lua9
-rw-r--r--modules/luci-base/luasrc/view/csrftoken.htm24
-rw-r--r--modules/luci-base/luasrc/view/empty_node_placeholder.htm11
-rw-r--r--modules/luci-base/luasrc/view/error404.htm12
-rw-r--r--modules/luci-base/luasrc/view/error500.htm11
-rw-r--r--modules/luci-base/luasrc/view/footer.htm27
-rw-r--r--modules/luci-base/luasrc/view/header.htm38
-rw-r--r--modules/luci-base/luasrc/view/indexer.htm7
-rw-r--r--modules/luci-base/luasrc/view/sysauth.htm75
-rw-r--r--modules/luci-base/luasrc/view/view.htm12
-rw-r--r--modules/luci-base/luasrc/xml.lua26
-rw-r--r--modules/luci-base/luasrc/xml.luadoc23
32 files changed, 0 insertions, 5215 deletions
diff --git a/modules/luci-base/luasrc/cacheloader.lua b/modules/luci-base/luasrc/cacheloader.lua
deleted file mode 100644
index 7ef971df8d..0000000000
--- a/modules/luci-base/luasrc/cacheloader.lua
+++ /dev/null
@@ -1,12 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-local config = require "luci.config"
-local ccache = require "luci.ccache"
-
-module "luci.cacheloader"
-
-if config.ccache and config.ccache.enable == "1" then
- ccache.cache_ondemand()
-end
diff --git a/modules/luci-base/luasrc/ccache.lua b/modules/luci-base/luasrc/ccache.lua
deleted file mode 100644
index d3be7cba6c..0000000000
--- a/modules/luci-base/luasrc/ccache.lua
+++ /dev/null
@@ -1,76 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-local io = require "io"
-local fs = require "nixio.fs"
-local util = require "luci.util"
-local nixio = require "nixio"
-local debug = require "debug"
-local string = require "string"
-local package = require "package"
-
-local type, loadfile = type, loadfile
-
-
-module "luci.ccache"
-
-function cache_ondemand(...)
- if debug.getinfo(1, 'S').source ~= "=?" then
- cache_enable(...)
- end
-end
-
-function cache_enable(cachepath, mode)
- cachepath = cachepath or "/tmp/luci-modulecache"
- mode = mode or "r--r--r--"
-
- local loader = package.loaders[2]
- local uid = nixio.getuid()
-
- if not fs.stat(cachepath) then
- fs.mkdir(cachepath)
- end
-
- local function _encode_filename(name)
- local encoded = ""
- for i=1, #name do
- encoded = encoded .. ("%2X" % string.byte(name, i))
- end
- return encoded
- end
-
- local function _load_sane(file)
- local stat = fs.stat(file)
- if stat and stat.uid == uid and stat.modestr == mode then
- return loadfile(file)
- end
- end
-
- local function _write_sane(file, func)
- if nixio.getuid() == uid then
- local fp = io.open(file, "w")
- if fp then
- fp:write(util.get_bytecode(func))
- fp:close()
- fs.chmod(file, mode)
- end
- end
- end
-
- package.loaders[2] = function(mod)
- local encoded = cachepath .. "/" .. _encode_filename(mod)
- local modcons = _load_sane(encoded)
-
- if modcons then
- return modcons
- end
-
- -- No cachefile
- modcons = loader(mod)
- if type(modcons) == "function" then
- _write_sane(encoded, modcons)
- end
- return modcons
- end
-end
diff --git a/modules/luci-base/luasrc/config.lua b/modules/luci-base/luasrc/config.lua
deleted file mode 100644
index d01153f4f5..0000000000
--- a/modules/luci-base/luasrc/config.lua
+++ /dev/null
@@ -1,18 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local util = require "luci.util"
-module("luci.config",
- function(m)
- if pcall(require, "luci.model.uci") then
- local config = util.threadlocal()
- setmetatable(m, {
- __index = function(tbl, key)
- if not config[key] then
- config[key] = luci.model.uci.cursor():get_all("luci", key)
- end
- return config[key]
- end
- })
- end
- end)
diff --git a/modules/luci-base/luasrc/controller/admin/index.lua b/modules/luci-base/luasrc/controller/admin/index.lua
deleted file mode 100644
index 8f9b481cce..0000000000
--- a/modules/luci-base/luasrc/controller/admin/index.lua
+++ /dev/null
@@ -1,199 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-module("luci.controller.admin.index", package.seeall)
-
-function action_logout()
- local dsp = require "luci.dispatcher"
- local utl = require "luci.util"
- local sid = dsp.context.authsession
-
- if sid then
- utl.ubus("session", "destroy", { ubus_rpc_session = sid })
-
- local url = dsp.build_url()
-
- if luci.http.getenv('HTTPS') == 'on' then
- luci.http.header("Set-Cookie", "sysauth_https=; expires=Thu, 01 Jan 1970 01:00:00 GMT; path=%s" % url)
- end
-
- luci.http.header("Set-Cookie", "sysauth_http=; expires=Thu, 01 Jan 1970 01:00:00 GMT; path=%s" % url)
- end
-
- luci.http.redirect(dsp.build_url())
-end
-
-function action_translations(lang)
- local i18n = require "luci.i18n"
- local http = require "luci.http"
- local fs = require "nixio".fs
-
- if lang and #lang > 0 then
- lang = i18n.setlanguage(lang)
- if lang then
- local s = fs.stat("%s/base.%s.lmo" %{ i18n.i18ndir, lang })
- if s then
- http.header("Cache-Control", "public, max-age=31536000")
- http.header("ETag", "%x-%x-%x" %{ s["ino"], s["size"], s["mtime"] })
- end
- end
- end
-
- http.prepare_content("application/javascript; charset=utf-8")
- http.write("window.TR=")
- http.write_json(i18n.dump())
-end
-
-local function ubus_reply(id, data, code, errmsg)
- local reply = { jsonrpc = "2.0", id = id }
- if errmsg then
- reply.error = {
- code = code,
- message = errmsg
- }
- elseif type(code) == "table" then
- reply.result = code
- else
- reply.result = { code, data }
- end
-
- return reply
-end
-
-local ubus_types = {
- nil,
- "array",
- "object",
- "string",
- nil, -- INT64
- "number",
- nil, -- INT16,
- "boolean",
- "double"
-}
-
-local function ubus_access(sid, obj, fun)
- local res, code = luci.util.ubus("session", "access", {
- ubus_rpc_session = sid,
- scope = "ubus",
- object = obj,
- ["function"] = fun
- })
-
- return (type(res) == "table" and res.access == true)
-end
-
-local function ubus_request(req)
- if type(req) ~= "table" or type(req.method) ~= "string" or req.jsonrpc ~= "2.0" or req.id == nil then
- return ubus_reply(nil, nil, -32600, "Invalid request")
-
- elseif req.method == "call" then
- if type(req.params) ~= "table" or #req.params < 3 then
- return ubus_reply(nil, nil, -32600, "Invalid parameters")
- end
-
- local sid, obj, fun, arg =
- req.params[1], req.params[2], req.params[3], req.params[4] or {}
- if type(arg) ~= "table" or arg.ubus_rpc_session ~= nil then
- return ubus_reply(req.id, nil, -32602, "Invalid parameters")
- end
-
- if sid == "00000000000000000000000000000000" and luci.dispatcher.context.authsession then
- sid = luci.dispatcher.context.authsession
- end
-
- if not ubus_access(sid, obj, fun) then
- return ubus_reply(req.id, nil, -32002, "Access denied")
- end
-
- arg.ubus_rpc_session = sid
-
- local res, code = luci.util.ubus(obj, fun, arg)
- return ubus_reply(req.id, res, code or 0)
-
- elseif req.method == "list" then
- if req.params == nil or (type(req.params) == "table" and #req.params == 0) then
- local objs = luci.util.ubus()
- return ubus_reply(req.id, nil, objs)
-
- elseif type(req.params) == "table" then
- local n, rv = nil, {}
- for n = 1, #req.params do
- if type(req.params[n]) ~= "string" then
- return ubus_reply(req.id, nil, -32602, "Invalid parameters")
- end
-
- local sig = luci.util.ubus(req.params[n])
- if sig and type(sig) == "table" then
- rv[req.params[n]] = {}
-
- local m, p
- for m, p in pairs(sig) do
- if type(p) == "table" then
- rv[req.params[n]][m] = {}
-
- local pn, pt
- for pn, pt in pairs(p) do
- rv[req.params[n]][m][pn] = ubus_types[pt] or "unknown"
- end
- end
- end
- end
- end
- return ubus_reply(req.id, nil, rv)
-
- else
- return ubus_reply(req.id, nil, -32602, "Invalid parameters")
- end
- end
-
- return ubus_reply(req.id, nil, -32601, "Method not found")
-end
-
-function action_ubus()
- local parser = require "luci.jsonc".new()
-
- luci.http.context.request:setfilehandler(function(_, s)
- if not s then
- return nil
- end
-
- local ok, err = parser:parse(s)
- return (not err or nil)
- end)
-
- luci.http.context.request:content()
-
- local json = parser:get()
- if json == nil or type(json) ~= "table" then
- luci.http.prepare_content("application/json")
- luci.http.write_json(ubus_reply(nil, nil, -32700, "Parse error"))
- return
- end
-
- local response
- if #json == 0 then
- response = ubus_request(json)
- else
- response = {}
-
- local _, request
- for _, request in ipairs(json) do
- response[_] = ubus_request(request)
- end
- end
-
- luci.http.prepare_content("application/json")
- luci.http.write_json(response)
-end
-
-function action_menu()
- local dsp = require "luci.dispatcher"
- local http = require "luci.http"
-
- local _, _, acls = dsp.is_authenticated({ methods = { "cookie:sysauth_https", "cookie:sysauth_http" } })
- local menu = dsp.menu_json(acls or {}) or {}
-
- http.prepare_content("application/json")
- http.write_json(menu)
-end
diff --git a/modules/luci-base/luasrc/controller/admin/uci.lua b/modules/luci-base/luasrc/controller/admin/uci.lua
deleted file mode 100644
index 7aad10d58a..0000000000
--- a/modules/luci-base/luasrc/controller/admin/uci.lua
+++ /dev/null
@@ -1,70 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2010-2019 Jo-Philipp Wich <jo@mein.io>
--- Licensed to the public under the Apache License 2.0.
-
-module("luci.controller.admin.uci", package.seeall)
-
-local function ubus_state_to_http(errstr)
- local map = {
- ["Invalid command"] = 400,
- ["Invalid argument"] = 400,
- ["Method not found"] = 404,
- ["Entry not found"] = 404,
- ["No data"] = 204,
- ["Permission denied"] = 403,
- ["Timeout"] = 504,
- ["Not supported"] = 500,
- ["Unknown error"] = 500,
- ["Connection failed"] = 503
- }
-
- local code = map[errstr] or 200
- local msg = errstr or "OK"
-
- luci.http.status(code, msg)
-
- if code ~= 204 then
- luci.http.prepare_content("text/plain")
- luci.http.write(msg)
- end
-end
-
-function action_apply_rollback()
- local uci = require "luci.model.uci"
- local token, errstr = uci:apply(true)
- if token then
- luci.http.prepare_content("application/json")
- luci.http.write_json({ token = token })
- else
- ubus_state_to_http(errstr)
- end
-end
-
-function action_apply_unchecked()
- local uci = require "luci.model.uci"
- local _, errstr = uci:apply(false)
- ubus_state_to_http(errstr)
-end
-
-function action_confirm()
- local uci = require "luci.model.uci"
- local token = luci.http.formvalue("token")
- local _, errstr = uci:confirm(token)
- ubus_state_to_http(errstr)
-end
-
-function action_revert()
- local uci = require "luci.model.uci"
- local changes = uci:changes()
-
- -- Collect files to be reverted
- local _, errstr, r, tbl
- for r, tbl in pairs(changes) do
- _, errstr = uci:revert(r)
- if errstr then
- break
- end
- end
-
- ubus_state_to_http(errstr or "OK")
-end
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
deleted file mode 100644
index a3726fb1c1..0000000000
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ /dev/null
@@ -1,1564 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-local fs = require "nixio.fs"
-local sys = require "luci.sys"
-local util = require "luci.util"
-local xml = require "luci.xml"
-local http = require "luci.http"
-local nixio = require "nixio", require "nixio.util"
-
-module("luci.dispatcher", package.seeall)
-context = util.threadlocal()
-uci = require "luci.model.uci"
-i18n = require "luci.i18n"
-_M.fs = fs
-
--- Index table
-local index = nil
-
-local function check_fs_depends(spec)
- local fs = require "nixio.fs"
-
- for path, kind in pairs(spec) do
- if kind == "directory" then
- local empty = true
- for entry in (fs.dir(path) or function() end) do
- empty = false
- break
- end
- if empty then
- return false
- end
- elseif kind == "executable" then
- if fs.stat(path, "type") ~= "reg" or not fs.access(path, "x") then
- return false
- end
- elseif kind == "file" then
- if fs.stat(path, "type") ~= "reg" then
- return false
- end
- elseif kind == "absent" then
- if fs.stat(path, "type") then
- return false
- end
- end
- end
-
- return true
-end
-
-local function check_uci_depends_options(conf, s, opts)
- local uci = require "luci.model.uci"
-
- if type(opts) == "string" then
- return (s[".type"] == opts)
- elseif opts == true then
- for option, value in pairs(s) do
- if option:byte(1) ~= 46 then
- return true
- end
- end
- elseif type(opts) == "table" then
- for option, value in pairs(opts) do
- local sval = s[option]
- if type(sval) == "table" then
- local found = false
- for _, v in ipairs(sval) do
- if v == value then
- found = true
- break
- end
- end
- if not found then
- return false
- end
- elseif value == true then
- if sval == nil then
- return false
- end
- else
- if sval ~= value then
- return false
- end
- end
- end
- end
-
- return true
-end
-
-local function check_uci_depends_section(conf, sect)
- local uci = require "luci.model.uci"
-
- for section, options in pairs(sect) do
- local stype = section:match("^@([A-Za-z0-9_%-]+)$")
- if stype then
- local found = false
- uci:foreach(conf, stype, function(s)
- if check_uci_depends_options(conf, s, options) then
- found = true
- return false
- end
- end)
- if not found then
- return false
- end
- else
- local s = uci:get_all(conf, section)
- if not s or not check_uci_depends_options(conf, s, options) then
- return false
- end
- end
- end
-
- return true
-end
-
-local function check_uci_depends(conf)
- local uci = require "luci.model.uci"
-
- for config, values in pairs(conf) do
- if values == true then
- local found = false
- uci:foreach(config, nil, function(s)
- found = true
- return false
- end)
- if not found then
- return false
- end
- elseif type(values) == "table" then
- if not check_uci_depends_section(config, values) then
- return false
- end
- end
- end
-
- return true
-end
-
-local function check_acl_depends(require_groups, groups)
- if type(require_groups) == "table" and #require_groups > 0 then
- local writable = false
-
- for _, group in ipairs(require_groups) do
- local read = false
- local write = false
- if type(groups) == "table" and type(groups[group]) == "table" then
- for _, perm in ipairs(groups[group]) do
- if perm == "read" then
- read = true
- elseif perm == "write" then
- write = true
- end
- end
- end
- if not read and not write then
- return nil
- elseif write then
- writable = true
- end
- end
-
- return writable
- end
-
- return true
-end
-
-local function check_depends(spec)
- if type(spec.depends) ~= "table" then
- return true
- end
-
- if type(spec.depends.fs) == "table" then
- local satisfied = false
- local alternatives = (#spec.depends.fs > 0) and spec.depends.fs or { spec.depends.fs }
- for _, alternative in ipairs(alternatives) do
- if check_fs_depends(alternative) then
- satisfied = true
- break
- end
- end
- if not satisfied then
- return false
- end
- end
-
- if type(spec.depends.uci) == "table" then
- local satisfied = false
- local alternatives = (#spec.depends.uci > 0) and spec.depends.uci or { spec.depends.uci }
- for _, alternative in ipairs(alternatives) do
- if check_uci_depends(alternative) then
- satisfied = true
- break
- end
- end
- if not satisfied then
- return false
- end
- end
-
- return true
-end
-
-local function target_to_json(target, module)
- local action
-
- if target.type == "call" then
- action = {
- ["type"] = "call",
- ["module"] = module,
- ["function"] = target.name,
- ["parameters"] = target.argv
- }
- elseif target.type == "view" then
- action = {
- ["type"] = "view",
- ["path"] = target.view
- }
- elseif target.type == "template" then
- action = {
- ["type"] = "template",
- ["path"] = target.view
- }
- elseif target.type == "cbi" then
- action = {
- ["type"] = "cbi",
- ["path"] = target.model,
- ["config"] = target.config
- }
- elseif target.type == "form" then
- action = {
- ["type"] = "form",
- ["path"] = target.model
- }
- elseif target.type == "firstchild" then
- action = {
- ["type"] = "firstchild"
- }
- elseif target.type == "firstnode" then
- action = {
- ["type"] = "firstchild",
- ["recurse"] = true
- }
- elseif target.type == "arcombine" then
- if type(target.targets) == "table" then
- action = {
- ["type"] = "arcombine",
- ["targets"] = {
- target_to_json(target.targets[1], module),
- target_to_json(target.targets[2], module)
- }
- }
- end
- elseif target.type == "alias" then
- action = {
- ["type"] = "alias",
- ["path"] = table.concat(target.req, "/")
- }
- elseif target.type == "rewrite" then
- action = {
- ["type"] = "rewrite",
- ["path"] = table.concat(target.req, "/"),
- ["remove"] = target.n
- }
- end
-
- if target.post and action then
- action.post = target.post
- end
-
- return action
-end
-
-local function tree_to_json(node, json)
- local fs = require "nixio.fs"
- local util = require "luci.util"
-
- if type(node.nodes) == "table" then
- for subname, subnode in pairs(node.nodes) do
- local spec = {
- title = xml.striptags(subnode.title),
- order = subnode.order
- }
-
- if subnode.leaf then
- spec.wildcard = true
- end
-
- if subnode.cors then
- spec.cors = true
- end
-
- if subnode.setuser then
- spec.setuser = subnode.setuser
- end
-
- if subnode.setgroup then
- spec.setgroup = subnode.setgroup
- end
-
- if type(subnode.target) == "table" then
- spec.action = target_to_json(subnode.target, subnode.module)
- end
-
- if type(subnode.file_depends) == "table" then
- for _, v in ipairs(subnode.file_depends) do
- spec.depends = spec.depends or {}
- spec.depends.fs = spec.depends.fs or {}
-
- local ft = fs.stat(v, "type")
- if ft == "dir" then
- spec.depends.fs[v] = "directory"
- elseif v:match("/s?bin/") then
- spec.depends.fs[v] = "executable"
- else
- spec.depends.fs[v] = "file"
- end
- end
- end
-
- if type(subnode.uci_depends) == "table" then
- for k, v in pairs(subnode.uci_depends) do
- spec.depends = spec.depends or {}
- spec.depends.uci = spec.depends.uci or {}
- spec.depends.uci[k] = v
- end
- end
-
- if type(subnode.acl_depends) == "table" then
- for _, acl in ipairs(subnode.acl_depends) do
- spec.depends = spec.depends or {}
- spec.depends.acl = spec.depends.acl or {}
- spec.depends.acl[#spec.depends.acl + 1] = acl
- end
- end
-
- if (subnode.sysauth_authenticator ~= nil) or
- (subnode.sysauth ~= nil and subnode.sysauth ~= false)
- then
- if subnode.sysauth_authenticator == "htmlauth" then
- spec.auth = {
- login = true,
- methods = { "cookie:sysauth_https", "cookie:sysauth_http" }
- }
- elseif subname == "rpc" and subnode.module == "luci.controller.rpc" then
- spec.auth = {
- login = false,
- methods = { "query:auth", "cookie:sysauth_https", "cookie:sysauth_http" }
- }
- elseif subnode.module == "luci.controller.admin.uci" then
- spec.auth = {
- login = false,
- methods = { "param:sid" }
- }
- end
- elseif subnode.sysauth == false then
- spec.auth = {}
- end
-
- if not spec.action then
- spec.title = nil
- end
-
- spec.satisfied = check_depends(spec)
- json.children = json.children or {}
- json.children[subname] = tree_to_json(subnode, spec)
- end
- end
-
- return json
-end
-
-function build_url(...)
- local path = {...}
- local url = { http.getenv("SCRIPT_NAME") or "" }
-
- local p
- for _, p in ipairs(path) do
- if p:match("^[a-zA-Z0-9_%-%.%%/,;]+$") then
- url[#url+1] = "/"
- url[#url+1] = p
- end
- end
-
- if #path == 0 then
- url[#url+1] = "/"
- end
-
- return table.concat(url, "")
-end
-
-
-function error404(message)
- http.status(404, "Not Found")
- message = message or "Not Found"
-
- local function render()
- local template = require "luci.template"
- template.render("error404", {message=message})
- end
-
- if not util.copcall(render) then
- http.prepare_content("text/plain")
- http.write(message)
- end
-
- return false
-end
-
-function error500(message)
- util.perror(message)
- if not context.template_header_sent then
- http.status(500, "Internal Server Error")
- http.prepare_content("text/plain")
- http.write(message)
- else
- require("luci.template")
- if not util.copcall(luci.template.render, "error500", {message=message}) then
- http.prepare_content("text/plain")
- http.write(message)
- end
- end
- return false
-end
-
-local function determine_request_language()
- local conf = require "luci.config"
- assert(conf.main, "/etc/config/luci seems to be corrupt, unable to find section 'main'")
-
- local lang = conf.main.lang or "auto"
- if lang == "auto" then
- local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or ""
- for aclang in aclang:gmatch("[%w_-]+") do
- local country, culture = aclang:match("^([a-z][a-z])[_-]([a-zA-Z][a-zA-Z])$")
- if country and culture then
- local cc = "%s_%s" %{ country, culture:lower() }
- if conf.languages[cc] then
- lang = cc
- break
- elseif conf.languages[country] then
- lang = country
- break
- end
- elseif conf.languages[aclang] then
- lang = aclang
- break
- end
- end
- end
-
- if lang == "auto" then
- lang = i18n.default
- end
-
- i18n.setlanguage(lang)
-end
-
-function httpdispatch(request, prefix)
- http.context.request = request
-
- local r = {}
- context.request = r
-
- local pathinfo = http.urldecode(request:getenv("PATH_INFO") or "", true)
-
- if prefix then
- for _, node in ipairs(prefix) do
- r[#r+1] = node
- end
- end
-
- local node
- for node in pathinfo:gmatch("[^/%z]+") do
- r[#r+1] = node
- end
-
- determine_request_language()
-
- local stat, err = util.coxpcall(function()
- dispatch(context.request)
- end, error500)
-
- http.close()
-
- --context._disable_memtrace()
-end
-
-local function require_post_security(target, args)
- if type(target) == "table" and target.type == "arcombine" and type(target.targets) == "table" then
- return require_post_security((type(args) == "table" and #args > 0) and target.targets[2] or target.targets[1], args)
- end
-
- if type(target) == "table" then
- if type(target.post) == "table" then
- local param_name, required_val, request_val
-
- for param_name, required_val in pairs(target.post) do
- request_val = http.formvalue(param_name)
-
- if (type(required_val) == "string" and
- request_val ~= required_val) or
- (required_val == true and request_val == nil)
- then
- return false
- end
- end
-
- return true
- end
-
- return (target.post == true)
- end
-
- return false
-end
-
-function test_post_security()
- if http.getenv("REQUEST_METHOD") ~= "POST" then
- http.status(405, "Method Not Allowed")
- http.header("Allow", "POST")
- return false
- end
-
- if http.formvalue("token") ~= context.authtoken then
- http.status(403, "Forbidden")
- luci.template.render("csrftoken")
- return false
- end
-
- return true
-end
-
-local function session_retrieve(sid, allowed_users)
- local sdat = util.ubus("session", "get", { ubus_rpc_session = sid })
- local sacl = util.ubus("session", "access", { ubus_rpc_session = sid })
-
- if type(sdat) == "table" and
- type(sdat.values) == "table" and
- type(sdat.values.token) == "string" and
- (not allowed_users or
- util.contains(allowed_users, sdat.values.username))
- then
- uci:set_session_id(sid)
- return sid, sdat.values, type(sacl) == "table" and sacl or {}
- end
-
- return nil, nil, nil
-end
-
-local function session_setup(user, pass)
- local login = util.ubus("session", "login", {
- username = user,
- password = pass,
- timeout = tonumber(luci.config.sauth.sessiontime)
- })
-
- local rp = context.requestpath
- and table.concat(context.requestpath, "/") or ""
-
- if type(login) == "table" and
- type(login.ubus_rpc_session) == "string"
- then
- util.ubus("session", "set", {
- ubus_rpc_session = login.ubus_rpc_session,
- values = { token = sys.uniqueid(16) }
- })
- nixio.syslog("info", tostring("luci: accepted login on /%s for %s from %s\n"
- %{ rp, user or "?", http.getenv("REMOTE_ADDR") or "?" }))
-
- return session_retrieve(login.ubus_rpc_session)
- end
- nixio.syslog("info", tostring("luci: failed login on /%s for %s from %s\n"
- %{ rp, user or "?", http.getenv("REMOTE_ADDR") or "?" }))
-end
-
-local function check_authentication(method)
- local auth_type, auth_param = method:match("^(%w+):(.+)$")
- local sid, sdat
-
- if auth_type == "cookie" then
- sid = http.getcookie(auth_param)
- elseif auth_type == "param" then
- sid = http.formvalue(auth_param)
- elseif auth_type == "query" then
- sid = http.formvalue(auth_param, true)
- end
-
- return session_retrieve(sid)
-end
-
-local function merge_trees(node_a, node_b)
- for k, v in pairs(node_b) do
- if k == "children" then
- node_a.children = node_a.children or {}
-
- for name, spec in pairs(v) do
- node_a.children[name] = merge_trees(node_a.children[name] or {}, spec)
- end
- else
- node_a[k] = v
- end
- end
-
- if type(node_a.action) == "table" and
- node_a.action.type == "firstchild" and
- node_a.children == nil
- then
- node_a.satisfied = false
- end
-
- return node_a
-end
-
-local function apply_tree_acls(node, acl)
- if type(node.children) == "table" then
- for _, child in pairs(node.children) do
- apply_tree_acls(child, acl)
- end
- end
-
- local perm
- if type(node.depends) == "table" then
- perm = check_acl_depends(node.depends.acl, acl["access-group"])
- else
- perm = true
- end
-
- if perm == nil then
- node.satisfied = false
- elseif perm == false then
- node.readonly = true
- end
-end
-
-function menu_json(acl)
- local tree = context.tree or createtree()
- local lua_tree = tree_to_json(tree, {
- action = {
- ["type"] = "firstchild",
- ["recurse"] = true
- }
- })
-
- local json_tree = createtree_json()
- local menu_tree = merge_trees(lua_tree, json_tree)
-
- if acl then
- apply_tree_acls(menu_tree, acl)
- end
-
- return menu_tree
-end
-
-local function init_template_engine(ctx)
- local tpl = require "luci.template"
- local media = luci.config.main.mediaurlbase
-
- 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,
- "themes/%s/header" % fs.basename(theme)) then
- media = theme
- end
- end
- assert(media, "No valid theme found")
- end
-
- local function _ifattr(cond, key, val, noescape)
- if cond then
- local env = getfenv(3)
- local scope = (type(env.self) == "table") and env.self
- if type(val) == "table" then
- if not next(val) then
- return ''
- else
- val = util.serialize_json(val)
- end
- end
-
- val = tostring(val or
- (type(env[key]) ~= "function" and env[key]) or
- (scope and type(scope[key]) ~= "function" and scope[key]) or "")
-
- if noescape ~= true then
- val = xml.pcdata(val)
- end
-
- return string.format(' %s="%s"', tostring(key), val)
- else
- return ''
- end
- end
-
- tpl.context.viewns = setmetatable({
- write = http.write;
- include = function(name) tpl.Template(name):render(getfenv(2)) end;
- translate = i18n.translate;
- translatef = i18n.translatef;
- export = function(k, v) if tpl.context.viewns[k] == nil then tpl.context.viewns[k] = v end end;
- striptags = xml.striptags;
- pcdata = xml.pcdata;
- media = media;
- theme = fs.basename(media);
- resource = luci.config.main.resourcebase;
- ifattr = function(...) return _ifattr(...) end;
- attr = function(...) return _ifattr(true, ...) end;
- url = build_url;
- }, {__index=function(tbl, key)
- if key == "controller" then
- return build_url()
- elseif key == "REQUEST_URI" then
- return build_url(unpack(ctx.requestpath))
- elseif key == "FULL_REQUEST_URI" then
- local url = { http.getenv("SCRIPT_NAME") or "", http.getenv("PATH_INFO") }
- local query = http.getenv("QUERY_STRING")
- if query and #query > 0 then
- url[#url+1] = "?"
- url[#url+1] = query
- end
- return table.concat(url, "")
- elseif key == "token" then
- return ctx.authtoken
- else
- return rawget(tbl, key) or _G[key]
- end
- end})
-
- return tpl
-end
-
-function is_authenticated(auth)
- if type(auth) == "table" and type(auth.methods) == "table" and #auth.methods > 0 then
- local sid, sdat, sacl
- for _, method in ipairs(auth.methods) do
- sid, sdat, sacl = check_authentication(method)
-
- if sid and sdat and sacl then
- return sid, sdat, sacl
- end
- end
- end
-end
-
-local function ctx_append(ctx, name, node)
- ctx.path = ctx.path or {}
- ctx.path[#ctx.path + 1] = name
-
- ctx.acls = ctx.acls or {}
-
- local acls = (type(node.depends) == "table" and type(node.depends.acl) == "table") and node.depends.acl or {}
- for _, acl in ipairs(acls) do
- ctx.acls[_] = acl
- end
-
- ctx.auth = node.auth or ctx.auth
- ctx.cors = node.cors or ctx.cors
- ctx.suid = node.setuser or ctx.suid
- ctx.sgid = node.setgroup or ctx.sgid
-
- return ctx
-end
-
-local function node_weight(node)
- local weight = node.order or 9999
-
- if weight > 9999 then
- weight = 9999
- end
-
- if type(node.auth) == "table" and node.auth.login then
- weight = weight + 10000
- end
-
- return weight
-end
-
-local function resolve_firstchild(node, sacl, login_allowed, ctx)
- local candidate = nil
- local candidate_ctx = nil
-
- for name, child in pairs(node.children) do
- if child.satisfied then
- if not sacl then
- local _
- _, _, sacl = is_authenticated(node.auth)
- end
-
- local cacl = (type(child.depends) == "table") and child.depends.acl or nil
- local login = login_allowed or (type(child.auth) == "table" and child.auth.login)
- if login or check_acl_depends(cacl, sacl and sacl["access-group"]) ~= nil then
- if child.title and type(child.action) == "table" then
- local child_ctx = ctx_append(util.clone(ctx, true), name, child)
- if child.action.type == "firstchild" then
- if not candidate or node_weight(candidate) > node_weight(child) then
- local have_grandchild = resolve_firstchild(child, sacl, login, child_ctx)
- if have_grandchild then
- candidate = child
- candidate_ctx = child_ctx
- end
- end
- elseif not child.firstchild_ineligible then
- if not candidate or node_weight(candidate) > node_weight(child) then
- candidate = child
- candidate_ctx = child_ctx
- end
- end
- end
- end
- end
- end
-
- if candidate then
- for k, v in pairs(candidate_ctx) do
- ctx[k] = v
- end
-
- return true
- end
-
- return false
-end
-
-local function resolve_page(tree, request_path)
- local node = tree
- local sacl = nil
- local login = false
- local ctx = {}
-
- for i, s in ipairs(request_path) do
- node = node.children and node.children[s]
-
- if not node or not node.satisfied then
- break
- end
-
- ctx_append(ctx, s, node)
-
- if not sacl then
- local _
- _, _, sacl = is_authenticated(node.auth)
- end
-
- if not login and type(node.auth) == "table" and node.auth.login then
- login = true
- end
-
- if node.wildcard then
- ctx.request_args = {}
- ctx.request_path = util.clone(ctx.path, true)
-
- for j = i + 1, #request_path do
- ctx.request_path[j] = request_path[j]
- ctx.request_args[j - i] = request_path[j]
- end
-
- break
- end
- end
-
- if node and type(node.action) == "table" and node.action.type == "firstchild" then
- resolve_firstchild(node, sacl, login, ctx)
- end
-
- ctx.acls = ctx.acls or {}
- ctx.path = ctx.path or {}
- ctx.request_args = ctx.request_args or {}
- ctx.request_path = ctx.request_path or util.clone(request_path, true)
-
- node = tree
-
- for _, s in ipairs(ctx.path or {}) do
- node = node.children[s]
- assert(node, "Internal node resolve error")
- end
-
- return node, ctx
-end
-
-function dispatch(request)
- --context._disable_memtrace = require "luci.debug".trap_memtrace("l")
- local ctx = context
-
- local auth, cors, suid, sgid
- local menu = menu_json()
- local page, lookup_ctx = resolve_page(menu, request)
- local action = (page and type(page.action) == "table") and page.action or {}
-
- local tpl = init_template_engine(ctx)
-
- ctx.args = lookup_ctx.request_args
- ctx.path = lookup_ctx.path
- ctx.dispatched = page
-
- ctx.requestpath = ctx.requestpath or lookup_ctx.request_path
- ctx.requestargs = ctx.requestargs or lookup_ctx.request_args
- ctx.requested = ctx.requested or page
-
- if type(lookup_ctx.auth) == "table" and next(lookup_ctx.auth) then
- local sid, sdat, sacl = is_authenticated(lookup_ctx.auth)
-
- if not (sid and sdat and sacl) and lookup_ctx.auth.login then
- local user = http.getenv("HTTP_AUTH_USER")
- local pass = http.getenv("HTTP_AUTH_PASS")
-
- if user == nil and pass == nil then
- user = http.formvalue("luci_username")
- pass = http.formvalue("luci_password")
- end
-
- if user and pass then
- sid, sdat, sacl = session_setup(user, pass)
- end
-
- if not sid then
- context.path = {}
-
- http.status(403, "Forbidden")
- http.header("X-LuCI-Login-Required", "yes")
-
- local scope = { duser = "root", fuser = user }
- local ok, res = util.copcall(tpl.render_string, [[<% include("themes/" .. theme .. "/sysauth") %>]], scope)
- if ok then
- return res
- end
- return tpl.render("sysauth", scope)
- end
-
- http.header("Set-Cookie", 'sysauth_%s=%s; path=%s; SameSite=Strict; HttpOnly%s' %{
- http.getenv("HTTPS") == "on" and "https" or "http",
- sid, build_url(), http.getenv("HTTPS") == "on" and "; secure" or ""
- })
-
- http.redirect(build_url(unpack(ctx.requestpath)))
- return
- end
-
- if not sid or not sdat or not sacl then
- http.status(403, "Forbidden")
- http.header("X-LuCI-Login-Required", "yes")
- return
- end
-
- ctx.authsession = sid
- ctx.authtoken = sdat.token
- ctx.authuser = sdat.username
- ctx.authacl = sacl
- end
-
- if #lookup_ctx.acls > 0 then
- local perm = check_acl_depends(lookup_ctx.acls, ctx.authacl and ctx.authacl["access-group"])
- if perm == nil then
- http.status(403, "Forbidden")
- return
- end
-
- if page then
- page.readonly = not perm
- end
- end
-
- if action.type == "arcombine" then
- action = (#lookup_ctx.request_args > 0) and action.targets[2] or action.targets[1]
- end
-
- if lookup_ctx.cors and http.getenv("REQUEST_METHOD") == "OPTIONS" then
- luci.http.status(200, "OK")
- luci.http.header("Access-Control-Allow-Origin", http.getenv("HTTP_ORIGIN") or "*")
- luci.http.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
- return
- end
-
- if require_post_security(action) then
- if not test_post_security() then
- return
- end
- end
-
- if lookup_ctx.sgid then
- sys.process.setgroup(lookup_ctx.sgid)
- end
-
- if lookup_ctx.suid then
- sys.process.setuser(lookup_ctx.suid)
- end
-
- if action.type == "view" then
- tpl.render("view", { view = action.path })
-
- elseif action.type == "call" then
- local ok, mod = util.copcall(require, action.module)
- if not ok then
- error500(mod)
- return
- end
-
- local func = mod[action["function"]]
-
- assert(func ~= nil,
- 'Cannot resolve function "' .. action["function"] .. '". Is it misspelled or local?')
-
- assert(type(func) == "function",
- 'The symbol "' .. action["function"] .. '" does not refer to a function but data ' ..
- 'of type "' .. type(func) .. '".')
-
- local argv = (type(action.parameters) == "table" and #action.parameters > 0) and { unpack(action.parameters) } or {}
- for _, s in ipairs(lookup_ctx.request_args) do
- argv[#argv + 1] = s
- end
-
- local ok, err = util.copcall(func, unpack(argv))
- if not ok then
- error500(err)
- end
-
- --elseif action.type == "firstchild" then
- -- tpl.render("empty_node_placeholder", getfenv(1))
-
- elseif action.type == "alias" then
- local sub_request = {}
- for name in action.path:gmatch("[^/]+") do
- sub_request[#sub_request + 1] = name
- end
-
- for _, s in ipairs(lookup_ctx.request_args) do
- sub_request[#sub_request + 1] = s
- end
-
- dispatch(sub_request)
-
- elseif action.type == "rewrite" then
- local sub_request = { unpack(request) }
- for i = 1, action.remove do
- table.remove(sub_request, 1)
- end
-
- local n = 1
- for s in action.path:gmatch("[^/]+") do
- table.insert(sub_request, n, s)
- n = n + 1
- end
-
- for _, s in ipairs(lookup_ctx.request_args) do
- sub_request[#sub_request + 1] = s
- end
-
- dispatch(sub_request)
-
- elseif action.type == "template" then
- tpl.render(action.path, getfenv(1))
-
- elseif action.type == "cbi" then
- _cbi({ config = action.config, model = action.path }, unpack(lookup_ctx.request_args))
-
- elseif action.type == "form" then
- _form({ model = action.path }, unpack(lookup_ctx.request_args))
-
- else
- if not menu.children then
- error404("No root node was registered, this usually happens if no module was installed.\n" ..
- "Install luci-mod-admin-full and retry. " ..
- "If the module is already installed, try removing the /tmp/luci-indexcache file.")
- else
- error404("No page is registered at '/" .. table.concat(lookup_ctx.request_path, "/") .. "'.\n" ..
- "If this url belongs to an extension, make sure it is properly installed.\n" ..
- "If the extension was recently installed, try removing the /tmp/luci-indexcache file.")
- end
- end
-end
-
-local function hash_filelist(files)
- local fprint = {}
- local n = 0
-
- for i, file in ipairs(files) do
- local st = fs.stat(file)
- if st then
- fprint[n + 1] = '%x' % st.ino
- fprint[n + 2] = '%x' % st.mtime
- fprint[n + 3] = '%x' % st.size
- n = n + 3
- end
- end
-
- return nixio.crypt(table.concat(fprint, "|"), "$1$"):sub(5):gsub("/", ".")
-end
-
-local function read_cachefile(file, reader)
- local euid = sys.process.info("uid")
- local fuid = fs.stat(file, "uid")
- local mode = fs.stat(file, "modestr")
-
- if euid ~= fuid or mode ~= "rw-------" then
- return nil
- end
-
- return reader(file)
-end
-
-function createindex()
- local controllers = { }
- local base = "%s/controller/" % util.libpath()
- local _, path
-
- for path in (fs.glob("%s*.lua" % base) or function() end) do
- controllers[#controllers+1] = path
- end
-
- for path in (fs.glob("%s*/*.lua" % base) or function() end) do
- controllers[#controllers+1] = path
- end
-
- local cachefile
-
- if indexcache then
- cachefile = "%s.%s.lua" %{ indexcache, hash_filelist(controllers) }
-
- local res = read_cachefile(cachefile, function(path) return loadfile(path)() end)
- if res then
- index = res
- return res
- end
-
- for file in (fs.glob("%s.*.lua" % indexcache) or function() end) do
- fs.unlink(file)
- end
- end
-
- index = {}
-
- for _, path in ipairs(controllers) do
- local modname = "luci.controller." .. path:sub(#base+1, #path-4):gsub("/", ".")
- local mod = require(modname)
- assert(mod ~= true,
- "Invalid controller file found\n" ..
- "The file '" .. path .. "' contains an invalid module line.\n" ..
- "Please verify whether the module name is set to '" .. modname ..
- "' - It must correspond to the file path!")
-
- local idx = mod.index
- if type(idx) == "function" then
- index[modname] = idx
- end
- end
-
- if cachefile then
- local f = nixio.open(cachefile, "w", 600)
- f:writeall(util.get_bytecode(index))
- f:close()
- end
-end
-
-function createtree_json()
- local json = require "luci.jsonc"
- local tree = {}
-
- local schema = {
- action = "table",
- auth = "table",
- cors = "boolean",
- depends = "table",
- order = "number",
- setgroup = "string",
- setuser = "string",
- title = "string",
- wildcard = "boolean",
- firstchild_ineligible = "boolean"
- }
-
- local files = {}
- local cachefile
-
- for file in (fs.glob("/usr/share/luci/menu.d/*.json") or function() end) do
- files[#files+1] = file
- end
-
- if indexcache then
- cachefile = "%s.%s.json" %{ indexcache, hash_filelist(files) }
-
- local res = read_cachefile(cachefile, function(path) return json.parse(fs.readfile(path) or "") end)
- if res then
- return res
- end
-
- for file in (fs.glob("%s.*.json" % indexcache) or function() end) do
- fs.unlink(file)
- end
- end
-
- for _, file in ipairs(files) do
- local data = json.parse(fs.readfile(file) or "")
- if type(data) == "table" then
- for path, spec in pairs(data) do
- if type(spec) == "table" then
- local node = tree
-
- for s in path:gmatch("[^/]+") do
- if s == "*" then
- node.wildcard = true
- break
- end
-
- node.children = node.children or {}
- node.children[s] = node.children[s] or {}
- node = node.children[s]
- end
-
- if node ~= tree then
- for k, t in pairs(schema) do
- if type(spec[k]) == t then
- node[k] = spec[k]
- end
- end
-
- node.satisfied = check_depends(spec)
- end
- end
- end
- end
- end
-
- if cachefile then
- local f = nixio.open(cachefile, "w", 600)
- f:writeall(json.stringify(tree))
- f:close()
- end
-
- return tree
-end
-
--- Build the index before if it does not exist yet.
-function createtree()
- if not index then
- createindex()
- end
-
- local ctx = context
- local tree = {nodes={}, inreq=true}
-
- ctx.treecache = setmetatable({}, {__mode="v"})
- ctx.tree = tree
-
- local scope = setmetatable({}, {__index = luci.dispatcher})
-
- for k, v in pairs(index) do
- scope._NAME = k
- setfenv(v, scope)
- v()
- end
-
- return tree
-end
-
-function assign(path, clone, title, order)
- local obj = node(unpack(path))
- obj.nodes = nil
- obj.module = nil
-
- obj.title = title
- obj.order = order
-
- setmetatable(obj, {__index = _create_node(clone)})
-
- return obj
-end
-
-function entry(path, target, title, order)
- local c = node(unpack(path))
-
- c.target = target
- c.title = title
- c.order = order
- c.module = getfenv(2)._NAME
-
- return c
-end
-
--- enabling the node.
-function get(...)
- return _create_node({...})
-end
-
-function node(...)
- local c = _create_node({...})
-
- c.module = getfenv(2)._NAME
- c.auto = nil
-
- return c
-end
-
-function lookup(...)
- local i, path = nil, {}
- for i = 1, select('#', ...) do
- local name, arg = nil, tostring(select(i, ...))
- for name in arg:gmatch("[^/]+") do
- path[#path+1] = name
- end
- end
-
- for i = #path, 1, -1 do
- local node = context.treecache[table.concat(path, ".", 1, i)]
- if node and (i == #path or node.leaf) then
- return node, build_url(unpack(path))
- end
- end
-end
-
-function _create_node(path)
- if #path == 0 then
- return context.tree
- end
-
- local name = table.concat(path, ".")
- local c = context.treecache[name]
-
- if not c then
- local last = table.remove(path)
- local parent = _create_node(path)
-
- c = {nodes={}, auto=true, inreq=true}
-
- parent.nodes[last] = c
- context.treecache[name] = c
- end
-
- return c
-end
-
--- Subdispatchers --
-
-function firstchild()
- return { type = "firstchild" }
-end
-
-function firstnode()
- return { type = "firstnode" }
-end
-
-function alias(...)
- return { type = "alias", req = { ... } }
-end
-
-function rewrite(n, ...)
- return { type = "rewrite", n = n, req = { ... } }
-end
-
-function call(name, ...)
- return { type = "call", argv = {...}, name = name }
-end
-
-function post_on(params, name, ...)
- return {
- type = "call",
- post = params,
- argv = { ... },
- name = name
- }
-end
-
-function post(...)
- return post_on(true, ...)
-end
-
-
-function template(name)
- return { type = "template", view = name }
-end
-
-function view(name)
- return { type = "view", view = name }
-end
-
-
-function _cbi(self, ...)
- local cbi = require "luci.cbi"
- local tpl = require "luci.template"
- local http = require "luci.http"
- local util = require "luci.util"
-
- local config = self.config or {}
- local maps = cbi.load(self.model, ...)
-
- local state = nil
-
- local function has_uci_access(config, level)
- local rv = util.ubus("session", "access", {
- ubus_rpc_session = context.authsession,
- scope = "uci", object = config,
- ["function"] = level
- })
-
- return (type(rv) == "table" and rv.access == true) or false
- end
-
- local i, res
- for i, res in ipairs(maps) do
- if util.instanceof(res, cbi.SimpleForm) then
- io.stderr:write("Model %s returns SimpleForm but is dispatched via cbi(),\n"
- % self.model)
-
- io.stderr:write("please change %s to use the form() action instead.\n"
- % table.concat(context.request, "/"))
- end
-
- res.flow = config
- local cstate = res:parse()
- if cstate and (not state or cstate < state) then
- state = cstate
- end
- end
-
- local function _resolve_path(path)
- return type(path) == "table" and build_url(unpack(path)) or path
- end
-
- if config.on_valid_to and state and state > 0 and state < 2 then
- http.redirect(_resolve_path(config.on_valid_to))
- return
- end
-
- if config.on_changed_to and state and state > 1 then
- http.redirect(_resolve_path(config.on_changed_to))
- return
- end
-
- if config.on_success_to and state and state > 0 then
- http.redirect(_resolve_path(config.on_success_to))
- return
- end
-
- if config.state_handler then
- if not config.state_handler(state, maps) then
- return
- end
- end
-
- http.header("X-CBI-State", state or 0)
-
- if not config.noheader then
- tpl.render("cbi/header", {state = state})
- end
-
- local redirect
- local messages
- local applymap = false
- local pageaction = true
- local parsechain = { }
- local writable = false
-
- for i, res in ipairs(maps) do
- if res.apply_needed and res.parsechain then
- local c
- for _, c in ipairs(res.parsechain) do
- parsechain[#parsechain+1] = c
- end
- applymap = true
- end
-
- if res.redirect then
- redirect = redirect or res.redirect
- end
-
- if res.pageaction == false then
- pageaction = false
- end
-
- if res.message then
- messages = messages or { }
- messages[#messages+1] = res.message
- end
- end
-
- for i, res in ipairs(maps) do
- local is_readable_map = has_uci_access(res.config, "read")
- local is_writable_map = has_uci_access(res.config, "write")
-
- writable = writable or is_writable_map
-
- res:render({
- firstmap = (i == 1),
- redirect = redirect,
- messages = messages,
- pageaction = pageaction,
- parsechain = parsechain,
- readable = is_readable_map,
- writable = is_writable_map
- })
- end
-
- if not config.nofooter then
- tpl.render("cbi/footer", {
- flow = config,
- pageaction = pageaction,
- redirect = redirect,
- state = state,
- autoapply = config.autoapply,
- trigger_apply = applymap,
- writable = writable
- })
- end
-end
-
-function cbi(model, config)
- return {
- type = "cbi",
- post = { ["cbi.submit"] = true },
- config = config,
- model = model
- }
-end
-
-
-function arcombine(trg1, trg2)
- return {
- type = "arcombine",
- env = getfenv(),
- targets = {trg1, trg2}
- }
-end
-
-
-function _form(self, ...)
- local cbi = require "luci.cbi"
- local tpl = require "luci.template"
- local http = require "luci.http"
-
- local maps = luci.cbi.load(self.model, ...)
- local state = nil
-
- local i, res
- for i, res in ipairs(maps) do
- local cstate = res:parse()
- if cstate and (not state or cstate < state) then
- state = cstate
- end
- end
-
- http.header("X-CBI-State", state or 0)
- tpl.render("header")
- for i, res in ipairs(maps) do
- res:render()
- end
- tpl.render("footer")
-end
-
-function form(model)
- return {
- type = "form",
- post = { ["cbi.submit"] = true },
- model = model
- }
-end
-
-translate = i18n.translate
-
--- This function does not actually translate the given argument but
--- is used by build/i18n-scan.pl to find translatable entries.
-function _(text)
- return text
-end
diff --git a/modules/luci-base/luasrc/dispatcher.luadoc b/modules/luci-base/luasrc/dispatcher.luadoc
deleted file mode 100644
index a77f8d8b07..0000000000
--- a/modules/luci-base/luasrc/dispatcher.luadoc
+++ /dev/null
@@ -1,220 +0,0 @@
----[[
-LuCI web dispatcher.
-]]
-module "luci.dispatcher"
-
----[[
-Build the URL relative to the server webroot from given virtual path.
-
-@class function
-@name build_url
-@param ... Virtual path
-@return Relative URL
-]]
-
----[[
-Check whether a dispatch node shall be visible
-
-@class function
-@name node_visible
-@param node Dispatch node
-@return Boolean indicating whether the node should be visible
-]]
-
----[[
-Return a sorted table of visible children within a given node
-
-@class function
-@name node_childs
-@param node Dispatch node
-@return Ordered table of child node names
-]]
-
----[[
-Send a 404 error code and render the "error404" template if available.
-
-@class function
-@name error404
-@param message Custom error message (optional)
-@return false
-]]
-
----[[
-Send a 500 error code and render the "error500" template if available.
-
-@class function
-@name error500
-@param message Custom error message (optional)#
-@return false
-]]
-
----[[
-Dispatch an HTTP request.
-
-@class function
-@name httpdispatch
-@param request LuCI HTTP Request object
-]]
-
----[[
-Dispatches a LuCI virtual path.
-
-@class function
-@name dispatch
-@param request Virtual path
-]]
-
----[[
-Generate the dispatching index using the native file-cache based strategy.
-
-
-@class function
-@name createindex
-]]
-
----[[
-Create the dispatching tree from the index.
-
-Build the index before if it does not exist yet.
-
-@class function
-@name createtree
-]]
-
----[[
-Clone a node of the dispatching tree to another position.
-
-@class function
-@name assign
-@param path Virtual path destination
-@param clone Virtual path source
-@param title Destination node title (optional)
-@param order Destination node order value (optional)
-@return Dispatching tree node
-]]
-
----[[
-Create a new dispatching node and define common parameters.
-
-@class function
-@name entry
-@param path Virtual path
-@param target Target function to call when dispatched.
-@param title Destination node title
-@param order Destination node order value (optional)
-@return Dispatching tree node
-]]
-
----[[
-Fetch or create a dispatching node without setting the target module or
-enabling the node.
-
-@class function
-@name get
-@param ... Virtual path
-@return Dispatching tree node
-]]
-
----[[
-Fetch or create a new dispatching node.
-
-@class function
-@name node
-@param ... Virtual path
-@return Dispatching tree node
-]]
-
----[[
-Lookup node in dispatching tree.
-
-@class function
-@name lookup
-@param ... Virtual path
-@return Node object, canonical url or nil if the path was not found.
-]]
-
----[[
-Alias the first (lowest order) page automatically
-
-
-@class function
-@name firstchild
-]]
-
----[[
-Create a redirect to another dispatching node.
-
-@class function
-@name alias
-@param ... Virtual path destination
-]]
-
----[[
-Rewrite the first x path values of the request.
-
-@class function
-@name rewrite
-@param n Number of path values to replace
-@param ... Virtual path to replace removed path values with
-]]
-
----[[
-Create a function-call dispatching target.
-
-@class function
-@name call
-@param name Target function of local controller
-@param ... Additional parameters passed to the function
-]]
-
----[[
-Create a template render dispatching target.
-
-@class function
-@name template
-@param name Template to be rendered
-]]
-
----[[
-Create a CBI model dispatching target.
-
-@class function
-@name cbi
-@param model CBI model to be rendered
-]]
-
----[[
-Create a combined dispatching target for non argv and argv requests.
-
-@class function
-@name arcombine
-@param trg1 Overview Target
-@param trg2 Detail Target
-]]
-
----[[
-Create a CBI form model dispatching target.
-
-@class function
-@name form
-@param model CBI form model tpo be rendered
-]]
-
----[[
-Access the luci.i18n translate() api.
-
-@class function
-@name translate
-@param text Text to translate
-]]
-
----[[
-No-op function used to mark translation entries for menu labels.
-
-This function does not actually translate the given argument but
-is used by build/i18n-scan.pl to find translatable entries.
-
-@class function
-@name _
-]]
-
diff --git a/modules/luci-base/luasrc/i18n.lua b/modules/luci-base/luasrc/i18n.lua
deleted file mode 100644
index 323912b650..0000000000
--- a/modules/luci-base/luasrc/i18n.lua
+++ /dev/null
@@ -1,55 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local tparser = require "luci.template.parser"
-local util = require "luci.util"
-local tostring = tostring
-
-module "luci.i18n"
-
-i18ndir = util.libpath() .. "/i18n/"
-context = util.threadlocal()
-default = "en"
-
-
-function setlanguage(lang)
- local code, subcode = lang:match("^([A-Za-z][A-Za-z])[%-_]([A-Za-z][A-Za-z])$")
- if not (code and subcode) then
- subcode = lang:match("^([A-Za-z][A-Za-z])$")
- if not subcode then
- return nil
- end
- end
-
- context.parent = code and code:lower()
- context.lang = context.parent and context.parent.."-"..subcode:lower() or subcode:lower()
-
- if tparser.load_catalog(context.lang, i18ndir) and
- tparser.change_catalog(context.lang)
- then
- return context.lang
-
- elseif context.parent then
- if tparser.load_catalog(context.parent, i18ndir) and
- tparser.change_catalog(context.parent)
- then
- return context.parent
- end
- end
-
- return nil
-end
-
-function translate(key)
- return tparser.translate(key) or key
-end
-
-function translatef(key, ...)
- return tostring(translate(key)):format(...)
-end
-
-function dump()
- local rv = {}
- tparser.get_translations(function(k, v) rv[k] = v end)
- return rv
-end
diff --git a/modules/luci-base/luasrc/i18n.luadoc b/modules/luci-base/luasrc/i18n.luadoc
deleted file mode 100644
index b76c298565..0000000000
--- a/modules/luci-base/luasrc/i18n.luadoc
+++ /dev/null
@@ -1,42 +0,0 @@
----[[
-LuCI translation library.
-]]
-module "luci.i18n"
-
----[[
-Set the context default translation language.
-
-@class function
-@name setlanguage
-@param lang An IETF/BCP 47 language tag or ISO3166 country code, e.g. "en-US" or "de"
-@return The effective loaded language, e.g. "en" for "en-US" - or nil on failure
-]]
-
----[[
-Return the translated value for a specific translation key.
-
-@class function
-@name translate
-@param key Default translation text
-@return Translated string
-]]
-
----[[
-Return the translated value for a specific translation key and use it as sprintf pattern.
-
-@class function
-@name translatef
-@param key Default translation text
-@param ... Format parameters
-@return Translated and formatted string
-]]
-
----[[
-Return all currently loaded translation strings as a key-value table. The key is the
-hexadecimal representation of the translation key while the value is the translated
-text content.
-
-@class function
-@name dump
-@return Key-value translation string table.
-]]
diff --git a/modules/luci-base/luasrc/model/uci.lua b/modules/luci-base/luasrc/model/uci.lua
deleted file mode 100644
index 816f6f2053..0000000000
--- a/modules/luci-base/luasrc/model/uci.lua
+++ /dev/null
@@ -1,508 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local os = require "os"
-local util = require "luci.util"
-local table = require "table"
-
-
-local setmetatable, rawget, rawset = setmetatable, rawget, rawset
-local require, getmetatable, assert = require, getmetatable, assert
-local error, pairs, ipairs, select = error, pairs, ipairs, select
-local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack
-
--- The typical workflow for UCI is: Get a cursor instance from the
--- cursor factory, modify data (via Cursor.add, Cursor.delete, etc.),
--- save the changes to the staging area via Cursor.save and finally
--- Cursor.commit the data to the actual config files.
--- LuCI then needs to Cursor.apply the changes so daemons etc. are
--- reloaded.
-module "luci.model.uci"
-
-local ERRSTR = {
- "Invalid command",
- "Invalid argument",
- "Method not found",
- "Entry not found",
- "No data",
- "Permission denied",
- "Timeout",
- "Not supported",
- "Unknown error",
- "Connection failed"
-}
-
-local session_id = nil
-
-local function call(cmd, args)
- if type(args) == "table" and session_id then
- args.ubus_rpc_session = session_id
- end
- return util.ubus("uci", cmd, args)
-end
-
-
-function cursor()
- return _M
-end
-
-function cursor_state()
- return _M
-end
-
-function substate(self)
- return self
-end
-
-
-function get_confdir(self)
- return "/etc/config"
-end
-
-function get_savedir(self)
- return "/tmp/.uci"
-end
-
-function get_session_id(self)
- return session_id
-end
-
-function set_confdir(self, directory)
- return false
-end
-
-function set_savedir(self, directory)
- return false
-end
-
-function set_session_id(self, id)
- session_id = id
- return true
-end
-
-
-function load(self, config)
- return true
-end
-
-function save(self, config)
- return true
-end
-
-function unload(self, config)
- return true
-end
-
-
-function changes(self, config)
- local rv, err = call("changes", { config = config })
-
- if type(rv) == "table" and type(rv.changes) == "table" then
- return rv.changes
- elseif err then
- return nil, ERRSTR[err]
- else
- return { }
- end
-end
-
-
-function revert(self, config)
- local _, err = call("revert", { config = config })
- return (err == nil), ERRSTR[err]
-end
-
-function commit(self, config)
- local _, err = call("commit", { config = config })
- return (err == nil), ERRSTR[err]
-end
-
-function apply(self, rollback)
- local _, err
-
- if rollback then
- local sys = require "luci.sys"
- local conf = require "luci.config"
- local timeout = tonumber(conf and conf.apply and conf.apply.rollback or 90) or 0
-
- _, err = call("apply", {
- timeout = (timeout > 90) and timeout or 90,
- rollback = true
- })
-
- if not err then
- local now = os.time()
- local token = sys.uniqueid(16)
-
- util.ubus("session", "set", {
- ubus_rpc_session = "00000000000000000000000000000000",
- values = {
- rollback = {
- token = token,
- session = session_id,
- timeout = now + timeout
- }
- }
- })
-
- return token
- end
- else
- _, err = call("changes", {})
-
- if not err then
- if type(_) == "table" and type(_.changes) == "table" then
- local k, v
- for k, v in pairs(_.changes) do
- _, err = call("commit", { config = k })
- if err then
- break
- end
- end
- end
- end
-
- if not err then
- _, err = call("apply", { rollback = false })
- end
- end
-
- return (err == nil), ERRSTR[err]
-end
-
-function confirm(self, token)
- local is_pending, time_remaining, rollback_sid, rollback_token = self:rollback_pending()
-
- if is_pending then
- if token ~= rollback_token then
- return false, "Permission denied"
- end
-
- local _, err = util.ubus("uci", "confirm", {
- ubus_rpc_session = rollback_sid
- })
-
- if not err then
- util.ubus("session", "set", {
- ubus_rpc_session = "00000000000000000000000000000000",
- values = { rollback = {} }
- })
- end
-
- return (err == nil), ERRSTR[err]
- end
-
- return false, "No data"
-end
-
-function rollback(self)
- local is_pending, time_remaining, rollback_sid = self:rollback_pending()
-
- if is_pending then
- local _, err = util.ubus("uci", "rollback", {
- ubus_rpc_session = rollback_sid
- })
-
- if not err then
- util.ubus("session", "set", {
- ubus_rpc_session = "00000000000000000000000000000000",
- values = { rollback = {} }
- })
- end
-
- return (err == nil), ERRSTR[err]
- end
-
- return false, "No data"
-end
-
-function rollback_pending(self)
- local rv, err = util.ubus("session", "get", {
- ubus_rpc_session = "00000000000000000000000000000000",
- keys = { "rollback" }
- })
-
- local now = os.time()
-
- if type(rv) == "table" and
- type(rv.values) == "table" and
- type(rv.values.rollback) == "table" and
- type(rv.values.rollback.token) == "string" and
- type(rv.values.rollback.session) == "string" and
- type(rv.values.rollback.timeout) == "number" and
- rv.values.rollback.timeout > now
- then
- return true,
- rv.values.rollback.timeout - now,
- rv.values.rollback.session,
- rv.values.rollback.token
- end
-
- return false, ERRSTR[err]
-end
-
-
-function foreach(self, config, stype, callback)
- if type(callback) == "function" then
- local rv, err = call("get", {
- config = config,
- type = stype
- })
-
- if type(rv) == "table" and type(rv.values) == "table" then
- local sections = { }
- local res = false
- local index = 1
-
- local _, section
- for _, section in pairs(rv.values) do
- section[".index"] = section[".index"] or index
- sections[index] = section
- index = index + 1
- end
-
- table.sort(sections, function(a, b)
- return a[".index"] < b[".index"]
- end)
-
- for _, section in ipairs(sections) do
- local continue = callback(section)
- res = true
- if continue == false then
- break
- end
- end
- return res
- else
- return false, ERRSTR[err] or "No data"
- end
- else
- return false, "Invalid argument"
- end
-end
-
-local function _get(self, operation, config, section, option)
- if section == nil then
- return nil
- elseif type(option) == "string" and option:byte(1) ~= 46 then
- local rv, err = call(operation, {
- config = config,
- section = section,
- option = option
- })
-
- if type(rv) == "table" then
- return rv.value or nil
- elseif err then
- return false, ERRSTR[err]
- else
- return nil
- end
- elseif option == nil then
- local values = self:get_all(config, section)
- if values then
- return values[".type"], values[".name"]
- else
- return nil
- end
- else
- return false, "Invalid argument"
- end
-end
-
-function get(self, ...)
- return _get(self, "get", ...)
-end
-
-function get_state(self, ...)
- return _get(self, "state", ...)
-end
-
-function get_all(self, config, section)
- local rv, err = call("get", {
- config = config,
- section = section
- })
-
- if type(rv) == "table" and type(rv.values) == "table" then
- return rv.values
- elseif err then
- return false, ERRSTR[err]
- else
- return nil
- end
-end
-
-function get_bool(self, ...)
- local val = self:get(...)
- return (val == "1" or val == "true" or val == "yes" or val == "on")
-end
-
-function get_first(self, config, stype, option, default)
- local rv = default
-
- self:foreach(config, stype, function(s)
- local val = not option and s[".name"] or s[option]
-
- if type(default) == "number" then
- val = tonumber(val)
- elseif type(default) == "boolean" then
- val = (val == "1" or val == "true" or
- val == "yes" or val == "on")
- end
-
- if val ~= nil then
- rv = val
- return false
- end
- end)
-
- return rv
-end
-
-function get_list(self, config, section, option)
- if config and section and option then
- local val = self:get(config, section, option)
- return (type(val) == "table" and val or { val })
- end
- return { }
-end
-
-
-function section(self, config, stype, name, values)
- local rv, err = call("add", {
- config = config,
- type = stype,
- name = name,
- values = values
- })
-
- if type(rv) == "table" then
- return rv.section
- elseif err then
- return false, ERRSTR[err]
- else
- return nil
- end
-end
-
-
-function add(self, config, stype)
- return self:section(config, stype)
-end
-
-function set(self, config, section, option, ...)
- if select('#', ...) == 0 then
- local sname, err = self:section(config, option, section)
- return (not not sname), err
- else
- local _, err = call("set", {
- config = config,
- section = section,
- values = { [option] = select(1, ...) }
- })
- return (err == nil), ERRSTR[err]
- end
-end
-
-function set_list(self, config, section, option, value)
- if section == nil or option == nil then
- return false
- elseif value == nil or (type(value) == "table" and #value == 0) then
- return self:delete(config, section, option)
- elseif type(value) == "table" then
- return self:set(config, section, option, value)
- else
- return self:set(config, section, option, { value })
- end
-end
-
-function tset(self, config, section, values)
- local _, err = call("set", {
- config = config,
- section = section,
- values = values
- })
- return (err == nil), ERRSTR[err]
-end
-
-function reorder(self, config, section, index)
- local sections
-
- if type(section) == "string" and type(index) == "number" then
- local pos = 0
-
- sections = { }
-
- self:foreach(config, nil, function(s)
- if pos == index then
- pos = pos + 1
- end
-
- if s[".name"] ~= section then
- pos = pos + 1
- sections[pos] = s[".name"]
- else
- sections[index + 1] = section
- end
- end)
- elseif type(section) == "table" then
- sections = section
- else
- return false, "Invalid argument"
- end
-
- local _, err = call("order", {
- config = config,
- sections = sections
- })
-
- return (err == nil), ERRSTR[err]
-end
-
-
-function delete(self, config, section, option)
- local _, err = call("delete", {
- config = config,
- section = section,
- option = option
- })
- return (err == nil), ERRSTR[err]
-end
-
-function delete_all(self, config, stype, comparator)
- local _, err
- if type(comparator) == "table" then
- _, err = call("delete", {
- config = config,
- type = stype,
- match = comparator
- })
- elseif type(comparator) == "function" then
- local rv = call("get", {
- config = config,
- type = stype
- })
-
- if type(rv) == "table" and type(rv.values) == "table" then
- local sname, section
- for sname, section in pairs(rv.values) do
- if comparator(section) then
- _, err = call("delete", {
- config = config,
- section = sname
- })
- end
- end
- end
- elseif comparator == nil then
- _, err = call("delete", {
- config = config,
- type = stype
- })
- else
- return false, "Invalid argument"
- end
-
- return (err == nil), ERRSTR[err]
-end
diff --git a/modules/luci-base/luasrc/model/uci.luadoc b/modules/luci-base/luasrc/model/uci.luadoc
deleted file mode 100644
index 0189d49aa1..0000000000
--- a/modules/luci-base/luasrc/model/uci.luadoc
+++ /dev/null
@@ -1,369 +0,0 @@
----[[
-LuCI UCI model library.
-
-The typical workflow for UCI is: Get a cursor instance from the
-cursor factory, modify data (via Cursor.add, Cursor.delete, etc.),
-save the changes to the staging area via Cursor.save and finally
-Cursor.commit the data to the actual config files.
-LuCI then needs to Cursor.apply the changes so daemons etc. are
-reloaded.
-@cstyle instance
-]]
-module "luci.model.uci"
-
----[[
-Create a new UCI-Cursor.
-
-@class function
-@name cursor
-@return UCI-Cursor
-]]
-
----[[
-Create a new Cursor initialized to the state directory.
-
-@class function
-@name cursor_state
-@return UCI cursor
-]]
-
----[[
-Applies UCI configuration changes.
-
-If the rollback parameter is set to true, the apply function will invoke the
-rollback mechanism which causes the configuration to be automatically reverted
-if no confirm() call occurs within a certain timeout.
-
-The current default timeout is 30s and can be increased using the
-"luci.apply.timeout" uci configuration key.
-
-@class function
-@name Cursor.apply
-@param rollback Enable rollback mechanism
-@return Boolean whether operation succeeded
-]]
-
----[[
-Confirms UCI apply process.
-
-If a previous UCI apply with rollback has been invoked using apply(true),
-this function confirms the process and cancels the pending rollback timer.
-
-If no apply with rollback session is active, the function has no effect and
-returns with a "No data" error.
-
-@class function
-@name Cursor.confirm
-@return Boolean whether operation succeeded
-]]
-
----[[
-Cancels UCI apply process.
-
-If a previous UCI apply with rollback has been invoked using apply(true),
-this function cancels the process and rolls back the configuration to the
-pre-apply state.
-
-If no apply with rollback session is active, the function has no effect and
-returns with a "No data" error.
-
-@class function
-@name Cursor.rollback
-@return Boolean whether operation succeeded
-]]
-
----[[
-Checks whether a pending rollback is scheduled.
-
-If a previous UCI apply with rollback has been invoked using apply(true),
-and has not been confirmed or rolled back yet, this function returns true
-and the remaining time until rollback in seconds. If no rollback is pending,
-the function returns false. On error, the function returns false and an
-additional string describing the error.
-
-@class function
-@name Cursor.rollback_pending
-@return Boolean whether rollback is pending
-@return Remaining time in seconds
-]]
-
----[[
-Delete all sections of a given type that match certain criteria.
-
-@class function
-@name Cursor.delete_all
-@param config UCI config
-@param type UCI section type
-@param comparator Function that will be called for each section and returns
- a boolean whether to delete the current section (optional)
-]]
-
----[[
-Create a new section and initialize it with data.
-
-@class function
-@name Cursor.section
-@param config UCI config
-@param type UCI section type
-@param name UCI section name (optional)
-@param values Table of key - value pairs to initialize the section with
-@return Name of created section
-]]
-
----[[
-Updated the data of a section using data from a table.
-
-@class function
-@name Cursor.tset
-@param config UCI config
-@param section UCI section name (optional)
-@param values Table of key - value pairs to update the section with
-]]
-
----[[
-Get a boolean option and return it's value as true or false.
-
-@class function
-@name Cursor.get_bool
-@param config UCI config
-@param section UCI section name
-@param option UCI option
-@return Boolean
-]]
-
----[[
-Get an option or list and return values as table.
-
-@class function
-@name Cursor.get_list
-@param config UCI config
-@param section UCI section name
-@param option UCI option
-@return table. If the option was not found, you will simply get an empty
- table.
-]]
-
----[[
-Get the given option from the first section with the given type.
-
-@class function
-@name Cursor.get_first
-@param config UCI config
-@param type UCI section type
-@param option UCI option (optional)
-@param default Default value (optional)
-@return UCI value
-]]
-
----[[
-Set given values as list. Setting a list option to an empty list
-has the same effect as deleting the option.
-
-@class function
-@name Cursor.set_list
-@param config UCI config
-@param section UCI section name
-@param option UCI option
-@param value Value or table. Non-table values will be set as single
- item UCI list.
-@return Boolean whether operation succeeded
-]]
-
----[[
-Create a sub-state of this cursor.
-
-The sub-state is tied to the parent cursor, means it the parent unloads or
-loads configs, the sub state will do so as well.
-
-@class function
-@name Cursor.substate
-@return UCI state cursor tied to the parent cursor
-]]
-
----[[
-Add an anonymous section.
-
-@class function
-@name Cursor.add
-@param config UCI config
-@param type UCI section type
-@return Name of created section
-]]
-
----[[
-Get a table of saved but uncommitted changes.
-
-@class function
-@name Cursor.changes
-@param config UCI config
-@return Table of changes
-@see Cursor.save
-]]
-
----[[
-Commit saved changes.
-
-@class function
-@name Cursor.commit
-@param config UCI config
-@return Boolean whether operation succeeded
-@see Cursor.revert
-@see Cursor.save
-]]
-
----[[
-Deletes a section or an option.
-
-@class function
-@name Cursor.delete
-@param config UCI config
-@param section UCI section name
-@param option UCI option (optional)
-@return Boolean whether operation succeeded
-]]
-
----[[
-Call a function for every section of a certain type.
-
-@class function
-@name Cursor.foreach
-@param config UCI config
-@param type UCI section type
-@param callback Function to be called
-@return Boolean whether operation succeeded
-]]
-
----[[
-Get a section type or an option
-
-@class function
-@name Cursor.get
-@param config UCI config
-@param section UCI section name
-@param option UCI option (optional)
-@return UCI value
-]]
-
----[[
-Get all sections of a config or all values of a section.
-
-@class function
-@name Cursor.get_all
-@param config UCI config
-@param section UCI section name (optional)
-@return Table of UCI sections or table of UCI values
-]]
-
----[[
-Manually load a config.
-
-@class function
-@name Cursor.load
-@param config UCI config
-@return Boolean whether operation succeeded
-@see Cursor.save
-@see Cursor.unload
-]]
-
----[[
-Revert saved but uncommitted changes.
-
-@class function
-@name Cursor.revert
-@param config UCI config
-@return Boolean whether operation succeeded
-@see Cursor.commit
-@see Cursor.save
-]]
-
----[[
-Saves changes made to a config to make them committable.
-
-@class function
-@name Cursor.save
-@param config UCI config
-@return Boolean whether operation succeeded
-@see Cursor.load
-@see Cursor.unload
-]]
-
----[[
-Set a value or create a named section.
-
-When invoked with three arguments `config`, `sectionname`, `sectiontype`,
-then a named section of the given type is created.
-
-When invoked with four arguments `config`, `sectionname`, `optionname` and
-`optionvalue` then the value of the specified option is set to the given value.
-
-@class function
-@name Cursor.set
-@param config UCI config
-@param section UCI section name
-@param option UCI option or UCI section type
-@param value UCI value or nothing if you want to create a section
-@return Boolean whether operation succeeded
-]]
-
----[[
-Get the configuration directory.
-
-@class function
-@name Cursor.get_confdir
-@return Configuration directory
-]]
-
----[[
-Get the directory for uncomitted changes.
-
-@class function
-@name Cursor.get_savedir
-@return Save directory
-]]
-
----[[
-Get the effective session ID.
-
-@class function
-@name Cursor.get_session_id
-@return String containing the session ID
-]]
-
----[[
-Set the configuration directory.
-
-@class function
-@name Cursor.set_confdir
-@param directory UCI configuration directory
-@return Boolean whether operation succeeded
-]]
-
----[[
-Set the directory for uncommitted changes.
-
-@class function
-@name Cursor.set_savedir
-@param directory UCI changes directory
-@return Boolean whether operation succeeded
-]]
-
----[[
-Set the effective session ID.
-
-@class function
-@name Cursor.set_session_id
-@param id String containing the session ID to set
-@return Boolean whether operation succeeded
-]]
-
----[[
-Discard changes made to a config.
-
-@class function
-@name Cursor.unload
-@param config UCI config
-@return Boolean whether operation succeeded
-@see Cursor.load
-@see Cursor.save
-]]
-
diff --git a/modules/luci-base/luasrc/sgi/cgi.lua b/modules/luci-base/luasrc/sgi/cgi.lua
deleted file mode 100644
index 400db4710d..0000000000
--- a/modules/luci-base/luasrc/sgi/cgi.lua
+++ /dev/null
@@ -1,73 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-exectime = os.clock()
-module("luci.sgi.cgi", package.seeall)
-local ltn12 = require("luci.ltn12")
-require("nixio.util")
-require("luci.http")
-require("luci.sys")
-require("luci.dispatcher")
-
--- Limited source to avoid endless blocking
-local function limitsource(handle, limit)
- limit = limit or 0
- local BLOCKSIZE = ltn12.BLOCKSIZE
-
- return function()
- if limit < 1 then
- handle:close()
- return nil
- else
- local read = (limit > BLOCKSIZE) and BLOCKSIZE or limit
- limit = limit - read
-
- local chunk = handle:read(read)
- if not chunk then handle:close() end
- return chunk
- end
- end
-end
-
-function run()
- local r = luci.http.Request(
- luci.sys.getenv(),
- limitsource(io.stdin, tonumber(luci.sys.getenv("CONTENT_LENGTH"))),
- ltn12.sink.file(io.stderr)
- )
-
- local x = coroutine.create(luci.dispatcher.httpdispatch)
- local hcache = ""
- local active = true
-
- while coroutine.status(x) ~= "dead" do
- local res, id, data1, data2 = coroutine.resume(x, r)
-
- if not res then
- print("Status: 500 Internal Server Error")
- print("Content-Type: text/plain\n")
- print(id)
- break;
- end
-
- if active then
- if id == 1 then
- io.write("Status: " .. tostring(data1) .. " " .. data2 .. "\r\n")
- elseif id == 2 then
- hcache = hcache .. data1 .. ": " .. data2 .. "\r\n"
- elseif id == 3 then
- io.write(hcache)
- io.write("\r\n")
- elseif id == 4 then
- io.write(tostring(data1 or ""))
- elseif id == 5 then
- io.flush()
- io.close()
- active = false
- elseif id == 6 then
- data1:copyz(nixio.stdout, data2)
- data1:close()
- end
- end
- end
-end
diff --git a/modules/luci-base/luasrc/sgi/uhttpd.lua b/modules/luci-base/luasrc/sgi/uhttpd.lua
deleted file mode 100644
index 4cd3649c62..0000000000
--- a/modules/luci-base/luasrc/sgi/uhttpd.lua
+++ /dev/null
@@ -1,99 +0,0 @@
--- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-require "nixio.util"
-require "luci.http"
-require "luci.sys"
-require "luci.dispatcher"
-require "luci.ltn12"
-
-function handle_request(env)
- exectime = os.clock()
- local renv = {
- CONTENT_LENGTH = env.CONTENT_LENGTH,
- CONTENT_TYPE = env.CONTENT_TYPE,
- REQUEST_METHOD = env.REQUEST_METHOD,
- REQUEST_URI = env.REQUEST_URI,
- PATH_INFO = env.PATH_INFO,
- SCRIPT_NAME = env.SCRIPT_NAME:gsub("/+$", ""),
- SCRIPT_FILENAME = env.SCRIPT_NAME,
- SERVER_PROTOCOL = env.SERVER_PROTOCOL,
- QUERY_STRING = env.QUERY_STRING,
- DOCUMENT_ROOT = env.DOCUMENT_ROOT,
- HTTPS = env.HTTPS,
- REDIRECT_STATUS = env.REDIRECT_STATUS,
- REMOTE_ADDR = env.REMOTE_ADDR,
- REMOTE_NAME = env.REMOTE_NAME,
- REMOTE_PORT = env.REMOTE_PORT,
- REMOTE_USER = env.REMOTE_USER,
- SERVER_ADDR = env.SERVER_ADDR,
- SERVER_NAME = env.SERVER_NAME,
- SERVER_PORT = env.SERVER_PORT
- }
-
- local k, v
- for k, v in pairs(env.headers) do
- k = k:upper():gsub("%-", "_")
- renv["HTTP_" .. k] = v
- end
-
- local len = tonumber(env.CONTENT_LENGTH) or 0
- local function recv()
- if len > 0 then
- local rlen, rbuf = uhttpd.recv(4096)
- if rlen >= 0 then
- len = len - rlen
- return rbuf
- end
- end
- return nil
- end
-
- local send = uhttpd.send
-
- local req = luci.http.Request(
- renv, recv, luci.ltn12.sink.file(io.stderr)
- )
-
-
- local x = coroutine.create(luci.dispatcher.httpdispatch)
- local hcache = { }
- local active = true
-
- while coroutine.status(x) ~= "dead" do
- local res, id, data1, data2 = coroutine.resume(x, req)
-
- if not res then
- send("Status: 500 Internal Server Error\r\n")
- send("Content-Type: text/plain\r\n\r\n")
- send(tostring(id))
- break
- end
-
- if active then
- if id == 1 then
- send("Status: ")
- send(tostring(data1))
- send(" ")
- send(tostring(data2))
- send("\r\n")
- elseif id == 2 then
- hcache[data1] = data2
- elseif id == 3 then
- for k, v in pairs(hcache) do
- send(tostring(k))
- send(": ")
- send(tostring(v))
- send("\r\n")
- end
- send("\r\n")
- elseif id == 4 then
- send(tostring(data1 or ""))
- elseif id == 5 then
- active = false
- elseif id == 6 then
- data1:copyz(nixio.stdout, data2)
- end
- end
- end
-end
diff --git a/modules/luci-base/luasrc/store.lua b/modules/luci-base/luasrc/store.lua
deleted file mode 100644
index a735981137..0000000000
--- a/modules/luci-base/luasrc/store.lua
+++ /dev/null
@@ -1,6 +0,0 @@
--- Copyright 2009 Steven Barth <steven@midlink.org>
--- Copyright 2009 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-local util = require "luci.util"
-module("luci.store", util.threadlocal)
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua
deleted file mode 100644
index e6eb762e48..0000000000
--- a/modules/luci-base/luasrc/sys.lua
+++ /dev/null
@@ -1,615 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local io = require "io"
-local os = require "os"
-local table = require "table"
-local nixio = require "nixio"
-local fs = require "nixio.fs"
-local uci = require "luci.model.uci"
-
-local luci = {}
-luci.util = require "luci.util"
-luci.ip = require "luci.ip"
-
-local tonumber, ipairs, pairs, pcall, type, next, setmetatable, require, select, unpack =
- tonumber, ipairs, pairs, pcall, type, next, setmetatable, require, select, unpack
-
-
-module "luci.sys"
-
-function call(...)
- return os.execute(...) / 256
-end
-
-exec = luci.util.exec
-
--- containing the whole environment is returned otherwise this function returns
--- the corresponding string value for the given name or nil if no such variable
--- exists.
-getenv = nixio.getenv
-
-function hostname(newname)
- if type(newname) == "string" and #newname > 0 then
- fs.writefile( "/proc/sys/kernel/hostname", newname )
- return newname
- else
- return nixio.uname().nodename
- end
-end
-
-function httpget(url, stream, target)
- if not target then
- local source = stream and io.popen or luci.util.exec
- return source("wget -qO- %s" % luci.util.shellquote(url))
- else
- return os.execute("wget -qO %s %s" %
- {luci.util.shellquote(target), luci.util.shellquote(url)})
- end
-end
-
-function reboot()
- return os.execute("reboot >/dev/null 2>&1")
-end
-
-function syslog()
- return luci.util.exec("logread")
-end
-
-function dmesg()
- return luci.util.exec("dmesg")
-end
-
-function uniqueid(bytes)
- local rand = fs.readfile("/dev/urandom", bytes)
- return rand and nixio.bin.hexlify(rand)
-end
-
-function uptime()
- return nixio.sysinfo().uptime
-end
-
-
-net = {}
-
-local function _nethints(what, callback)
- local _, k, e, mac, ip, name, duid, iaid
- local cur = uci.cursor()
- local ifn = { }
- local hosts = { }
- local lookup = { }
-
- local function _add(i, ...)
- local k = select(i, ...)
- if k then
- if not hosts[k] then hosts[k] = { } end
- hosts[k][1] = select(1, ...) or hosts[k][1]
- hosts[k][2] = select(2, ...) or hosts[k][2]
- hosts[k][3] = select(3, ...) or hosts[k][3]
- hosts[k][4] = select(4, ...) or hosts[k][4]
- end
- end
-
- luci.ip.neighbors(nil, function(neigh)
- if neigh.mac and neigh.family == 4 then
- _add(what, neigh.mac:string(), neigh.dest:string(), nil, nil)
- elseif neigh.mac and neigh.family == 6 then
- _add(what, neigh.mac:string(), nil, neigh.dest:string(), nil)
- end
- end)
-
- if fs.access("/etc/ethers") then
- for e in io.lines("/etc/ethers") do
- mac, name = e:match("^([a-fA-F0-9:-]+)%s+(%S+)")
- mac = luci.ip.checkmac(mac)
- if mac and name then
- if luci.ip.checkip4(name) then
- _add(what, mac, name, nil, nil)
- else
- _add(what, mac, nil, nil, name)
- end
- end
- end
- end
-
- cur:foreach("dhcp", "dnsmasq",
- function(s)
- if s.leasefile and fs.access(s.leasefile) then
- for e in io.lines(s.leasefile) do
- mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
- mac = luci.ip.checkmac(mac)
- if mac and ip then
- _add(what, mac, ip, nil, name ~= "*" and name)
- end
- end
- end
- end
- )
-
- cur:foreach("dhcp", "odhcpd",
- function(s)
- if type(s.leasefile) == "string" and fs.access(s.leasefile) then
- for e in io.lines(s.leasefile) do
- duid, iaid, name, _, ip = e:match("^# %S+ (%S+) (%S+) (%S+) (-?%d+) %S+ %S+ ([0-9a-f:.]+)/[0-9]+")
- mac = net.duid_to_mac(duid)
- if mac then
- if ip and iaid == "ipv4" then
- _add(what, mac, ip, nil, name ~= "*" and name)
- elseif ip then
- _add(what, mac, nil, ip, name ~= "*" and name)
- end
- end
- end
- end
- end
- )
-
- cur:foreach("dhcp", "host",
- function(s)
- for mac in luci.util.imatch(s.mac) do
- mac = luci.ip.checkmac(mac)
- if mac then
- _add(what, mac, s.ip, nil, s.name)
- end
- end
- end)
-
- for _, e in ipairs(nixio.getifaddrs()) do
- if e.name ~= "lo" then
- ifn[e.name] = ifn[e.name] or { }
- if e.family == "packet" and e.addr and #e.addr == 17 then
- ifn[e.name][1] = e.addr:upper()
- elseif e.family == "inet" then
- ifn[e.name][2] = e.addr
- elseif e.family == "inet6" then
- ifn[e.name][3] = e.addr
- end
- end
- end
-
- for _, e in pairs(ifn) do
- if e[what] and (e[2] or e[3]) then
- _add(what, e[1], e[2], e[3], e[4])
- end
- end
-
- for _, e in pairs(hosts) do
- lookup[#lookup+1] = (what > 1) and e[what] or (e[2] or e[3])
- end
-
- if #lookup > 0 then
- lookup = luci.util.ubus("network.rrdns", "lookup", {
- addrs = lookup,
- timeout = 250,
- limit = 1000
- }) or { }
- end
-
- for _, e in luci.util.kspairs(hosts) do
- callback(e[1], e[2], e[3], lookup[e[2]] or lookup[e[3]] or e[4])
- end
-end
-
--- Each entry contains the values in the following order:
--- [ "mac", "name" ]
-function net.mac_hints(callback)
- if callback then
- _nethints(1, function(mac, v4, v6, name)
- name = name or v4
- if name and name ~= mac then
- callback(mac, name or v4)
- end
- end)
- else
- local rv = { }
- _nethints(1, function(mac, v4, v6, name)
- name = name or v4
- if name and name ~= mac then
- rv[#rv+1] = { mac, name or v4 }
- end
- end)
- return rv
- end
-end
-
--- Each entry contains the values in the following order:
--- [ "ip", "name" ]
-function net.ipv4_hints(callback)
- if callback then
- _nethints(2, function(mac, v4, v6, name)
- name = name or mac
- if name and name ~= v4 then
- callback(v4, name)
- end
- end)
- else
- local rv = { }
- _nethints(2, function(mac, v4, v6, name)
- name = name or mac
- if name and name ~= v4 then
- rv[#rv+1] = { v4, name }
- end
- end)
- return rv
- end
-end
-
--- Each entry contains the values in the following order:
--- [ "ip", "name" ]
-function net.ipv6_hints(callback)
- if callback then
- _nethints(3, function(mac, v4, v6, name)
- name = name or mac
- if name and name ~= v6 then
- callback(v6, name)
- end
- end)
- else
- local rv = { }
- _nethints(3, function(mac, v4, v6, name)
- name = name or mac
- if name and name ~= v6 then
- rv[#rv+1] = { v6, name }
- end
- end)
- return rv
- end
-end
-
-function net.host_hints(callback)
- if callback then
- _nethints(1, function(mac, v4, v6, name)
- if mac and mac ~= "00:00:00:00:00:00" and (v4 or v6 or name) then
- callback(mac, v4, v6, name)
- end
- end)
- else
- local rv = { }
- _nethints(1, function(mac, v4, v6, name)
- if mac and mac ~= "00:00:00:00:00:00" and (v4 or v6 or name) then
- local e = { }
- if v4 then e.ipv4 = v4 end
- if v6 then e.ipv6 = v6 end
- if name then e.name = name end
- rv[mac] = e
- end
- end)
- return rv
- end
-end
-
-function net.conntrack(callback)
- local ok, nfct = pcall(io.lines, "/proc/net/nf_conntrack")
- if not ok or not nfct then
- return nil
- end
-
- local line, connt = nil, (not callback) and { }
- for line in nfct do
- local fam, l3, l4, rest =
- line:match("^(ipv[46]) +(%d+) +%S+ +(%d+) +(.+)$")
-
- local timeout, tuples = rest:match("^(%d+) +(.+)$")
-
- if not tuples then
- tuples = rest
- end
-
- if fam and l3 and l4 and not tuples:match("^TIME_WAIT ") then
- l4 = nixio.getprotobynumber(l4)
-
- local entry = {
- bytes = 0,
- packets = 0,
- layer3 = fam,
- layer4 = l4 and l4.name or "unknown",
- timeout = tonumber(timeout, 10)
- }
-
- local key, val
- for key, val in tuples:gmatch("(%w+)=(%S+)") do
- if key == "bytes" or key == "packets" then
- entry[key] = entry[key] + tonumber(val, 10)
- elseif key == "src" or key == "dst" then
- if entry[key] == nil then
- entry[key] = luci.ip.new(val):string()
- end
- elseif key == "sport" or key == "dport" then
- if entry[key] == nil then
- entry[key] = val
- end
- elseif val then
- entry[key] = val
- end
- end
-
- if callback then
- callback(entry)
- else
- connt[#connt+1] = entry
- end
- end
- end
-
- return callback and true or connt
-end
-
-function net.devices()
- local devs = {}
- local seen = {}
- for k, v in ipairs(nixio.getifaddrs()) do
- if v.name and not seen[v.name] then
- seen[v.name] = true
- devs[#devs+1] = v.name
- end
- end
- return devs
-end
-
-function net.duid_to_mac(duid)
- local b1, b2, b3, b4, b5, b6
-
- if type(duid) == "string" then
- -- DUID-LLT / Ethernet
- if #duid == 28 then
- b1, b2, b3, b4, b5, b6 = duid:match("^00010001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)%x%x%x%x%x%x%x%x$")
-
- -- DUID-LL / Ethernet
- elseif #duid == 20 then
- b1, b2, b3, b4, b5, b6 = duid:match("^00030001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
-
- -- DUID-LL / Ethernet (Without Header)
- elseif #duid == 12 then
- b1, b2, b3, b4, b5, b6 = duid:match("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
- end
- end
-
- return b1 and luci.ip.checkmac(table.concat({ b1, b2, b3, b4, b5, b6 }, ":"))
-end
-
-process = {}
-
-function process.info(key)
- local s = {uid = nixio.getuid(), gid = nixio.getgid()}
- return not key and s or s[key]
-end
-
-function process.list()
- local data = {}
- local k
- local ps = luci.util.execi("/bin/busybox top -bn1")
-
- if not ps then
- return
- end
-
- for line in ps do
- local pid, ppid, user, stat, vsz, mem, cpu, cmd = line:match(
- "^ *(%d+) +(%d+) +(%S.-%S) +([RSDZTW][<NW ][<N ]) +(%d+m?) +(%d+%%) +(%d+%%) +(.+)"
- )
-
- local idx = tonumber(pid)
- if idx and not cmd:match("top %-bn1") then
- data[idx] = {
- ['PID'] = pid,
- ['PPID'] = ppid,
- ['USER'] = user,
- ['STAT'] = stat,
- ['VSZ'] = vsz,
- ['%MEM'] = mem,
- ['%CPU'] = cpu,
- ['COMMAND'] = cmd
- }
- end
- end
-
- return data
-end
-
-function process.setgroup(gid)
- return nixio.setgid(gid)
-end
-
-function process.setuser(uid)
- return nixio.setuid(uid)
-end
-
-process.signal = nixio.kill
-
-local function xclose(fd)
- if fd and fd:fileno() > 2 then
- fd:close()
- end
-end
-
-function process.exec(command, stdout, stderr, nowait)
- local out_r, out_w, err_r, err_w
- if stdout then out_r, out_w = nixio.pipe() end
- if stderr then err_r, err_w = nixio.pipe() end
-
- local pid = nixio.fork()
- if pid == 0 then
- nixio.chdir("/")
-
- local null = nixio.open("/dev/null", "w+")
- if null then
- nixio.dup(out_w or null, nixio.stdout)
- nixio.dup(err_w or null, nixio.stderr)
- nixio.dup(null, nixio.stdin)
- xclose(out_w)
- xclose(out_r)
- xclose(err_w)
- xclose(err_r)
- xclose(null)
- end
-
- nixio.exec(unpack(command))
- os.exit(-1)
- end
-
- local _, pfds, rv = nil, {}, { code = -1, pid = pid }
-
- xclose(out_w)
- xclose(err_w)
-
- if out_r then
- pfds[#pfds+1] = {
- fd = out_r,
- cb = type(stdout) == "function" and stdout,
- name = "stdout",
- events = nixio.poll_flags("in", "err", "hup")
- }
- end
-
- if err_r then
- pfds[#pfds+1] = {
- fd = err_r,
- cb = type(stderr) == "function" and stderr,
- name = "stderr",
- events = nixio.poll_flags("in", "err", "hup")
- }
- end
-
- while #pfds > 0 do
- local nfds, err = nixio.poll(pfds, -1)
- if not nfds and err ~= nixio.const.EINTR then
- break
- end
-
- local i
- for i = #pfds, 1, -1 do
- local rfd = pfds[i]
- if rfd.revents > 0 then
- local chunk, err = rfd.fd:read(4096)
- if chunk and #chunk > 0 then
- if rfd.cb then
- rfd.cb(chunk)
- else
- rfd.buf = rfd.buf or {}
- rfd.buf[#rfd.buf + 1] = chunk
- end
- else
- table.remove(pfds, i)
- if rfd.buf then
- rv[rfd.name] = table.concat(rfd.buf, "")
- end
- rfd.fd:close()
- end
- end
- end
- end
-
- if not nowait then
- _, _, rv.code = nixio.waitpid(pid)
- end
-
- return rv
-end
-
-
-user = {}
-
--- { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
-user.getuser = nixio.getpw
-
-function user.getpasswd(username)
- 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 then
- return nil, pwe
- else
- return pwh, pwe
- end
-end
-
-function user.checkpasswd(username, pass)
- local pwh, pwe = user.getpasswd(username)
- if pwe then
- return (pwh == nil or nixio.crypt(pass, pwh) == pwh)
- end
- return false
-end
-
-function user.setpasswd(username, password)
- return os.execute("(echo %s; sleep 1; echo %s) | passwd %s >/dev/null 2>&1" %{
- luci.util.shellquote(password),
- luci.util.shellquote(password),
- luci.util.shellquote(username)
- })
-end
-
-
-wifi = {}
-
-function wifi.getiwinfo(ifname)
- local ntm = require "luci.model.network"
-
- ntm.init()
-
- local wnet = ntm:get_wifinet(ifname)
- if wnet and wnet.iwinfo then
- return wnet.iwinfo
- end
-
- local wdev = ntm:get_wifidev(ifname)
- if wdev and wdev.iwinfo then
- return wdev.iwinfo
- end
-
- return { ifname = ifname }
-end
-
-
-init = {}
-init.dir = "/etc/init.d/"
-
-function init.names()
- local names = { }
- for name in fs.glob(init.dir.."*") do
- names[#names+1] = fs.basename(name)
- end
- return names
-end
-
-function init.index(name)
- name = fs.basename(name)
- if fs.access(init.dir..name) then
- return call("env -i sh -c 'source %s%s enabled; exit ${START:-255}' >/dev/null"
- %{ init.dir, name })
- end
-end
-
-local function init_action(action, name)
- name = fs.basename(name)
- if fs.access(init.dir..name) then
- return call("env -i %s%s %s >/dev/null" %{ init.dir, name, action })
- end
-end
-
-function init.enabled(name)
- return (init_action("enabled", name) == 0)
-end
-
-function init.enable(name)
- return (init_action("enable", name) == 0)
-end
-
-function init.disable(name)
- return (init_action("disable", name) == 0)
-end
-
-function init.start(name)
- return (init_action("start", name) == 0)
-end
-
-function init.stop(name)
- return (init_action("stop", name) == 0)
-end
-
-function init.restart(name)
- return (init_action("restart", name) == 0)
-end
-
-function init.reload(name)
- return (init_action("reload", name) == 0)
-end
diff --git a/modules/luci-base/luasrc/sys.luadoc b/modules/luci-base/luasrc/sys.luadoc
deleted file mode 100644
index c1e088eb23..0000000000
--- a/modules/luci-base/luasrc/sys.luadoc
+++ /dev/null
@@ -1,392 +0,0 @@
----[[
-LuCI Linux and POSIX system utilities.
-]]
-module "luci.sys"
-
----[[
-Execute a given shell command and return the error code
-
-@class function
-@name call
-@param ... Command to call
-@return Error code of the command
-]]
-
----[[
-Execute a given shell command and capture its standard output
-
-@class function
-@name exec
-@param command Command to call
-@return String containing the return the output of the command
-]]
-
----[[
-Retrieve information about currently mounted file systems.
-
-@class function
-@name mounts
-@return Table containing mount information
-]]
-
----[[
-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
-exists.
-@class function
-@name getenv
-@param var Name of the environment variable to retrieve (optional)
-@return String containing the value of the specified variable
-@return Table containing all variables if no variable name is given
-]]
-
----[[
-Get or set the current hostname.
-
-@class function
-@name hostname
-@param String containing a new hostname to set (optional)
-@return String containing the system hostname
-]]
-
----[[
-Returns the contents of a documented referred by an URL.
-
-@class function
-@name httpget
-@param url The URL to retrieve
-@param stream Return a stream instead of a buffer
-@param target Directly write to target file name
-@return String containing the contents of given the URL
-]]
-
----[[
-Initiate a system reboot.
-
-@class function
-@name reboot
-@return Return value of os.execute()
-]]
-
----[[
-Retrieves the output of the "logread" command.
-
-@class function
-@name syslog
-@return String containing the current log buffer
-]]
-
----[[
-Retrieves the output of the "dmesg" command.
-
-@class function
-@name dmesg
-@return String containing the current log buffer
-]]
-
----[[
-Generates a random id with specified length.
-
-@class function
-@name uniqueid
-@param bytes Number of bytes for the unique id
-@return String containing hex encoded id
-]]
-
----[[
-Returns the current system uptime stats.
-
-@class function
-@name uptime
-@return String containing total uptime in seconds
-]]
-
----[[
-LuCI system utilities / network related functions.
-
-@class module
-@name luci.sys.net
-]]
-
----[[
-Returns a two-dimensional table of mac address hints.
-
-@class function
-@name net.mac_hints
-@return Table of table containing known hosts from various sources.
- Each entry contains the values in the following order:
- [ "mac", "name" ]
-]]
-
----[[
-Returns a two-dimensional table of IPv4 address hints.
-
-@class function
-@name net.ipv4_hints
-@return Table of table containing known hosts from various sources.
- Each entry contains the values in the following order:
- [ "ip", "name" ]
-]]
-
----[[
-Returns a two-dimensional table of IPv6 address hints.
-
-@class function
-@name net.ipv6_hints
-@return Table of table containing known hosts from various sources.
- Each entry contains the values in the following order:
- [ "ip", "name" ]
-]]
-
----[[
-Returns a two-dimensional table of host hints.
-
-@class function
-@name net.host_hints
-@return Table of table containing known hosts from various sources,
- indexed by mac address. Each subtable contains at least one
- of the fields "name", "ipv4" or "ipv6".
-]]
-
----[[
-Returns conntrack information
-
-@class function
-@name net.conntrack
-@return Table with the currently tracked IP connections
-]]
-
----[[
-Determine the names of available network interfaces.
-
-@class function
-@name net.devices
-@return Table containing all current interface names
-]]
-
----[[
-LuCI system utilities / process related functions.
-
-@class module
-@name luci.sys.process
-]]
-
----[[
-Get the current process id.
-
-@class function
-@name process.info
-@return Number containing the current pid
-]]
-
----[[
-Retrieve information about currently running processes.
-
-@class function
-@name process.list
-@return Table containing process information
-]]
-
----[[
-Set the gid of a process identified by given pid.
-
-@class function
-@name process.setgroup
-@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
-]]
-
----[[
-Set the uid of a process identified by given pid.
-
-@class function
-@name process.setuser
-@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
-]]
-
----[[
-Send a signal to a process identified by given pid.
-
-@class function
-@name process.signal
-@param pid Number containing the process id
-@param sig Signal to send (default: 15 [SIGTERM])
-@return Boolean indicating successful operation
-@return Number containing the error code if failed
-]]
-
----[[
-Execute a process, optionally capturing stdio.
-
-Executes the process specified by the given argv vector, e.g.
-`{ "/bin/sh", "-c", "echo 1" }` and waits for it to terminate unless a true
-value has been passed for the "nowait" parameter.
-
-When a function value is passed for the stdout or stderr arguments, the passed
-function is repeatedly called for each chunk read from the corresponding stdio
-stream. The read data is passed as string containing at most 4096 bytes at a
-time.
-
-When a true, non-function value is passed for the stdout or stderr arguments,
-the data of the corresponding stdio stream is read into an internal string
-buffer and returned as "stdout" or "stderr" field respectively in the result
-table.
-
-When a true value is passed to the nowait parameter, the function does not
-await process termination but returns as soon as all captured stdio streams
-have been closed or - if no streams are captured - immediately after launching
-the process.
-
-@class function
-@name process.exec
-@param commend Table containing the argv vector to execute
-@param stdout Callback function or boolean to indicate capturing (optional)
-@param stderr Callback function or boolean to indicate capturing (optional)
-@param nowait Don't wait for process termination when true (optional)
-@return Table containing at least the fields "code" which holds the exit
- status of the invoked process or "-1" on error and "pid", which
- contains the process id assigned to the spawned process. When
- stdout and/or stderr capturing has been requested, it additionally
- contains "stdout" and "stderr" fields respectively, holding the
- captured stdio data as string.
-]]
-
----[[
-LuCI system utilities / user related functions.
-
-@class module
-@name luci.sys.user
-]]
-
----[[
-Retrieve user information for given uid.
-
-@class function
-@name getuser
-@param uid Number containing the Unix user id
-@return Table containing the following fields:
--- { "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
-]]
-
----[[
-Retrieve the current user password hash.
-
-@class function
-@name user.getpasswd
-@param username String containing the username to retrieve the password for
-@return String containing the hash or nil if no password is set.
-@return Password database entry
-]]
-
----[[
-Test whether given string matches the password of a given system user.
-
-@class function
-@name user.checkpasswd
-@param username String containing the Unix user name
-@param pass String containing the password to compare
-@return Boolean indicating whether the passwords are equal
-]]
-
----[[
-Change the password of given user.
-
-@class function
-@name user.setpasswd
-@param username String containing the Unix user name
-@param password String containing the password to compare
-@return Number containing 0 on success and >= 1 on error
-]]
-
----[[
-LuCI system utilities / wifi related functions.
-
-@class module
-@name luci.sys.wifi
-]]
-
----[[
-Get wireless information for given interface.
-
-@class function
-@name wifi.getiwinfo
-@param ifname String containing the interface name
-@return A wrapped iwinfo object instance
-]]
-
----[[
-LuCI system utilities / init related functions.
-
-@class module
-@name luci.sys.init
-]]
-
----[[
-Get the names of all installed init scripts
-
-@class function
-@name init.names
-@return Table containing the names of all inistalled init scripts
-]]
-
----[[
-Get the index of he given init script
-
-@class function
-@name init.index
-@param name Name of the init script
-@return Numeric index value
-]]
-
----[[
-Test whether the given init script is enabled
-
-@class function
-@name init.enabled
-@param name Name of the init script
-@return Boolean indicating whether init is enabled
-]]
-
----[[
-Enable the given init script
-
-@class function
-@name init.enable
-@param name Name of the init script
-@return Boolean indicating success
-]]
-
----[[
-Disable the given init script
-
-@class function
-@name init.disable
-@param name Name of the init script
-@return Boolean indicating success
-]]
-
----[[
-Start the given init script
-
-@class function
-@name init.start
-@param name Name of the init script
-@return Boolean indicating success
-]]
-
----[[
-Stop the given init script
-
-@class function
-@name init.stop
-@param name Name of the init script
-@return Boolean indicating success
-]]
-
diff --git a/modules/luci-base/luasrc/sys/zoneinfo.lua b/modules/luci-base/luasrc/sys/zoneinfo.lua
deleted file mode 100644
index aa054a246f..0000000000
--- a/modules/luci-base/luasrc/sys/zoneinfo.lua
+++ /dev/null
@@ -1,19 +0,0 @@
--- Licensed to the public under the Apache License 2.0.
-
-local setmetatable, require, rawget, rawset = setmetatable, require, rawget, rawset
-
-module "luci.sys.zoneinfo"
-
-setmetatable(_M, {
- __index = function(t, k)
- if k == "TZ" and not rawget(t, k) then
- local m = require "luci.sys.zoneinfo.tzdata"
- rawset(t, k, rawget(m, k))
- elseif k == "OFFSET" and not rawget(t, k) then
- local m = require "luci.sys.zoneinfo.tzoffset"
- rawset(t, k, rawget(m, k))
- end
-
- return rawget(t, k)
- end
-})
diff --git a/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua b/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua
deleted file mode 100644
index a3edbf5cb4..0000000000
--- a/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua
+++ /dev/null
@@ -1,457 +0,0 @@
--- Licensed to the public under the Apache License 2.0.
-
-module "luci.sys.zoneinfo.tzdata"
-
-TZ = {
- { 'Africa/Abidjan', 'GMT0' },
- { 'Africa/Accra', 'GMT0' },
- { 'Africa/Addis Ababa', 'EAT-3' },
- { 'Africa/Algiers', 'CET-1' },
- { 'Africa/Asmara', 'EAT-3' },
- { 'Africa/Bamako', 'GMT0' },
- { 'Africa/Bangui', 'WAT-1' },
- { 'Africa/Banjul', 'GMT0' },
- { 'Africa/Bissau', 'GMT0' },
- { 'Africa/Blantyre', 'CAT-2' },
- { 'Africa/Brazzaville', 'WAT-1' },
- { 'Africa/Bujumbura', 'CAT-2' },
- { 'Africa/Cairo', 'EET-2' },
- { 'Africa/Casablanca', '<+01>-1' },
- { 'Africa/Ceuta', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Africa/Conakry', 'GMT0' },
- { 'Africa/Dakar', 'GMT0' },
- { 'Africa/Dar es Salaam', 'EAT-3' },
- { 'Africa/Djibouti', 'EAT-3' },
- { 'Africa/Douala', 'WAT-1' },
- { 'Africa/El Aaiun', '<+01>-1' },
- { 'Africa/Freetown', 'GMT0' },
- { 'Africa/Gaborone', 'CAT-2' },
- { 'Africa/Harare', 'CAT-2' },
- { 'Africa/Johannesburg', 'SAST-2' },
- { 'Africa/Juba', 'CAT-2' },
- { 'Africa/Kampala', 'EAT-3' },
- { 'Africa/Khartoum', 'CAT-2' },
- { 'Africa/Kigali', 'CAT-2' },
- { 'Africa/Kinshasa', 'WAT-1' },
- { 'Africa/Lagos', 'WAT-1' },
- { 'Africa/Libreville', 'WAT-1' },
- { 'Africa/Lome', 'GMT0' },
- { 'Africa/Luanda', 'WAT-1' },
- { 'Africa/Lubumbashi', 'CAT-2' },
- { 'Africa/Lusaka', 'CAT-2' },
- { 'Africa/Malabo', 'WAT-1' },
- { 'Africa/Maputo', 'CAT-2' },
- { 'Africa/Maseru', 'SAST-2' },
- { 'Africa/Mbabane', 'SAST-2' },
- { 'Africa/Mogadishu', 'EAT-3' },
- { 'Africa/Monrovia', 'GMT0' },
- { 'Africa/Nairobi', 'EAT-3' },
- { 'Africa/Ndjamena', 'WAT-1' },
- { 'Africa/Niamey', 'WAT-1' },
- { 'Africa/Nouakchott', 'GMT0' },
- { 'Africa/Ouagadougou', 'GMT0' },
- { 'Africa/Porto-Novo', 'WAT-1' },
- { 'Africa/Sao Tome', 'GMT0' },
- { 'Africa/Tripoli', 'EET-2' },
- { 'Africa/Tunis', 'CET-1' },
- { 'Africa/Windhoek', 'CAT-2' },
- { 'America/Adak', 'HST10HDT,M3.2.0,M11.1.0' },
- { 'America/Anchorage', 'AKST9AKDT,M3.2.0,M11.1.0' },
- { 'America/Anguilla', 'AST4' },
- { 'America/Antigua', 'AST4' },
- { 'America/Araguaina', '<-03>3' },
- { 'America/Argentina/Buenos Aires', '<-03>3' },
- { 'America/Argentina/Catamarca', '<-03>3' },
- { 'America/Argentina/Cordoba', '<-03>3' },
- { 'America/Argentina/Jujuy', '<-03>3' },
- { 'America/Argentina/La Rioja', '<-03>3' },
- { 'America/Argentina/Mendoza', '<-03>3' },
- { 'America/Argentina/Rio Gallegos', '<-03>3' },
- { 'America/Argentina/Salta', '<-03>3' },
- { 'America/Argentina/San Juan', '<-03>3' },
- { 'America/Argentina/San Luis', '<-03>3' },
- { 'America/Argentina/Tucuman', '<-03>3' },
- { 'America/Argentina/Ushuaia', '<-03>3' },
- { 'America/Aruba', 'AST4' },
- { 'America/Asuncion', '<-04>4<-03>,M10.1.0/0,M3.4.0/0' },
- { 'America/Atikokan', 'EST5' },
- { 'America/Bahia', '<-03>3' },
- { 'America/Bahia Banderas', 'CST6CDT,M4.1.0,M10.5.0' },
- { 'America/Barbados', 'AST4' },
- { 'America/Belem', '<-03>3' },
- { 'America/Belize', 'CST6' },
- { 'America/Blanc-Sablon', 'AST4' },
- { 'America/Boa Vista', '<-04>4' },
- { 'America/Bogota', '<-05>5' },
- { 'America/Boise', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'America/Cambridge Bay', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'America/Campo Grande', '<-04>4' },
- { 'America/Cancun', 'EST5' },
- { 'America/Caracas', '<-04>4' },
- { 'America/Cayenne', '<-03>3' },
- { 'America/Cayman', 'EST5' },
- { 'America/Chicago', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Chihuahua', 'MST7MDT,M4.1.0,M10.5.0' },
- { 'America/Costa Rica', 'CST6' },
- { 'America/Creston', 'MST7' },
- { 'America/Cuiaba', '<-04>4' },
- { 'America/Curacao', 'AST4' },
- { 'America/Danmarkshavn', 'GMT0' },
- { 'America/Dawson', 'MST7' },
- { 'America/Dawson Creek', 'MST7' },
- { 'America/Denver', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'America/Detroit', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Dominica', 'AST4' },
- { 'America/Edmonton', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'America/Eirunepe', '<-05>5' },
- { 'America/El Salvador', 'CST6' },
- { 'America/Fort Nelson', 'MST7' },
- { 'America/Fortaleza', '<-03>3' },
- { 'America/Glace Bay', 'AST4ADT,M3.2.0,M11.1.0' },
- { 'America/Goose Bay', 'AST4ADT,M3.2.0,M11.1.0' },
- { 'America/Grand Turk', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Grenada', 'AST4' },
- { 'America/Guadeloupe', 'AST4' },
- { 'America/Guatemala', 'CST6' },
- { 'America/Guayaquil', '<-05>5' },
- { 'America/Guyana', '<-04>4' },
- { 'America/Halifax', 'AST4ADT,M3.2.0,M11.1.0' },
- { 'America/Havana', 'CST5CDT,M3.2.0/0,M11.1.0/1' },
- { 'America/Hermosillo', 'MST7' },
- { 'America/Indiana/Indianapolis', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Knox', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Marengo', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Petersburg', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Tell City', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Vevay', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Vincennes', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Indiana/Winamac', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Inuvik', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'America/Iqaluit', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Jamaica', 'EST5' },
- { 'America/Juneau', 'AKST9AKDT,M3.2.0,M11.1.0' },
- { 'America/Kentucky/Louisville', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Kentucky/Monticello', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Kralendijk', 'AST4' },
- { 'America/La Paz', '<-04>4' },
- { 'America/Lima', '<-05>5' },
- { 'America/Los Angeles', 'PST8PDT,M3.2.0,M11.1.0' },
- { 'America/Lower Princes', 'AST4' },
- { 'America/Maceio', '<-03>3' },
- { 'America/Managua', 'CST6' },
- { 'America/Manaus', '<-04>4' },
- { 'America/Marigot', 'AST4' },
- { 'America/Martinique', 'AST4' },
- { 'America/Matamoros', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Mazatlan', 'MST7MDT,M4.1.0,M10.5.0' },
- { 'America/Menominee', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Merida', 'CST6CDT,M4.1.0,M10.5.0' },
- { 'America/Metlakatla', 'AKST9AKDT,M3.2.0,M11.1.0' },
- { 'America/Mexico City', 'CST6CDT,M4.1.0,M10.5.0' },
- { 'America/Miquelon', '<-03>3<-02>,M3.2.0,M11.1.0' },
- { 'America/Moncton', 'AST4ADT,M3.2.0,M11.1.0' },
- { 'America/Monterrey', 'CST6CDT,M4.1.0,M10.5.0' },
- { 'America/Montevideo', '<-03>3' },
- { 'America/Montserrat', 'AST4' },
- { 'America/Nassau', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/New York', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Nipigon', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Nome', 'AKST9AKDT,M3.2.0,M11.1.0' },
- { 'America/Noronha', '<-02>2' },
- { 'America/North Dakota/Beulah', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/North Dakota/Center', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/North Dakota/New Salem', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Nuuk', '<-03>3<-02>,M3.5.0/-2,M10.5.0/-1' },
- { 'America/Ojinaga', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'America/Panama', 'EST5' },
- { 'America/Pangnirtung', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Paramaribo', '<-03>3' },
- { 'America/Phoenix', 'MST7' },
- { 'America/Port of Spain', 'AST4' },
- { 'America/Port-au-Prince', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Porto Velho', '<-04>4' },
- { 'America/Puerto Rico', 'AST4' },
- { 'America/Punta Arenas', '<-03>3' },
- { 'America/Rainy River', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Rankin Inlet', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Recife', '<-03>3' },
- { 'America/Regina', 'CST6' },
- { 'America/Resolute', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Rio Branco', '<-05>5' },
- { 'America/Santarem', '<-03>3' },
- { 'America/Santiago', '<-04>4<-03>,M9.1.6/24,M4.1.6/24' },
- { 'America/Santo Domingo', 'AST4' },
- { 'America/Sao Paulo', '<-03>3' },
- { 'America/Scoresbysund', '<-01>1<+00>,M3.5.0/0,M10.5.0/1' },
- { 'America/Sitka', 'AKST9AKDT,M3.2.0,M11.1.0' },
- { 'America/St Barthelemy', 'AST4' },
- { 'America/St Johns', 'NST3:30NDT,M3.2.0,M11.1.0' },
- { 'America/St Kitts', 'AST4' },
- { 'America/St Lucia', 'AST4' },
- { 'America/St Thomas', 'AST4' },
- { 'America/St Vincent', 'AST4' },
- { 'America/Swift Current', 'CST6' },
- { 'America/Tegucigalpa', 'CST6' },
- { 'America/Thule', 'AST4ADT,M3.2.0,M11.1.0' },
- { 'America/Thunder Bay', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Tijuana', 'PST8PDT,M3.2.0,M11.1.0' },
- { 'America/Toronto', 'EST5EDT,M3.2.0,M11.1.0' },
- { 'America/Tortola', 'AST4' },
- { 'America/Vancouver', 'PST8PDT,M3.2.0,M11.1.0' },
- { 'America/Whitehorse', 'MST7' },
- { 'America/Winnipeg', 'CST6CDT,M3.2.0,M11.1.0' },
- { 'America/Yakutat', 'AKST9AKDT,M3.2.0,M11.1.0' },
- { 'America/Yellowknife', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'Antarctica/Casey', '<+11>-11' },
- { 'Antarctica/Davis', '<+07>-7' },
- { 'Antarctica/DumontDUrville', '<+10>-10' },
- { 'Antarctica/Macquarie', 'AEST-10AEDT,M10.1.0,M4.1.0/3' },
- { 'Antarctica/Mawson', '<+05>-5' },
- { 'Antarctica/McMurdo', 'NZST-12NZDT,M9.5.0,M4.1.0/3' },
- { 'Antarctica/Palmer', '<-03>3' },
- { 'Antarctica/Rothera', '<-03>3' },
- { 'Antarctica/Syowa', '<+03>-3' },
- { 'Antarctica/Troll', '<+00>0<+02>-2,M3.5.0/1,M10.5.0/3' },
- { 'Antarctica/Vostok', '<+06>-6' },
- { 'Arctic/Longyearbyen', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Asia/Aden', '<+03>-3' },
- { 'Asia/Almaty', '<+06>-6' },
- { 'Asia/Amman', 'EET-2EEST,M2.5.4/24,M10.5.5/1' },
- { 'Asia/Anadyr', '<+12>-12' },
- { 'Asia/Aqtau', '<+05>-5' },
- { 'Asia/Aqtobe', '<+05>-5' },
- { 'Asia/Ashgabat', '<+05>-5' },
- { 'Asia/Atyrau', '<+05>-5' },
- { 'Asia/Baghdad', '<+03>-3' },
- { 'Asia/Bahrain', '<+03>-3' },
- { 'Asia/Baku', '<+04>-4' },
- { 'Asia/Bangkok', '<+07>-7' },
- { 'Asia/Barnaul', '<+07>-7' },
- { 'Asia/Beirut', 'EET-2EEST,M3.5.0/0,M10.5.0/0' },
- { 'Asia/Bishkek', '<+06>-6' },
- { 'Asia/Brunei', '<+08>-8' },
- { 'Asia/Chita', '<+09>-9' },
- { 'Asia/Choibalsan', '<+08>-8' },
- { 'Asia/Colombo', '<+0530>-5:30' },
- { 'Asia/Damascus', 'EET-2EEST,M3.5.5/0,M10.5.5/0' },
- { 'Asia/Dhaka', '<+06>-6' },
- { 'Asia/Dili', '<+09>-9' },
- { 'Asia/Dubai', '<+04>-4' },
- { 'Asia/Dushanbe', '<+05>-5' },
- { 'Asia/Famagusta', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Asia/Gaza', 'EET-2EEST,M3.4.4/72,M10.4.4/25' },
- { 'Asia/Hebron', 'EET-2EEST,M3.4.4/72,M10.4.4/25' },
- { 'Asia/Ho Chi Minh', '<+07>-7' },
- { 'Asia/Hong Kong', 'HKT-8' },
- { 'Asia/Hovd', '<+07>-7' },
- { 'Asia/Irkutsk', '<+08>-8' },
- { 'Asia/Jakarta', 'WIB-7' },
- { 'Asia/Jayapura', 'WIT-9' },
- { 'Asia/Jerusalem', 'IST-2IDT,M3.4.4/26,M10.5.0' },
- { 'Asia/Kabul', '<+0430>-4:30' },
- { 'Asia/Kamchatka', '<+12>-12' },
- { 'Asia/Karachi', 'PKT-5' },
- { 'Asia/Kathmandu', '<+0545>-5:45' },
- { 'Asia/Khandyga', '<+09>-9' },
- { 'Asia/Kolkata', 'IST-5:30' },
- { 'Asia/Krasnoyarsk', '<+07>-7' },
- { 'Asia/Kuala Lumpur', '<+08>-8' },
- { 'Asia/Kuching', '<+08>-8' },
- { 'Asia/Kuwait', '<+03>-3' },
- { 'Asia/Macau', 'CST-8' },
- { 'Asia/Magadan', '<+11>-11' },
- { 'Asia/Makassar', 'WITA-8' },
- { 'Asia/Manila', 'PST-8' },
- { 'Asia/Muscat', '<+04>-4' },
- { 'Asia/Nicosia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Asia/Novokuznetsk', '<+07>-7' },
- { 'Asia/Novosibirsk', '<+07>-7' },
- { 'Asia/Omsk', '<+06>-6' },
- { 'Asia/Oral', '<+05>-5' },
- { 'Asia/Phnom Penh', '<+07>-7' },
- { 'Asia/Pontianak', 'WIB-7' },
- { 'Asia/Pyongyang', 'KST-9' },
- { 'Asia/Qatar', '<+03>-3' },
- { 'Asia/Qostanay', '<+06>-6' },
- { 'Asia/Qyzylorda', '<+05>-5' },
- { 'Asia/Riyadh', '<+03>-3' },
- { 'Asia/Sakhalin', '<+11>-11' },
- { 'Asia/Samarkand', '<+05>-5' },
- { 'Asia/Seoul', 'KST-9' },
- { 'Asia/Shanghai', 'CST-8' },
- { 'Asia/Singapore', '<+08>-8' },
- { 'Asia/Srednekolymsk', '<+11>-11' },
- { 'Asia/Taipei', 'CST-8' },
- { 'Asia/Tashkent', '<+05>-5' },
- { 'Asia/Tbilisi', '<+04>-4' },
- { 'Asia/Tehran', '<+0330>-3:30' },
- { 'Asia/Thimphu', '<+06>-6' },
- { 'Asia/Tokyo', 'JST-9' },
- { 'Asia/Tomsk', '<+07>-7' },
- { 'Asia/Ulaanbaatar', '<+08>-8' },
- { 'Asia/Urumqi', '<+06>-6' },
- { 'Asia/Ust-Nera', '<+10>-10' },
- { 'Asia/Vientiane', '<+07>-7' },
- { 'Asia/Vladivostok', '<+10>-10' },
- { 'Asia/Yakutsk', '<+09>-9' },
- { 'Asia/Yangon', '<+0630>-6:30' },
- { 'Asia/Yekaterinburg', '<+05>-5' },
- { 'Asia/Yerevan', '<+04>-4' },
- { 'Atlantic/Azores', '<-01>1<+00>,M3.5.0/0,M10.5.0/1' },
- { 'Atlantic/Bermuda', 'AST4ADT,M3.2.0,M11.1.0' },
- { 'Atlantic/Canary', 'WET0WEST,M3.5.0/1,M10.5.0' },
- { 'Atlantic/Cape Verde', '<-01>1' },
- { 'Atlantic/Faroe', 'WET0WEST,M3.5.0/1,M10.5.0' },
- { 'Atlantic/Madeira', 'WET0WEST,M3.5.0/1,M10.5.0' },
- { 'Atlantic/Reykjavik', 'GMT0' },
- { 'Atlantic/South Georgia', '<-02>2' },
- { 'Atlantic/St Helena', 'GMT0' },
- { 'Atlantic/Stanley', '<-03>3' },
- { 'Australia/Adelaide', 'ACST-9:30ACDT,M10.1.0,M4.1.0/3' },
- { 'Australia/Brisbane', 'AEST-10' },
- { 'Australia/Broken Hill', 'ACST-9:30ACDT,M10.1.0,M4.1.0/3' },
- { 'Australia/Darwin', 'ACST-9:30' },
- { 'Australia/Eucla', '<+0845>-8:45' },
- { 'Australia/Hobart', 'AEST-10AEDT,M10.1.0,M4.1.0/3' },
- { 'Australia/Lindeman', 'AEST-10' },
- { 'Australia/Lord Howe', '<+1030>-10:30<+11>-11,M10.1.0,M4.1.0' },
- { 'Australia/Melbourne', 'AEST-10AEDT,M10.1.0,M4.1.0/3' },
- { 'Australia/Perth', 'AWST-8' },
- { 'Australia/Sydney', 'AEST-10AEDT,M10.1.0,M4.1.0/3' },
- { 'Etc/GMT', 'GMT0' },
- { 'Etc/GMT+1', '<-01>1' },
- { 'Etc/GMT+10', '<-10>10' },
- { 'Etc/GMT+11', '<-11>11' },
- { 'Etc/GMT+12', '<-12>12' },
- { 'Etc/GMT+2', '<-02>2' },
- { 'Etc/GMT+3', '<-03>3' },
- { 'Etc/GMT+4', '<-04>4' },
- { 'Etc/GMT+5', '<-05>5' },
- { 'Etc/GMT+6', '<-06>6' },
- { 'Etc/GMT+7', '<-07>7' },
- { 'Etc/GMT+8', '<-08>8' },
- { 'Etc/GMT+9', '<-09>9' },
- { 'Etc/GMT-1', '<+01>-1' },
- { 'Etc/GMT-10', '<+10>-10' },
- { 'Etc/GMT-11', '<+11>-11' },
- { 'Etc/GMT-12', '<+12>-12' },
- { 'Etc/GMT-13', '<+13>-13' },
- { 'Etc/GMT-14', '<+14>-14' },
- { 'Etc/GMT-2', '<+02>-2' },
- { 'Etc/GMT-3', '<+03>-3' },
- { 'Etc/GMT-4', '<+04>-4' },
- { 'Etc/GMT-5', '<+05>-5' },
- { 'Etc/GMT-6', '<+06>-6' },
- { 'Etc/GMT-7', '<+07>-7' },
- { 'Etc/GMT-8', '<+08>-8' },
- { 'Etc/GMT-9', '<+09>-9' },
- { 'Europe/Amsterdam', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Andorra', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Astrakhan', '<+04>-4' },
- { 'Europe/Athens', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Belgrade', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Berlin', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Bratislava', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Brussels', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Bucharest', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Budapest', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Busingen', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Chisinau', 'EET-2EEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Copenhagen', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Dublin', 'IST-1GMT0,M10.5.0,M3.5.0/1' },
- { 'Europe/Gibraltar', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Guernsey', 'GMT0BST,M3.5.0/1,M10.5.0' },
- { 'Europe/Helsinki', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Isle of Man', 'GMT0BST,M3.5.0/1,M10.5.0' },
- { 'Europe/Istanbul', '<+03>-3' },
- { 'Europe/Jersey', 'GMT0BST,M3.5.0/1,M10.5.0' },
- { 'Europe/Kaliningrad', 'EET-2' },
- { 'Europe/Kirov', '<+03>-3' },
- { 'Europe/Kyiv', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Lisbon', 'WET0WEST,M3.5.0/1,M10.5.0' },
- { 'Europe/Ljubljana', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/London', 'GMT0BST,M3.5.0/1,M10.5.0' },
- { 'Europe/Luxembourg', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Madrid', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Malta', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Mariehamn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Minsk', '<+03>-3' },
- { 'Europe/Monaco', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Moscow', 'MSK-3' },
- { 'Europe/Oslo', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Paris', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Podgorica', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Prague', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Riga', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Rome', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Samara', '<+04>-4' },
- { 'Europe/San Marino', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Sarajevo', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Saratov', '<+04>-4' },
- { 'Europe/Simferopol', 'MSK-3' },
- { 'Europe/Skopje', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Sofia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Stockholm', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Tallinn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Tirane', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Ulyanovsk', '<+04>-4' },
- { 'Europe/Uzhgorod', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Vaduz', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Vatican', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Vienna', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Vilnius', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Volgograd', '<+03>-3' },
- { 'Europe/Warsaw', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Zagreb', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Europe/Zaporozhye', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Europe/Zurich', 'CET-1CEST,M3.5.0,M10.5.0/3' },
- { 'Indian/Antananarivo', 'EAT-3' },
- { 'Indian/Chagos', '<+06>-6' },
- { 'Indian/Christmas', '<+07>-7' },
- { 'Indian/Cocos', '<+0630>-6:30' },
- { 'Indian/Comoro', 'EAT-3' },
- { 'Indian/Kerguelen', '<+05>-5' },
- { 'Indian/Mahe', '<+04>-4' },
- { 'Indian/Maldives', '<+05>-5' },
- { 'Indian/Mauritius', '<+04>-4' },
- { 'Indian/Mayotte', 'EAT-3' },
- { 'Indian/Reunion', '<+04>-4' },
- { 'Pacific/Apia', '<+13>-13' },
- { 'Pacific/Auckland', 'NZST-12NZDT,M9.5.0,M4.1.0/3' },
- { 'Pacific/Bougainville', '<+11>-11' },
- { 'Pacific/Chatham', '<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45' },
- { 'Pacific/Chuuk', '<+10>-10' },
- { 'Pacific/Easter', '<-06>6<-05>,M9.1.6/22,M4.1.6/22' },
- { 'Pacific/Efate', '<+11>-11' },
- { 'Pacific/Fakaofo', '<+13>-13' },
- { 'Pacific/Fiji', '<+12>-12<+13>,M11.2.0,M1.2.3/99' },
- { 'Pacific/Funafuti', '<+12>-12' },
- { 'Pacific/Galapagos', '<-06>6' },
- { 'Pacific/Gambier', '<-09>9' },
- { 'Pacific/Guadalcanal', '<+11>-11' },
- { 'Pacific/Guam', 'ChST-10' },
- { 'Pacific/Honolulu', 'HST10' },
- { 'Pacific/Kanton', '<+13>-13' },
- { 'Pacific/Kiritimati', '<+14>-14' },
- { 'Pacific/Kosrae', '<+11>-11' },
- { 'Pacific/Kwajalein', '<+12>-12' },
- { 'Pacific/Majuro', '<+12>-12' },
- { 'Pacific/Marquesas', '<-0930>9:30' },
- { 'Pacific/Midway', 'SST11' },
- { 'Pacific/Nauru', '<+12>-12' },
- { 'Pacific/Niue', '<-11>11' },
- { 'Pacific/Norfolk', '<+11>-11<+12>,M10.1.0,M4.1.0/3' },
- { 'Pacific/Noumea', '<+11>-11' },
- { 'Pacific/Pago Pago', 'SST11' },
- { 'Pacific/Palau', '<+09>-9' },
- { 'Pacific/Pitcairn', '<-08>8' },
- { 'Pacific/Pohnpei', '<+11>-11' },
- { 'Pacific/Port Moresby', '<+10>-10' },
- { 'Pacific/Rarotonga', '<-10>10' },
- { 'Pacific/Saipan', 'ChST-10' },
- { 'Pacific/Tahiti', '<-10>10' },
- { 'Pacific/Tarawa', '<+12>-12' },
- { 'Pacific/Tongatapu', '<+13>-13' },
- { 'Pacific/Wake', '<+12>-12' },
- { 'Pacific/Wallis', '<+12>-12' },
-}
diff --git a/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua b/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua
deleted file mode 100644
index caee1d2c1c..0000000000
--- a/modules/luci-base/luasrc/sys/zoneinfo/tzoffset.lua
+++ /dev/null
@@ -1,46 +0,0 @@
--- Licensed to the public under the Apache License 2.0.
-
-module "luci.sys.zoneinfo.tzoffset"
-
-OFFSET = {
- gmt = 0, -- GMT
- eat = 10800, -- EAT
- cet = 3600, -- CET
- wat = 3600, -- WAT
- cat = 7200, -- CAT
- eet = 7200, -- EET
- sast = 7200, -- SAST
- hst = -36000, -- HST
- hdt = -32400, -- HDT
- akst = -32400, -- AKST
- akdt = -28800, -- AKDT
- ast = -14400, -- AST
- est = -18000, -- EST
- cst = -21600, -- CST
- cdt = -18000, -- CDT
- mst = -25200, -- MST
- mdt = -21600, -- MDT
- pst = -28800, -- PST
- pdt = -25200, -- PDT
- nst = -12600, -- NST
- ndt = -9000, -- NDT
- aest = 36000, -- AEST
- aedt = 39600, -- AEDT
- nzst = 43200, -- NZST
- nzdt = 46800, -- NZDT
- hkt = 28800, -- HKT
- wib = 25200, -- WIB
- wit = 32400, -- WIT
- ist = 7200, -- IST
- idt = 10800, -- IDT
- pkt = 18000, -- PKT
- wita = 28800, -- WITA
- kst = 32400, -- KST
- jst = 32400, -- JST
- wet = 0, -- WET
- acst = 34200, -- ACST
- acdt = 37800, -- ACDT
- awst = 28800, -- AWST
- msk = 10800, -- MSK
- sst = -39600, -- SST
-}
diff --git a/modules/luci-base/luasrc/template.lua b/modules/luci-base/luasrc/template.lua
deleted file mode 100644
index 3955bd76f3..0000000000
--- a/modules/luci-base/luasrc/template.lua
+++ /dev/null
@@ -1,100 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local util = require "luci.util"
-local config = require "luci.config"
-local tparser = require "luci.template.parser"
-
-local tostring, pairs, loadstring = tostring, pairs, loadstring
-local setmetatable, loadfile = setmetatable, loadfile
-local getfenv, setfenv, rawget = getfenv, setfenv, rawget
-local assert, type, error = assert, type, error
-
---- LuCI template library.
-module "luci.template"
-
-config.template = config.template or {}
-viewdir = config.template.viewdir or util.libpath() .. "/view"
-
-
--- Define the namespace for template modules
-context = util.threadlocal()
-
---- Render a certain template.
--- @param name Template name
--- @param scope Scope to assign to template (optional)
-function render(name, scope)
- return Template(name):render(scope or getfenv(2))
-end
-
---- Render a template from a string.
--- @param template Template string
--- @param scope Scope to assign to template (optional)
-function render_string(template, scope)
- return Template(nil, template):render(scope or getfenv(2))
-end
-
-
--- Template class
-Template = util.class()
-
--- Shared template cache to store templates in to avoid unnecessary reloading
-Template.cache = setmetatable({}, {__mode = "v"})
-
-
--- Constructor - Reads and compiles the template on-demand
-function Template.__init__(self, name, template)
- if name then
- self.template = self.cache[name]
- self.name = name
- else
- self.name = "[string]"
- end
-
- -- Create a new namespace for this template
- self.viewns = context.viewns
-
- -- If we have a cached template, skip compiling and loading
- if not self.template then
-
- -- Compile template
- local err
- local sourcefile
-
- if name then
- sourcefile = viewdir .. "/" .. name .. ".htm"
- self.template, _, err = tparser.parse(sourcefile)
- else
- sourcefile = "[string]"
- self.template, _, err = tparser.parse_string(template)
- end
-
- -- If we have no valid template throw error, otherwise cache the template
- if not self.template then
- error("Failed to load template '" .. self.name .. "'.\n" ..
- "Error while parsing template '" .. sourcefile .. "':\n" ..
- (err or "Unknown syntax error"))
- elseif name then
- self.cache[name] = self.template
- end
- end
-end
-
-
--- Renders a template
-function Template.render(self, scope)
- scope = scope or getfenv(2)
-
- -- Put our predefined objects in the scope of the template
- setfenv(self.template, setmetatable({}, {__index =
- function(tbl, key)
- return rawget(tbl, key) or self.viewns[key] or scope[key]
- end}))
-
- -- Now finally render the thing
- local stat, err = util.copcall(self.template)
- if not stat then
- error("Failed to execute template '" .. self.name .. "'.\n" ..
- "A runtime error occurred: " .. tostring(err or "(nil)"))
- end
-end
diff --git a/modules/luci-base/luasrc/version.lua b/modules/luci-base/luasrc/version.lua
deleted file mode 100644
index 8af2e80619..0000000000
--- a/modules/luci-base/luasrc/version.lua
+++ /dev/null
@@ -1,9 +0,0 @@
--- Licensed to the public under the Apache License 2.0.
-
-module "luci.version"
-
-distname = "Host System"
-distversion = "SDK"
-
-luciname = "LuCI"
-luciversion = "SVN"
diff --git a/modules/luci-base/luasrc/view/csrftoken.htm b/modules/luci-base/luasrc/view/csrftoken.htm
deleted file mode 100644
index 57ac03f3bf..0000000000
--- a/modules/luci-base/luasrc/view/csrftoken.htm
+++ /dev/null
@@ -1,24 +0,0 @@
-<%#
- Copyright 2015 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-
-<h2 name="content"><%:Form token mismatch%></h2>
-<br />
-
-<p class="alert-message"><%:The submitted security token is invalid or already expired!%></p>
-
-<p><%:
- In order to prevent unauthorized access to the system, your request has
- been blocked. Click "Continue »" below to return to the previous page.
-%></p>
-
-<hr />
-
-<p class="right">
- <strong><a href="#" onclick="window.history.back();">Continue »</a></strong>
-</p>
-
-<%+footer%>
diff --git a/modules/luci-base/luasrc/view/empty_node_placeholder.htm b/modules/luci-base/luasrc/view/empty_node_placeholder.htm
deleted file mode 100644
index b7e276b960..0000000000
--- a/modules/luci-base/luasrc/view/empty_node_placeholder.htm
+++ /dev/null
@@ -1,11 +0,0 @@
-<%#
- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
- Copyright 2018 Daniel F. Dickinson <cshored@thecshore.com>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-
-<p>Component not present.</p>
-
-<%+footer%>
diff --git a/modules/luci-base/luasrc/view/error404.htm b/modules/luci-base/luasrc/view/error404.htm
deleted file mode 100644
index ff151d1834..0000000000
--- a/modules/luci-base/luasrc/view/error404.htm
+++ /dev/null
@@ -1,12 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-<h2 name="content">404 <%:Not Found%></h2>
-<p><%:Sorry, the object you requested was not found.%></p>
-<p><%=message%></p>
-<tt><%:Unable to dispatch%>: <%=url(unpack(luci.dispatcher.context.request))%></tt>
-<%+footer%>
diff --git a/modules/luci-base/luasrc/view/error500.htm b/modules/luci-base/luasrc/view/error500.htm
deleted file mode 100644
index 34a52cda84..0000000000
--- a/modules/luci-base/luasrc/view/error500.htm
+++ /dev/null
@@ -1,11 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-<h2 name="content">500 <%:Internal Server Error%></h2>
-<p><%:Sorry, the server encountered an unexpected error.%></p>
-<pre class="error500"><%=message%></pre>
-<%+footer%>
diff --git a/modules/luci-base/luasrc/view/footer.htm b/modules/luci-base/luasrc/view/footer.htm
deleted file mode 100644
index ba14ec8678..0000000000
--- a/modules/luci-base/luasrc/view/footer.htm
+++ /dev/null
@@ -1,27 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008-2019 Jo-Philipp Wich <jo@mein.io>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%
- local is_rollback_pending, rollback_time_remaining, rollback_session, rollback_token = luci.model.uci:rollback_pending()
-
- if is_rollback_pending or trigger_apply or trigger_revert then
-%>
- <script type="text/javascript">
- document.addEventListener("luci-loaded", function() {
- <% if trigger_apply then -%>
- L.ui.changes.apply(true);
- <%- elseif trigger_revert then -%>
- L.ui.changes.revert();
- <%- else -%>
- L.ui.changes.confirm(true, Date.now() + <%=rollback_time_remaining%> * 1000, <%=luci.http.write_json(rollback_token)%>);
- <%- end %>
- });
- </script>
-<%
- end
-
- include("themes/" .. theme .. "/footer")
-%>
diff --git a/modules/luci-base/luasrc/view/header.htm b/modules/luci-base/luasrc/view/header.htm
deleted file mode 100644
index cffe9482ca..0000000000
--- a/modules/luci-base/luasrc/view/header.htm
+++ /dev/null
@@ -1,38 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008-2019 Jo-Philipp Wich <jo@mein.io>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%
- if not luci.dispatcher.context.template_header_sent then
- include("themes/" .. theme .. "/header")
- luci.dispatcher.context.template_header_sent = true
- end
-
- local applyconf = luci.config and luci.config.apply
-%>
-
-<script type="text/javascript" src="<%=resource%>/promis.min.js"></script>
-<script type="text/javascript" src="<%=resource%>/luci.js"></script>
-<script type="text/javascript">
- L = new LuCI(<%= luci.http.write_json({
- token = token,
- media = media,
- resource = resource,
- scriptname = luci.http.getenv("SCRIPT_NAME"),
- pathinfo = luci.http.getenv("PATH_INFO"),
- documentroot = luci.http.getenv("DOCUMENT_ROOT"),
- requestpath = luci.dispatcher.context.requestpath,
- dispatchpath = luci.dispatcher.context.path,
- pollinterval = luci.config.main.pollinterval or 5,
- ubuspath = luci.config.main.ubuspath or '/ubus/',
- sessionid = luci.dispatcher.context.authsession,
- nodespec = luci.dispatcher.context.dispatched,
- apply_rollback = math.max(applyconf and applyconf.rollback or 90, 90),
- apply_holdoff = math.max(applyconf and applyconf.holdoff or 4, 1),
- apply_timeout = math.max(applyconf and applyconf.timeout or 5, 1),
- apply_display = math.max(applyconf and applyconf.display or 1.5, 1),
- rollback_token = rollback_token
- }) %>);
-</script>
diff --git a/modules/luci-base/luasrc/view/indexer.htm b/modules/luci-base/luasrc/view/indexer.htm
deleted file mode 100644
index 28fc3debc3..0000000000
--- a/modules/luci-base/luasrc/view/indexer.htm
+++ /dev/null
@@ -1,7 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<% include("themes/" .. theme .. "/indexer") %> \ No newline at end of file
diff --git a/modules/luci-base/luasrc/view/sysauth.htm b/modules/luci-base/luasrc/view/sysauth.htm
deleted file mode 100644
index 797c87a72e..0000000000
--- a/modules/luci-base/luasrc/view/sysauth.htm
+++ /dev/null
@@ -1,75 +0,0 @@
-<%#
- Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008-2012 Jo-Philipp Wich <jow@openwrt.org>
- Licensed to the public under the Apache License 2.0.
--%>
-
-<%+header%>
-
-<form method="post" action="<%=pcdata(FULL_REQUEST_URI)%>">
- <%- if fuser then %>
- <div class="alert-message warning">
- <p><%:Invalid username and/or password! Please try again.%></p>
- </div>
- <% end -%>
-
- <div class="cbi-map">
- <h2 name="content"><%:Authorization Required%></h2>
- <div class="cbi-map-descr">
- <%:Please enter your username and password.%>
- </div>
- <div class="cbi-section"><div class="cbi-section-node">
- <div class="cbi-value">
- <label class="cbi-value-title" for="luci_username"><%:Username%></label>
- <div class="cbi-value-field">
- <input class="cbi-input-text" type="text" name="luci_username" id="luci_username" autocomplete="username" value="<%=duser%>" />
- </div>
- </div>
- <div class="cbi-value cbi-value-last">
- <label class="cbi-value-title" for="luci_password"><%:Password%></label>
- <div class="cbi-value-field">
- <input class="cbi-input-text" type="password" name="luci_password" id="luci_password" autocomplete="current-password"/>
- </div>
- </div>
- </div></div>
- </div>
-
- <div class="cbi-page-actions">
- <input type="submit" value="<%:Login%>" class="btn cbi-button cbi-button-apply" />
- <input type="reset" value="<%:Reset%>" class="btn cbi-button cbi-button-reset" />
- </div>
-</form>
-<script type="text/javascript">//<![CDATA[
- var input = document.getElementsByName('luci_password')[0];
- if (input)
- input.focus();
-//]]></script>
-
-<%
-local uci = require "luci.model.uci".cursor()
-local fs = require "nixio.fs"
-local https_key = uci:get("uhttpd", "main", "key")
-local https_port = uci:get("uhttpd", "main", "listen_https")
-if type(https_port) == "table" then
- https_port = https_port[1]
-end
-
-if https_port and fs.access(https_key) then
- https_port = https_port:match("(%d+)$")
-%>
-
-<script type="text/javascript">//<![CDATA[
- if (document.location.protocol != 'https:') {
- var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
- var img=new Image;
- img.onload=function(){window.location = url};
- img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/icons/loading.gif?' + Math.random();
- setTimeout(function(){
- img.src=''
- }, 5000);
- }
-//]]></script>
-
-<% end %>
-
-<%+footer%>
diff --git a/modules/luci-base/luasrc/view/view.htm b/modules/luci-base/luasrc/view/view.htm
deleted file mode 100644
index b451e8cfbf..0000000000
--- a/modules/luci-base/luasrc/view/view.htm
+++ /dev/null
@@ -1,12 +0,0 @@
-<%+header%>
-
-<div id="view">
- <div class="spinning"><%:Loading view…%></div>
- <script type="text/javascript">
- L.require('ui').then(function(ui) {
- ui.instantiateView('<%=view%>');
- });
- </script>
-</div>
-
-<%+footer%>
diff --git a/modules/luci-base/luasrc/xml.lua b/modules/luci-base/luasrc/xml.lua
deleted file mode 100644
index 30b37210bd..0000000000
--- a/modules/luci-base/luasrc/xml.lua
+++ /dev/null
@@ -1,26 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-local tparser = require "luci.template.parser"
-local string = require "string"
-
-local tostring = tostring
-
-module "luci.xml"
-
---
--- String and data manipulation routines
---
-
-function pcdata(value)
- return value and tparser.pcdata(tostring(value))
-end
-
-function striptags(value)
- return value and tparser.striptags(tostring(value))
-end
-
-
--- also register functions above in the central string class for convenience
-string.pcdata = pcdata
-string.striptags = striptags
diff --git a/modules/luci-base/luasrc/xml.luadoc b/modules/luci-base/luasrc/xml.luadoc
deleted file mode 100644
index 58de533966..0000000000
--- a/modules/luci-base/luasrc/xml.luadoc
+++ /dev/null
@@ -1,23 +0,0 @@
----[[
-LuCI utility functions.
-]]
-module "luci.xml"
-
----[[
-Create valid XML PCDATA from given string.
-
-@class function
-@name pcdata
-@param value String value containing the data to escape
-@return String value containing the escaped data
-]]
-
----[[
-Strip HTML tags from given string.
-
-@class function
-@name striptags
-@param value String containing the HTML text
-@return String with HTML tags stripped of
-]]
-