From d412d9c2482592607a7eadd71f5920b22cd4be60 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Sun, 11 Oct 2020 16:46:11 +0800 Subject: [PATCH 01/36] luci-app-passwall: bump to 3.9-70 --- package/lienol/luci-app-passwall/Makefile | 4 +- .../luasrc/model/cbi/passwall/api/api.lua | 28 ++ .../model/cbi/passwall/api/gen_v2ray.lua | 283 +++++++++--------- .../model/cbi/passwall/client/auto_switch.lua | 21 +- .../model/cbi/passwall/client/global.lua | 24 +- .../model/cbi/passwall/client/haproxy.lua | 19 +- .../model/cbi/passwall/client/node_config.lua | 16 +- .../model/cbi/passwall/client/other.lua | 20 -- .../model/cbi/passwall/server/api/v2ray.lua | 102 +------ .../luasrc/model/cbi/passwall/server/user.lua | 8 +- 10 files changed, 209 insertions(+), 316 deletions(-) diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index 38c25c4a83..61697e29d1 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=3.9 -PKG_RELEASE:=68 -PKG_DATE:=20201006 +PKG_RELEASE:=70 +PKG_DATE:=20201009 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua index 2693c35c34..51061d51b3 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/api.lua @@ -3,6 +3,7 @@ local fs = require "nixio.fs" local sys = require "luci.sys" local uci = require"luci.model.uci".cursor() local util = require "luci.util" +local datatypes = require "luci.cbi.datatypes" local i18n = require "luci.i18n" appname = "passwall" @@ -14,6 +15,33 @@ command_timeout = 300 LEDE_BOARD = nil DISTRIB_TARGET = nil +function get_valid_nodes() + local nodes = {} + uci:foreach(appname, "nodes", function(e) + if e.type and e.remarks then + if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then + e.remarks_name = "%s:[%s] " % {i18n.translatef(e.type .. e.protocol), e.remarks} + e.node_type = "special" + nodes[#nodes + 1] = e + end + if e.port and e.address then + local address = e.address + if datatypes.ipaddr(address) or datatypes.hostname(address) then + local address2 = address + if datatypes.ip6addr(address) then address2 = "[" .. address .. "]" end + e.remarks_name = "%s:[%s] %s:%s" % {e.type, e.remarks, address2, e.port} + if e.use_kcp and e.use_kcp == "1" then + e.remarks_name = "%s+%s:[%s] %s" % {e.type, "Kcptun", e.remarks, address2} + end + e.node_type = "normal" + nodes[#nodes + 1] = e + end + end + end + end) + return nodes +end + function gen_uuid(format) local uuid = sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)") if format == nil then diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua index 0872e77402..9ec233d1c7 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua @@ -1,16 +1,18 @@ +module("luci.model.cbi.passwall.api.gen_v2ray", package.seeall) local ucursor = require"luci.model.uci".cursor() local sys = require "luci.sys" local json = require "luci.jsonc" local appname = "passwall" -local node_section = arg[1] +local inbounds = {} +local outbounds = {} +local routing = nil + +local node_section = arg[1] or "nil" local proto = arg[2] local redir_port = arg[3] local socks_proxy_port = arg[4] local node = ucursor:get_all(appname, node_section) -local inbounds = {} -local outbounds = {} local network = proto -local routing = nil local new_port local function get_new_port() @@ -22,7 +24,7 @@ local function get_new_port() return new_port end -local function gen_outbound(node, tag, relay_port) +function gen_outbound(node, tag, relay_port) local result = nil if node then local node_id = node[".name"] @@ -145,159 +147,160 @@ local function gen_outbound(node, tag, relay_port) } } end - return result end -if socks_proxy_port ~= "nil" then - table.insert(inbounds, { - listen = "0.0.0.0", - port = tonumber(socks_proxy_port), - protocol = "socks", - settings = {auth = "noauth", udp = true, ip = "127.0.0.1"} - }) - network = "tcp,udp" -end - -if redir_port ~= "nil" then - table.insert(inbounds, { - port = tonumber(redir_port), - protocol = "dokodemo-door", - settings = {network = proto, followRedirect = true}, - sniffing = {enabled = true, destOverride = {"http", "tls"}} - }) - if proto == "tcp" and node.tcp_socks == "1" then +if node then + if socks_proxy_port ~= "nil" then table.insert(inbounds, { listen = "0.0.0.0", - port = tonumber(node.tcp_socks_port), + port = tonumber(socks_proxy_port), protocol = "socks", - settings = { - auth = node.tcp_socks_auth, - accounts = (node.tcp_socks_auth == "password") and { - { - user = node.tcp_socks_auth_username, - pass = node.tcp_socks_auth_password - } - } or nil, - udp = true - } + settings = {auth = "noauth", udp = true, ip = "127.0.0.1"} }) + network = "tcp,udp" end -end -if node.protocol == "_shunt" then - local rules = {} - ucursor:foreach(appname, "shunt_rules", function(e) - local name = e[".name"] - local _node_id = node[name] or nil - if _node_id and _node_id ~= "nil" then - local _node = ucursor:get_all(appname, _node_id) - local is_proxy = node[name .. "_proxy"] - local relay_port - if is_proxy and is_proxy == "1" then - new_port = get_new_port() - relay_port = new_port - table.insert(inbounds, { - tag = "proxy_" .. name, - listen = "127.0.0.1", - port = new_port, - protocol = "dokodemo-door", - settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)} - }) - if _node.tls_serverName == nil then - _node.tls_serverName = _node.address - end - _node.address = "127.0.0.1" - _node.port = new_port - end - local _outbound = gen_outbound(_node, name, relay_port) - if _outbound then - table.insert(outbounds, _outbound) + if redir_port ~= "nil" then + table.insert(inbounds, { + port = tonumber(redir_port), + protocol = "dokodemo-door", + settings = {network = proto, followRedirect = true}, + sniffing = {enabled = true, destOverride = {"http", "tls"}} + }) + if proto == "tcp" and node.tcp_socks == "1" then + table.insert(inbounds, { + listen = "0.0.0.0", + port = tonumber(node.tcp_socks_port), + protocol = "socks", + settings = { + auth = node.tcp_socks_auth, + accounts = (node.tcp_socks_auth == "password") and { + { + user = node.tcp_socks_auth_username, + pass = node.tcp_socks_auth_password + } + } or nil, + udp = true + } + }) + end + end + + if node.protocol == "_shunt" then + local rules = {} + ucursor:foreach(appname, "shunt_rules", function(e) + local name = e[".name"] + local _node_id = node[name] or nil + if _node_id and _node_id ~= "nil" then + local _node = ucursor:get_all(appname, _node_id) + local is_proxy = node[name .. "_proxy"] + local relay_port if is_proxy and is_proxy == "1" then - table.insert(rules, { - type = "field", - inboundTag = {"proxy_" .. name}, - outboundTag = "default" + new_port = get_new_port() + relay_port = new_port + table.insert(inbounds, { + tag = "proxy_" .. name, + listen = "127.0.0.1", + port = new_port, + protocol = "dokodemo-door", + settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)} }) + if _node.tls_serverName == nil then + _node.tls_serverName = _node.address + end + _node.address = "127.0.0.1" + _node.port = new_port end - if e.domain_list then - local _domain = {} - string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w) - table.insert(_domain, w) - end) - table.insert(rules, { - type = "field", - outboundTag = name, - domain = _domain - }) - end - if e.ip_list then - local _ip = {} - string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w) - table.insert(_ip, w) - end) - table.insert(rules, { - type = "field", - outboundTag = name, - ip = _ip - }) + local _outbound = gen_outbound(_node, name, relay_port) + if _outbound then + table.insert(outbounds, _outbound) + if is_proxy and is_proxy == "1" then + table.insert(rules, { + type = "field", + inboundTag = {"proxy_" .. name}, + outboundTag = "default" + }) + end + if e.domain_list then + local _domain = {} + string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w) + table.insert(_domain, w) + end) + table.insert(rules, { + type = "field", + outboundTag = name, + domain = _domain + }) + end + if e.ip_list then + local _ip = {} + string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w) + table.insert(_ip, w) + end) + table.insert(rules, { + type = "field", + outboundTag = name, + ip = _ip + }) + end end end + end) + + local default_node_id = node.default_node or nil + if default_node_id and default_node_id ~= "nil" then + local default_node = ucursor:get_all(appname, default_node_id) + local default_outbound = gen_outbound(default_node, "default") + if default_outbound then + table.insert(outbounds, default_outbound) + local rule = { + type = "field", + outboundTag = "default", + network = network + } + table.insert(rules, rule) + end end - end) - - local default_node_id = node.default_node or nil - if default_node_id and default_node_id ~= "nil" then - local default_node = ucursor:get_all(appname, default_node_id) - local default_outbound = gen_outbound(default_node, "default") - if default_outbound then - table.insert(outbounds, default_outbound) - local rule = { - type = "field", - outboundTag = "default", - network = network + + routing = {domainStrategy = "IPOnDemand", rules = rules} + + elseif node.protocol == "_balancing" then + if node.balancing_node then + local nodes = node.balancing_node + local length = #nodes + for i = 1, length do + local node = ucursor:get_all(appname, nodes[i]) + local outbound = gen_outbound(node) + if outbound then table.insert(outbounds, outbound) end + end + routing = { + domainStrategy = "IPOnDemand", + balancers = {{tag = "balancer", selector = nodes}}, + rules = { + {type = "field", network = "tcp,udp", balancerTag = "balancer"} + } } - table.insert(rules, rule) end + else + local outbound = gen_outbound(node) + if outbound then table.insert(outbounds, outbound) end end - routing = {domainStrategy = "IPOnDemand", rules = rules} + -- 额外传出连接 + table.insert(outbounds, {protocol = "freedom", tag = "direct", settings = {keep = ""}}) -elseif node.protocol == "_balancing" then - if node.balancing_node then - local nodes = node.balancing_node - local length = #nodes - for i = 1, length do - local node = ucursor:get_all(appname, nodes[i]) - local outbound = gen_outbound(node) - if outbound then table.insert(outbounds, outbound) end - end - routing = { - domainStrategy = "IPOnDemand", - balancers = {{tag = "balancer", selector = nodes}}, - rules = { - {type = "field", network = "tcp,udp", balancerTag = "balancer"} - } - } - end -else - local outbound = gen_outbound(node) - if outbound then table.insert(outbounds, outbound) end + local v2ray = { + log = { + -- error = string.format("/var/etc/passwall/%s.log", node[".name"]), + loglevel = "warning" + }, + -- 传入连接 + inbounds = inbounds, + -- 传出连接 + outbounds = outbounds, + -- 路由 + routing = routing + } + print(json.stringify(v2ray, 1)) end - --- 额外传出连接 -table.insert(outbounds, {protocol = "freedom", tag = "direct", settings = {keep = ""}}) - -local v2ray = { - log = { - -- error = string.format("/var/etc/passwall/%s.log", node[".name"]), - loglevel = "warning" - }, - -- 传入连接 - inbounds = inbounds, - -- 传出连接 - outbounds = outbounds, - -- 路由 - routing = routing -} -print(json.stringify(v2ray, 1)) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua index 2263890fe8..2e7006202b 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua @@ -1,21 +1,14 @@ local uci = require"luci.model.uci".cursor() +local api = require "luci.model.cbi.passwall.api.api" local appname = "passwall" local nodes_table = {} -uci:foreach(appname, "nodes", function(e) - if e.type and e.remarks then - local remarks = "" - if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then - remarks = "%s:[%s] " % {translatef(e.type .. e.protocol), e.remarks} - else - remarks = "%s:[%s] %s:%s" % {e.type, e.remarks, e.address, e.port} - end - nodes_table[#nodes_table + 1] = { - id = e[".name"], - remarks = remarks - } - end -end) +for k, e in ipairs(api.get_valid_nodes()) do + nodes_table[#nodes_table + 1] = { + id = e[".name"], + remarks = e.remarks_name + } +end m = Map(appname) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index 5e62560d80..4dcb9d14c2 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -4,24 +4,12 @@ local api = require "luci.model.cbi.passwall.api.api" local appname = "passwall" local nodes_table = {} -uci:foreach(appname, "nodes", function(e) - if e.type and e.remarks then - local remarks = "" - if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then - remarks = "%s:[%s] " % {translatef(e.type .. e.protocol), e.remarks} - else - if e.use_kcp and e.use_kcp == "1" then - remarks = "%s+%s:[%s] %s" % {e.type, "Kcptun", e.remarks, e.address} - else - remarks = "%s:[%s] %s:%s" % {e.type, e.remarks, e.address, e.port} - end - end - nodes_table[#nodes_table + 1] = { - id = e[".name"], - remarks = remarks - } - end -end) +for k, e in ipairs(api.get_valid_nodes()) do + nodes_table[#nodes_table + 1] = { + id = e[".name"], + remarks = e.remarks_name + } +end local socks_table = {} uci:foreach(appname, "socks", function(s) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua index 893a0ae88d..d2ddedfd4b 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua @@ -1,20 +1,19 @@ local e = require "luci.sys" local net = require "luci.model.network".init() local uci = require "luci.model.uci".cursor() +local api = require "luci.model.cbi.passwall.api.api" local appname = "passwall" local nodes_table = {} -uci:foreach(appname, "nodes", function(e) - if e.type and e.remarks and e.port and e.address and e.address ~= "127.0.0.1" then - if e.address:match("[\u4e00-\u9fa5]") and e.address:find("%.") and e.address:sub(#e.address) ~= "." then - nodes_table[#nodes_table + 1] = { - id = e[".name"], - remarks = "%s:[%s] %s:%s" % {translate(e.type), e.remarks, e.address, e.port}, - obj = e - } - end +for k, e in ipairs(api.get_valid_nodes()) do + if e.node_type == "normal" then + nodes_table[#nodes_table + 1] = { + id = e[".name"], + obj = e, + remarks = e.remarks_name + } end -end) +end m = Map(appname) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua index a7029be285..a14a6f2838 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua @@ -112,16 +112,14 @@ protocol:value("_shunt", translate("Shunt")) protocol:depends("type", "V2ray") local nodes_table = {} -uci:foreach(appname, "nodes", function(e) - if e.type and e.remarks and e.port then - if e.address:match("[\u4e00-\u9fa5]") and e.address:find("%.") and e.address:sub(#e.address) ~= "." then - nodes_table[#nodes_table + 1] = { - id = e[".name"], - remarks = "%s:[%s] %s:%s" % {e.type, e.remarks, e.address, e.port} - } - end +for k, e in ipairs(api.get_valid_nodes()) do + if e.node_type == "normal" then + nodes_table[#nodes_table + 1] = { + id = e[".name"], + remarks = e.remarks_name + } end -end) +end -- 负载均衡列表 balancing_node = s:option(DynamicList, "balancing_node", translate("Load balancing node list"), translate("Load balancing node list, document")) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua index e8de32dc22..e9eddc103b 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua @@ -149,24 +149,4 @@ o:value("big_icon", translate("Big icon")) -- 大图标 o:value("show_check_port", translate("Show node check")) -- 显示节点检测 o:value("show_ip111", translate("Show Show IP111")) -- 显示IP111 -local nodes_table = {} -uci:foreach(appname, "nodes", function(e) - if e.type and e.remarks then - local remarks = "" - if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then - remarks = "%s:[%s] " % {translatef(e.type .. e.protocol), e.remarks} - else - if e.use_kcp and e.use_kcp == "1" then - remarks = "%s+%s:[%s] %s" % {e.type, "Kcptun", e.remarks, e.address} - else - remarks = "%s:[%s] %s:%s" % {e.type, e.remarks, e.address, e.port} - end - end - nodes_table[#nodes_table + 1] = { - id = e[".name"], - remarks = remarks - } - end -end) - return m diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua index 1a974c4fc6..27d8aa9a10 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/v2ray.lua @@ -87,105 +87,9 @@ function gen_config(user) } if user.transit_node and user.transit_node ~= "nil" then - local node = ucic:get_all("passwall", user.transit_node) - if node and node ~= "nil" and node.type and node.type == "V2ray" then - if node.transport == "mkcp" or node.transport == "quic" then - node.stream_security = "none" - end - local transit_node = { - tag = "transit", - protocol = node.protocol, - mux = { - enabled = (node.mux == "1") and true or false, - concurrency = (node.mux_concurrency) and tonumber(node.mux_concurrency) or 8 - }, - -- 底层传输配置 - streamSettings = { - network = node.transport, - security = node.stream_security, - xtlsSettings = (node.stream_security == "xtls") and { - serverName = node.tls_serverName, - allowInsecure = (node.tls_allowInsecure == "1") and true or false - } or nil, - tlsSettings = (node.stream_security == "tls") and { - disableSessionResumption = node.sessionTicket ~= "1" and true or false, - serverName = node.tls_serverName, - allowInsecure = (node.tls_allowInsecure == "1") and true or false - } or nil, - tcpSettings = (node.transport == "tcp") and { - header = { - type = node.tcp_guise, - request = (node.tcp_guise == "http") and { - path = node.tcp_guise_http_path or {"/"}, - headers = { - Host = node.tcp_guise_http_host or {} - } - } or nil - } - } or nil, - kcpSettings = (node.transport == "mkcp") and { - mtu = tonumber(node.mkcp_mtu), - tti = tonumber(node.mkcp_tti), - uplinkCapacity = tonumber(node.mkcp_uplinkCapacity), - downlinkCapacity = tonumber(node.mkcp_downlinkCapacity), - congestion = (node.mkcp_congestion == "1") and true or false, - readBufferSize = tonumber(node.mkcp_readBufferSize), - writeBufferSize = tonumber(node.mkcp_writeBufferSize), - seed = (node.mkcp_seed and node.mkcp_seed ~= "") and node.mkcp_seed or nil, - header = {type = node.mkcp_guise} - } or nil, - wsSettings = (node.transport == "ws") and { - path = node.ws_path or "", - headers = (node.ws_host ~= nil) and {Host = node.ws_host} or nil - } or nil, - httpSettings = (node.transport == "h2") and { - path = node.h2_path, host = node.h2_host - } or nil, - dsSettings = (node.transport == "ds") and { - path = node.ds_path - } or nil, - quicSettings = (node.transport == "quic") and { - security = node.quic_security, - key = node.quic_key, - header = {type = node.quic_guise} - } or nil - }, - settings = { - vnext = (node.protocol == "vmess" or node.protocol == "vless") and { - { - address = node.address, - port = tonumber(node.port), - users = { - { - id = node.uuid, - alterId = tonumber(node.alter_id), - level = node.level and tonumber(node.level) or 0, - security = (node.protocol == "vmess") and node.security or nil, - encryption = node.encryption or "none", - flow = (node.stream_security == "xtls") and node.flow or nil - } - } - } - } or nil, - servers = (node.protocol == "http" or node.protocol == "socks" or node.protocol == "shadowsocks" or node.protocol == "trojan") and { - { - address = node.address, - port = tonumber(node.port), - method = node.v_ss_encrypt_method, - password = node.password or "", - users = (node.username and node.password) and - { - { - user = node.username or "", - pass = node.password or "" - } - } or nil - } - } or nil - } - } - table.insert(outbounds, 1, transit_node) - end + local gen_v2ray = require("luci.model.cbi.passwall.api.gen_v2ray") + local client = gen_v2ray.gen_outbound(ucic:get_all("passwall", user.transit_node), "transit") + table.insert(outbounds, 1, client) end local config = { diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua index 75bcb5479b..e3c0ebfa87 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua @@ -514,14 +514,14 @@ ss_aead_pwd.rmempty = false ss_aead_pwd:depends("ss_aead", "1") local nodes_table = {} -uci:foreach("passwall", "nodes", function(e) - if e.type and e.type == "V2ray" and e.remarks and e.address and e.port then +for k, e in ipairs(api.get_valid_nodes()) do + if e.node_type == "normal" and e.type == "V2ray" then nodes_table[#nodes_table + 1] = { id = e[".name"], - remarks = "%s:[%s] %s:%s" % {e.type, e.remarks, e.address, e.port} + remarks = e.remarks_name } end -end) +end transit_node = s:option(ListValue, "transit_node", translate("transit node")) transit_node:value("nil", translate("Close")) From 94b6a91f111a3557715af9993a0ccaedad246b7d Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Mon, 28 Sep 2020 09:48:26 -1000 Subject: [PATCH 02/36] policycoreutils: add missing gettext dependency Add missing build dependency to both host and target build. The `msgfmt` is required which is missing without gettext-full. Signed-off-by: Paul Spooren --- package/utils/policycoreutils/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/utils/policycoreutils/Makefile b/package/utils/policycoreutils/Makefile index a237542be6..6abb64f102 100644 --- a/package/utils/policycoreutils/Makefile +++ b/package/utils/policycoreutils/Makefile @@ -13,8 +13,8 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/20200710 PKG_HASH:=c889f62ee80f8b6a369469a9b8af51f5b797975aeaa291f5c5960cc12eed1934 PKG_INSTALL:=1 -HOST_BUILD_DEPENDS:=libsemanage/host -PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam +HOST_BUILD_DEPENDS:=libsemanage/host gettext-full/host +PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam gettext-full/host PKG_MAINTAINER:=Thomas Petazzoni PKG_CPE_ID:=cpe:/a:selinuxproject:policycoreutils From a4d582bf10fd89cd6935e9ac3f3c9278d4675e4c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 2 Oct 2020 17:36:16 -0700 Subject: [PATCH 03/36] perf: disable libzstd support libzstd from the packages feed gets picked up. Remove it. Fixes: Package perf is missing dependencies for the following libraries: libzstd.so.1 Signed-off-by: Rosen Penev --- package/devel/perf/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/devel/perf/Makefile b/package/devel/perf/Makefile index aa478a0431..a7b538e7a5 100644 --- a/package/devel/perf/Makefile +++ b/package/devel/perf/Makefile @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=perf PKG_VERSION:=$(LINUX_VERSION) -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_USE_MIPS16:=0 PKG_BUILD_PARALLEL:=1 @@ -48,6 +48,7 @@ MAKE_FLAGS = \ NO_LIBAUDIT=1 \ NO_LIBCRYPTO=1 \ NO_LIBUNWIND=1 \ + NO_LIBZSTD=1 \ NO_LIBCAP=1 \ CROSS_COMPILE="$(TARGET_CROSS)" \ CC="$(TARGET_CC)" \ From 72f6de33cc95158935fe310c93c40f218de8a68c Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Fri, 2 Oct 2020 14:17:48 +0200 Subject: [PATCH 04/36] trace-cmd: disable AUDIT (libaudit library) If you compile first libaudit library and then trace-cmd package, compilations fails with: Package trace-cmd is missing dependencies for the following libraries: libaudit.so.1 If you enable libaudit for trace-cmd, it will show system name calls while using command profile. Try to be slim as much as possible - libaudit .ipk has 42,4 kB. Signed-off-by: Josef Schlehofer --- package/devel/trace-cmd/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/devel/trace-cmd/Makefile b/package/devel/trace-cmd/Makefile index 25831d8b1b..d1f73ae9bb 100644 --- a/package/devel/trace-cmd/Makefile +++ b/package/devel/trace-cmd/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=trace-cmd PKG_VERSION:=v2.6.1 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git/snapshot/ @@ -31,6 +31,7 @@ endef MAKE_FLAGS += \ NO_PYTHON=1 \ + NO_AUDIT=1 \ prefix=/usr PLUGINS_DIR := $(PKG_INSTALL_DIR)/usr/lib/trace-cmd/plugins From 814c8adef2b19cf02aeeea99748bfbc3ed9b5f04 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Tue, 8 Oct 2019 20:06:57 +0200 Subject: [PATCH 05/36] kernel: fix name of CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM CONFIG_SND_SOC_DMAENGINE_PCM was removed and replaced with CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM seven years ago, see: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=28c4468b00a1e55e08cc20117de968f7c6275441 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b7ae6f31d8243ec684af16bc5c763eccdfabaec0 Signed-off-by: Andre Heider --- package/kernel/linux/modules/sound.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/kernel/linux/modules/sound.mk b/package/kernel/linux/modules/sound.mk index a68595b03f..d69590837b 100644 --- a/package/kernel/linux/modules/sound.mk +++ b/package/kernel/linux/modules/sound.mk @@ -192,10 +192,10 @@ define KernelPackage/sound-soc-core KCONFIG:= \ CONFIG_SND_SOC \ CONFIG_SND_SOC_ADI=n \ - CONFIG_SND_SOC_DMAENGINE_PCM=y \ + CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y \ CONFIG_SND_SOC_ALL_CODECS=n FILES:=$(LINUX_DIR)/sound/soc/snd-soc-core.ko - AUTOLOAD:=$(call AutoLoad,55, snd-soc-core) + AUTOLOAD:=$(call AutoLoad,55,snd-soc-core) $(call AddDepends/sound) endef From b69fb2bf2f58c2a8c640ad5d96af8188f8249682 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Sun, 27 Sep 2020 15:21:31 +0200 Subject: [PATCH 06/36] ath79: fix rssi-low LED for My Net Range Extender The LED color was missing in 01_leds. Fixes: 745dee11ac78 ("ath79: add support for WD My Net Wi-Fi Range Extender") Signed-off-by: Adrian Schmutzler --- target/linux/ath79/generic/base-files/etc/board.d/01_leds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 5ae656f846..8bda7c4f2e 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -263,7 +263,7 @@ ubnt,nanostation-ac) wd,mynet-wifi-rangeextender) ucidef_set_led_netdev "lan" "LAN" "$boardname:green:lan" "eth0" ucidef_set_rssimon "wlan0" "200000" "1" - ucidef_set_led_rssi "rssilow" "RSSILOW" "$boardname:rssi-low" "wlan0" "1" "100" + ucidef_set_led_rssi "rssilow" "RSSILOW" "$boardname:blue:rssi-low" "wlan0" "1" "100" ucidef_set_led_rssi "rssimedium" "RSSIMED" "$boardname:blue:rssi-med" "wlan0" "33" "100" ucidef_set_led_rssi "rssihigh" "RSSIMAX" "$boardname:blue:rssi-max" "wlan0" "66" "100" ;; From c560d703786106b7db77a0a630d8bdeaf76da510 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 17 Sep 2020 12:09:23 +0200 Subject: [PATCH 07/36] mac80211: do not allow bigger VHT MPDUs than the hardware supports Signed-off-by: Felix Fietkau (cherry picked from commit caf727767ab5c8f8d884ef458c74726a8e610d96) [Refreshed patch] Signed-off-by: Koen Vandeputte --- ...allow-bigger-VHT-MPDUs-than-the-hard.patch | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 package/kernel/mac80211/patches/subsys/331-mac80211-do-not-allow-bigger-VHT-MPDUs-than-the-hard.patch diff --git a/package/kernel/mac80211/patches/subsys/331-mac80211-do-not-allow-bigger-VHT-MPDUs-than-the-hard.patch b/package/kernel/mac80211/patches/subsys/331-mac80211-do-not-allow-bigger-VHT-MPDUs-than-the-hard.patch new file mode 100644 index 0000000000..ce39fe0d8b --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/331-mac80211-do-not-allow-bigger-VHT-MPDUs-than-the-hard.patch @@ -0,0 +1,34 @@ +From: Felix Fietkau +Date: Thu, 17 Sep 2020 12:07:19 +0200 +Subject: [PATCH] mac80211: do not allow bigger VHT MPDUs than the hardware + supports + +Limit maximum VHT MPDU size by local capability + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/vht.c ++++ b/net/mac80211/vht.c +@@ -170,10 +170,7 @@ ieee80211_vht_cap_ie_to_sta_vht_cap(stru + /* take some capabilities as-is */ + cap_info = le32_to_cpu(vht_cap_ie->vht_cap_info); + vht_cap->cap = cap_info; +- vht_cap->cap &= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 | +- IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | +- IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | +- IEEE80211_VHT_CAP_RXLDPC | ++ vht_cap->cap &= IEEE80211_VHT_CAP_RXLDPC | + IEEE80211_VHT_CAP_VHT_TXOP_PS | + IEEE80211_VHT_CAP_HTC_VHT | + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK | +@@ -182,6 +179,9 @@ ieee80211_vht_cap_ie_to_sta_vht_cap(stru + IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | + IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN; + ++ vht_cap->cap |= min_t(u32, cap_info & IEEE80211_VHT_CAP_MAX_MPDU_MASK, ++ own_cap.cap & IEEE80211_VHT_CAP_MAX_MPDU_MASK); ++ + /* and some based on our own capabilities */ + switch (own_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { + case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: From d6860f8f9a66ee4046d60c3abf03ae5b9aeeddab Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Fri, 31 Jan 2020 15:22:54 +0100 Subject: [PATCH 08/36] base-files: diag: restore default trigger for 'boot' LED For devices without a dedicated 'diag' LED, we use sometimes one of other LEDs for indicating at least 'boot', 'failsafe' and 'upgrade' stages. In some cases, at the same time these LEDs have defined default triggers in DTS using 'linux,default-trigger' property. Current 'diag' setup removes the trigger and turns off 'boot' LED after bootup. This patch extends 'diag.sh' and 'leds.sh' scripts to make sure default trigger defined in DTS is restored for 'diag' LED which isn't used for indicating 'running' stage. Acked-by: Adrian Schmutzler Signed-off-by: Piotr Dymacz --- package/base-files/Makefile | 2 +- package/base-files/files/etc/diag.sh | 2 ++ .../base-files/files/lib/functions/leds.sh | 29 +++++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 4dec9291d7..74ca8426a3 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=202 +PKG_RELEASE:=203 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/diag.sh b/package/base-files/files/etc/diag.sh index 8eb36c6feb..37a8ec758e 100755 --- a/package/base-files/files/etc/diag.sh +++ b/package/base-files/files/etc/diag.sh @@ -37,6 +37,8 @@ set_led_state() { ;; done) status_led_off + [ "$status_led" != "$running" ] && \ + status_led_restore_trigger "boot" [ -n "$running" ] && { status_led="$running" status_led_on diff --git a/package/base-files/files/lib/functions/leds.sh b/package/base-files/files/lib/functions/leds.sh index 5b51e70b0a..14baeb37b4 100755 --- a/package/base-files/files/lib/functions/leds.sh +++ b/package/base-files/files/lib/functions/leds.sh @@ -1,17 +1,25 @@ #!/bin/sh # Copyright (C) 2013 OpenWrt.org -get_dt_led() { - local label +get_dt_led_path() { local ledpath local basepath="/proc/device-tree" local nodepath="$basepath/aliases/led-$1" [ -f "$nodepath" ] && ledpath=$(cat "$nodepath") + [ -n "$ledpath" ] && ledpath="$basepath$ledpath" + + echo "$ledpath" +} + +get_dt_led() { + local label + local ledpath=$(get_dt_led_path $1) + [ -n "$ledpath" ] && \ - label=$(cat "$basepath$ledpath/label" 2>/dev/null) || \ - label=$(cat "$basepath$ledpath/chan-name" 2>/dev/null) || \ - label=$(basename "$basepath$ledpath") + label=$(cat "$ledpath/label" 2>/dev/null) || \ + label=$(cat "$ledpath/chan-name" 2>/dev/null) || \ + label=$(basename "$ledpath") echo "$label" } @@ -36,6 +44,17 @@ led_off() { led_set_attr $1 "brightness" 0 } +status_led_restore_trigger() { + local trigger + local ledpath=$(get_dt_led_path $1) + + [ -n "$ledpath" ] && \ + trigger=$(cat "$ledpath/linux,default-trigger" 2>/dev/null) + + [ -n "$trigger" ] && \ + led_set_attr "$(get_dt_led $1)" "trigger" "$trigger" +} + status_led_set_timer() { led_timer $status_led "$1" "$2" [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2" From cbe99d64abeefc64dd1f5da80d18cccd330a8859 Mon Sep 17 00:00:00 2001 From: Michael Heimpold Date: Tue, 2 Apr 2019 21:48:11 +0200 Subject: [PATCH 09/36] base-files/hotplug: fix dedicated group for tty devices Commit 124ab1dc0a and 5523ee3459 introduced the assignment of the group "tty" to /dev/tty* devices in order to support unprivileged user access to serial devices. However, due to an improperly rebased commit this feature broke. This patch restores the lost hunk in hotplug.json file to re-introduce this feature and also renames the existing "tty" group to "dialout" as this is the more typical name for such a group on desktop systems. Fixes: 5209cfa534 ("procd: fix hotplug.json syntax") Signed-off-by: Michael Heimpold Acked-by: Jo-Philipp Wich Part of the commit content is already in system/procd/files. --- package/base-files/files/etc/group | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group index e8e2adf4ac..5b06dc6db9 100644 --- a/package/base-files/files/etc/group +++ b/package/base-files/files/etc/group @@ -1,8 +1,8 @@ root:x:0: daemon:x:1: adm:x:4: -tty:x:5: mail:x:8: +dialout:x:20: audio:x:29: www-data:x:33: ftp:x:55: From 341548d8b8299bbc0a64aceb924311f25c65d475 Mon Sep 17 00:00:00 2001 From: Arthur Skowronek Date: Wed, 30 Jan 2019 14:58:47 +0100 Subject: [PATCH 10/36] base-files: add service_stopped as a post stop hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose of these changes is to introduce a hook for post service shutdown in a similar fashion to the existing hook service_started. I found it to be useful to specify a hook that is called once the service has been stopped and not before the service is stopped like the stop_service hook does. The concrete use case I have for this is that I'm running a binary that takes over the hardware watchdog timer. Said binary unfortunately can not use ubus directly to tell procd to hand over the watchdog timer so this has to be done in the service file for the binary in question. In order to support a clean handover of the watchdog timer back to procd, the service init script has to dispatch the ubus invocation once the binary in question has been stopped. Signed-off-by: Arthur Skowronek Signed-off-by: Petr Štetiar [added commit message, use the same form as other hooks] --- package/base-files/files/etc/rc.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index d9773a0c5a..75dbeedf34 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -131,6 +131,9 @@ ${INIT_TRACE:+set -x} procd_lock stop_service "$@" procd_kill "$(basename ${basescript:-$initscript})" "$1" + if eval "type service_stopped" 2>/dev/null >/dev/null; then + service_stopped + fi } reload() { From 81f41e0d582c4650c6f9d85c0ac098d43259ffd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 23 Jul 2019 12:06:29 +0200 Subject: [PATCH 11/36] base-files: implement generic service_running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DRY is good, otherwise we're going to suffer with a copy&paste disease in the init scripts. Signed-off-by: Petr Štetiar --- package/base-files/files/etc/rc.common | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index 75dbeedf34..37adab0c54 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -95,7 +95,9 @@ service_data() { } service_running() { - return 0 + local service="${1:-$(basename $initscript)}" + local instance="${2:-*}" + procd_running "$service" "$instance" "$@" } ${INIT_TRACE:+set -x} @@ -104,6 +106,9 @@ ${INIT_TRACE:+set -x} [ -n "$USE_PROCD" ] && { EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace" + EXTRA_HELP="\ + running Check if service is running + " . $IPKG_INSTROOT/lib/functions/procd.sh basescript=$(readlink "$initscript") From 06a87652ff2ba45f46d46bbdf3c8acde5a7efee0 Mon Sep 17 00:00:00 2001 From: Luiz Angelo Daros de Luca Date: Tue, 11 Sep 2018 22:35:09 -0300 Subject: [PATCH 12/36] base-files,procd: add generic service status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a default status action for init.d scripts. procd "service status" will return: 0) for loaded services (even if disabled by conf or dead) 3) for inactive services 4) when filtering a non-existing instance Signed-off-by: Luiz Angelo Daros de Luca [rebased, cleaned up] Signed-off-by: Petr Štetiar Part of the commit content is already in system/procd/files. --- package/base-files/files/etc/rc.common | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index 37adab0c54..d3fa3be505 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -105,9 +105,10 @@ ${INIT_TRACE:+set -x} . "$initscript" [ -n "$USE_PROCD" ] && { - EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace" + EXTRA_COMMANDS="${EXTRA_COMMANDS} running status trace" EXTRA_HELP="\ running Check if service is running + status Service status " . $IPKG_INSTROOT/lib/functions/procd.sh @@ -153,6 +154,14 @@ ${INIT_TRACE:+set -x} running() { service_running "$@" } + + status() { + if eval "type status_service" 2>/dev/null >/dev/null; then + status_service "$@" + else + _procd_status "$(basename ${basescript:-$initscript})" "$1" + fi + } } ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}" From f53e2b1bd62b50f6e8026a538461a860c961fa32 Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Tue, 12 Nov 2019 15:54:53 +0100 Subject: [PATCH 13/36] base-files: rc.common: fix missing EXTRA_HELP texts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit ed5b9129d7a4 ("base-files: implement generic service_running") has added EXTRA_HELP variable, thus overriding already available EXTRA_HELP text available in other init scripts, resulting in the missing help text from services like dropbear for example. So fix this regression by appending EXTRA_HELP text provided by the other init scripts into the one provided by the script itself. Fixes: ed5b9129d7a4 ("base-files: implement generic service_running") Signed-off-by: Peter Stadler [commit title/description facelift, fixes tag, fixed From:, pkg bump] Signed-off-by: Petr Štetiar --- package/base-files/Makefile | 2 +- package/base-files/files/etc/rc.common | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 74ca8426a3..b0951747de 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=203 +PKG_RELEASE:=204 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index d3fa3be505..dbe26ec3bd 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -109,7 +109,7 @@ ${INIT_TRACE:+set -x} EXTRA_HELP="\ running Check if service is running status Service status - " +${EXTRA_HELP}" . $IPKG_INSTROOT/lib/functions/procd.sh basescript=$(readlink "$initscript") From f850950e9129dbed474f1d0cc94e0393afa23bd5 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Sun, 13 Jan 2019 02:14:22 +0800 Subject: [PATCH 14/36] procd: Add wrapper for uci_validate_section() This adds a wrapper (uci_load_validate) for uci_validate_section() that allows callers (through a callback function) to access the values set by uci_validate_section(), without having to manually declare a (potentially long) list of local variables. The callback function receives two arguments when called, the config section name and the return value of uci_validate_section(). If no callback function is given, then the wrapper exits with the value returned by uci_validate_section(). This also updates several init scripts to use the new wrapper function. Signed-off-by: Jeffery To Part of the commit content is already in dropbear/files, procd/files, ubox/files and busybox/files. --- package/base-files/files/etc/init.d/system | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system index 531aa8cbc5..a98a972469 100755 --- a/package/base-files/files/etc/init.d/system +++ b/package/base-files/files/etc/init.d/system @@ -6,7 +6,7 @@ USE_PROCD=1 validate_system_section() { - uci_validate_section system system "${1}" \ + uci_load_validate system system "$1" "$2" \ 'hostname:string:OpenWrt' \ 'conloglevel:uinteger' \ 'buffersize:uinteger' \ @@ -15,11 +15,7 @@ validate_system_section() } system_config() { - local cfg="$1" - - local hostname conloglevel buffersize timezone zonename - - validate_system_section "${1}" || { + [ "$2" = 0 ] || { echo "validation failed" return 1 } @@ -36,7 +32,7 @@ system_config() { reload_service() { config_load system - config_foreach system_config system + config_foreach validate_system_section system system_config } service_triggers() From 8093296e7a1eb0965569fc2349e7c28996c6acda Mon Sep 17 00:00:00 2001 From: Val Kulkov Date: Mon, 7 Oct 2019 12:06:52 -0400 Subject: [PATCH 15/36] base-files: coreutil-date breaks setting kernel timezone "coreutil-date" package from the packages feed replaces the Busybox date applet by symlinking /usr/bin/gnu-date to /bin/date. This prevents the system init script from setting kernel timezone because the GNU date utility does not provide such functionality: root@OpenWrt:~# date -k date: invalid option -- 'k' Try 'date --help' for more information. A specific reference to the Busybox date applet prevents alternative date utilities from breaking the system init script. Signed-off-by: Val Kulkov --- package/base-files/files/etc/init.d/system | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system index a98a972469..0e33c522b4 100755 --- a/package/base-files/files/etc/init.d/system +++ b/package/base-files/files/etc/init.d/system @@ -27,7 +27,7 @@ system_config() { ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ # apply timezone to kernel - date -k + busybox date -k } reload_service() { From 350a530b1841d63a9d9c3e9a131e6c2361808e3e Mon Sep 17 00:00:00 2001 From: Joseph Tingiris Date: Sun, 13 Jan 2019 16:43:48 -0500 Subject: [PATCH 16/36] base-files: change boot & umount STOP indexes This patch is in a series to allow additional STOP indexes after umount, so that other block devices may stop cleanly. boot is now STOP=90 umount is now STOP=90 Signed-off-by: Joseph Tingiris Signed-off-by: Christian Lamparter --- package/base-files/Makefile | 2 +- package/base-files/files/etc/init.d/umount | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index b0951747de..0f6881f34d 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=204 +PKG_RELEASE:=205 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount index 349b2b3264..57a4a6d90c 100755 --- a/package/base-files/files/etc/init.d/umount +++ b/package/base-files/files/etc/init.d/umount @@ -1,7 +1,7 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2006 OpenWrt.org -STOP=99 +STOP=90 stop() { sync /bin/umount -a -d -r From 1bd5c9063cbb5182ae905744abb0917aca0abf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 29 Jun 2019 11:10:19 +0200 Subject: [PATCH 17/36] base-files: supress service restart of umount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restart is in default implemented so it calls stop and start. This is pretty unsafe to call on umount service. This service should not do anything on restart the same way as on start. Only use of this service is on stop. Signed-off-by: Karel Kočí --- package/base-files/files/etc/init.d/umount | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount index 57a4a6d90c..b764ae1582 100755 --- a/package/base-files/files/etc/init.d/umount +++ b/package/base-files/files/etc/init.d/umount @@ -2,6 +2,11 @@ # Copyright (C) 2006 OpenWrt.org STOP=90 + +restart() { + : +} + stop() { sync /bin/umount -a -d -r From 54b983ee6067522346bd2b781ef9b1c4dc24929f Mon Sep 17 00:00:00 2001 From: Alan Swanson Date: Wed, 29 May 2019 11:28:33 +0100 Subject: [PATCH 18/36] base-files: add reboot only button handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For devices such as BTHOMEHUBV5A with both reset and restart buttons, its easily accessible restart button has been assigned to KEY_POWER power script to poweroff preventing accidental (or malicious) factory resets by KEY_RESTART reset script. However an easily accessible button immediately powering off the device is also undesirable. Fixes: FS#1965 Signed-off-by: Alan Swanson Signed-off-by: Petr Štetiar [long line wrap] --- package/base-files/files/etc/rc.button/reboot | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 package/base-files/files/etc/rc.button/reboot diff --git a/package/base-files/files/etc/rc.button/reboot b/package/base-files/files/etc/rc.button/reboot new file mode 100755 index 0000000000..cd547e3329 --- /dev/null +++ b/package/base-files/files/etc/rc.button/reboot @@ -0,0 +1,12 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +if [ "$SEEN" -ge 5 ] +then + echo "REBOOT" > /dev/console + sync + reboot +fi + +return 0 From e7878a97a4a510f8312576ec79c0262c607da9eb Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 7 Nov 2019 22:29:21 +0100 Subject: [PATCH 19/36] base-files: remove shebang from uci-defaults files uci-defaults are sourced and non-executable, so they do not require a shebang. While at it, apply consistent naming scheme. Signed-off-by: Adrian Schmutzler --- package/base-files/Makefile | 2 +- package/base-files/files/etc/uci-defaults/10_migrate-shadow | 2 -- .../base-files/files/etc/uci-defaults/12_network-generate-ula | 2 -- .../etc/uci-defaults/{13_fix_group_user => 13_fix-group-user} | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) rename package/base-files/files/etc/uci-defaults/{13_fix_group_user => 13_fix-group-user} (94%) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 0f6881f34d..a1c7b826cd 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=205 +PKG_RELEASE:=206 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/uci-defaults/10_migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow index a354844fe4..481444f35e 100755 --- a/package/base-files/files/etc/uci-defaults/10_migrate-shadow +++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -1,5 +1,3 @@ -#!/bin/sh - ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)" diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula index 8871427c60..19d7ed7f2e 100755 --- a/package/base-files/files/etc/uci-defaults/12_network-generate-ula +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -1,5 +1,3 @@ -#!/bin/sh - [ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0 r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"') diff --git a/package/base-files/files/etc/uci-defaults/13_fix_group_user b/package/base-files/files/etc/uci-defaults/13_fix-group-user similarity index 94% rename from package/base-files/files/etc/uci-defaults/13_fix_group_user rename to package/base-files/files/etc/uci-defaults/13_fix-group-user index e6dae2419f..bf9febdfe4 100755 --- a/package/base-files/files/etc/uci-defaults/13_fix_group_user +++ b/package/base-files/files/etc/uci-defaults/13_fix-group-user @@ -1,5 +1,3 @@ -#!/bin/sh - . /lib/functions.sh for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do From b2d4795acee06abed1143fe8d5d1944219f536ed Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Sun, 10 May 2020 16:47:46 +0200 Subject: [PATCH 20/36] base-files: replace backticks by $(...) This replaces deprecated backticks by more versatile $(...) syntax. This does not touch lib/upgrade/nand.sh, as there replacement is not trivial. Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/board_detect | 2 +- package/base-files/files/etc/uci-defaults/13_fix-group-user | 2 +- package/base-files/files/lib/preinit/30_failsafe_wait | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/base-files/files/bin/board_detect b/package/base-files/files/bin/board_detect index 441db6a08f..840bd0178d 100755 --- a/package/base-files/files/bin/board_detect +++ b/package/base-files/files/bin/board_detect @@ -5,7 +5,7 @@ CFG=$1 [ -n "$CFG" ] || CFG=/etc/board.json [ -d "/etc/board.d/" -a ! -s "$CFG" ] && { - for a in `ls /etc/board.d/*`; do + for a in $(ls /etc/board.d/*); do [ -x $a ] || continue; $(. $a) done diff --git a/package/base-files/files/etc/uci-defaults/13_fix-group-user b/package/base-files/files/etc/uci-defaults/13_fix-group-user index bf9febdfe4..74f501e8f7 100755 --- a/package/base-files/files/etc/uci-defaults/13_fix-group-user +++ b/package/base-files/files/etc/uci-defaults/13_fix-group-user @@ -1,6 +1,6 @@ . /lib/functions.sh -for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do +for file in $(grep -sl Require-User /usr/lib/opkg/info/*.control); do file="${file##*/}" file="${file%.control}" add_group_and_user "${file}" diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index dd9c7e2b59..7dc29540b2 100755 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -92,7 +92,7 @@ failsafe_wait() { preinit_net_echo "Please press button now to enter failsafe" pi_failsafe_net_message=false fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true - [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -" + [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "$(cat /tmp/failsafe_button)" was pressed -" [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe fi } From ac9b04e2fa8f997b0c76af2344978542573b45fc Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Fri, 28 Jun 2019 12:59:19 +0200 Subject: [PATCH 21/36] base-files: add network_get_uptime() to /lib/functions/network.sh Add missing ubus api call for uptime value. Signed-off-by: Florian Eckert --- package/base-files/Makefile | 2 +- package/base-files/files/lib/functions/network.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index a1c7b826cd..af83ac1068 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=206 +PKG_RELEASE:=207 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 8453e4be07..055f18c11e 100755 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -271,6 +271,11 @@ network_is_up() # 2: interface network_get_protocol() { __network_ifstatus "$1" "$2" ".proto"; } +# determine the uptime of the given logical interface +# 1: destination variable +# 2: interface +network_get_uptime() { __network_ifstatus "$1" "$2" ".uptime"; } + # determine the metric of the given logical interface # 1: destination variable # 2: interface From 49357cc5bfd2275a33303aa6a4304bf5cbe02bea Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 7 Apr 2020 14:03:50 +0200 Subject: [PATCH 22/36] base-files: add enabled commands to service rc.common Add missing enbaled command help output. Signed-off-by: Florian Eckert --- package/base-files/Makefile | 2 +- package/base-files/files/etc/rc.common | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index af83ac1068..e3065770cf 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=207 +PKG_RELEASE:=208 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index dbe26ec3bd..7c11544405 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -73,6 +73,7 @@ Available commands: reload Reload configuration files (or restart if service does not implement reload) enable Enable service autostart disable Disable service autostart + enabled Check if service is started on boot $EXTRA_HELP EOF } From 8205266f875c013e2f3e6f66feeb8e1b0d723546 Mon Sep 17 00:00:00 2001 From: Thomas Albers Date: Wed, 3 Jun 2020 13:42:47 +0200 Subject: [PATCH 23/36] base-files: fix LED IDE trigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes the ide-disk LED trigger to the generic disk-activity as ide-disk trigger was removed in upstream commit eb25cb9956cc ("leds: convert IDE trigger to common disk trigger"). Signed-off-by: Thomas Albers [split into separate commit, commit description facelift] Signed-off-by: Petr Štetiar --- package/base-files/files/lib/functions/uci-defaults.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 81f26465fa..946ff440fd 100755 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -391,7 +391,7 @@ ucidef_set_led_gpio() { } ucidef_set_led_ide() { - _ucidef_set_led_trigger "$1" "$2" "$3" ide-disk + _ucidef_set_led_trigger "$1" "$2" "$3" disk-activity } ucidef_set_led_netdev() { From 5f00c3dc56ce1fbb59b7b255a4c5903976cf04a5 Mon Sep 17 00:00:00 2001 From: Thomas Albers Date: Wed, 15 Apr 2020 18:53:13 -0500 Subject: [PATCH 24/36] linux/generic: remove obsolete config option LEDS_TRIGGER_IDE_DISK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kernel config option LEDS_TRIGGER_IDE_DISK was renamed in kernel 4.8 to CONFIG_LEDS_TRIGGER_DISK in upstream commit eb25cb9956cc ("leds: convert IDE trigger to common disk trigger"). Removing it as it should be added only on targets which has usage for this trigger. Signed-off-by: Thomas Albers [commit description facelift] Signed-off-by: Petr Štetiar --- target/linux/generic/config-4.14 | 1 - target/linux/generic/config-4.19 | 1 - target/linux/generic/config-4.9 | 1 - 3 files changed, 3 deletions(-) diff --git a/target/linux/generic/config-4.14 b/target/linux/generic/config-4.14 index 396a49f015..f5069e349c 100644 --- a/target/linux/generic/config-4.14 +++ b/target/linux/generic/config-4.14 @@ -2446,7 +2446,6 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y # CONFIG_LEDS_TRIGGER_DISK is not set # CONFIG_LEDS_TRIGGER_GPIO is not set # CONFIG_LEDS_TRIGGER_HEARTBEAT is not set -# CONFIG_LEDS_TRIGGER_IDE_DISK is not set # CONFIG_LEDS_TRIGGER_MTD is not set CONFIG_LEDS_TRIGGER_NETDEV=y # CONFIG_LEDS_TRIGGER_ONESHOT is not set diff --git a/target/linux/generic/config-4.19 b/target/linux/generic/config-4.19 index b67dd7adc2..452f17eb26 100644 --- a/target/linux/generic/config-4.19 +++ b/target/linux/generic/config-4.19 @@ -2560,7 +2560,6 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y # CONFIG_LEDS_TRIGGER_DISK is not set # CONFIG_LEDS_TRIGGER_GPIO is not set # CONFIG_LEDS_TRIGGER_HEARTBEAT is not set -# CONFIG_LEDS_TRIGGER_IDE_DISK is not set # CONFIG_LEDS_TRIGGER_MTD is not set CONFIG_LEDS_TRIGGER_NETDEV=y # CONFIG_LEDS_TRIGGER_ONESHOT is not set diff --git a/target/linux/generic/config-4.9 b/target/linux/generic/config-4.9 index 79fab3fe16..9f1da66c7d 100644 --- a/target/linux/generic/config-4.9 +++ b/target/linux/generic/config-4.9 @@ -2197,7 +2197,6 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y # CONFIG_LEDS_TRIGGER_DISK is not set # CONFIG_LEDS_TRIGGER_GPIO is not set # CONFIG_LEDS_TRIGGER_HEARTBEAT is not set -# CONFIG_LEDS_TRIGGER_IDE_DISK is not set # CONFIG_LEDS_TRIGGER_MTD is not set CONFIG_LEDS_TRIGGER_NETDEV=y # CONFIG_LEDS_TRIGGER_ONESHOT is not set From 2bb829ee47defbbdbeea266af7bf87fa81d2acf7 Mon Sep 17 00:00:00 2001 From: Sergey Ryazanov Date: Fri, 24 Apr 2020 17:04:14 +0300 Subject: [PATCH 25/36] base-files: prevent issues w/ overlay on powerloss after sysupgrade Due to filesystem write caching the old configuration data could stay out of flash for a long time during a first boot after the sysupgrade. Power loss during this period could damage the overlay data and even make device inaccessable via the network. Fix this by syncing data to a flash as soon as the previous configuration will be unpacked after the sysupgrade. Also sync the FS state after the sysupgrade.tgz archive removing to prevent duplicative extraction of a previous configuration. Tested with AMD Geode based board. Signed-off-by: Sergey Ryazanov --- package/base-files/files/etc/init.d/done | 2 +- package/base-files/files/lib/preinit/80_mount_root | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/etc/init.d/done b/package/base-files/files/etc/init.d/done index 374353a23c..32d6118df7 100755 --- a/package/base-files/files/etc/init.d/done +++ b/package/base-files/files/etc/init.d/done @@ -4,7 +4,7 @@ START=95 boot() { mount_root done - rm -f /sysupgrade.tgz + rm -f /sysupgrade.tgz && sync # process user commands [ -f /etc/rc.local ] && { diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root index f3fe788e19..265a3f18df 100755 --- a/package/base-files/files/lib/preinit/80_mount_root +++ b/package/base-files/files/lib/preinit/80_mount_root @@ -9,6 +9,8 @@ do_mount_root() { echo "- config restore -" cd / tar xzf /sysupgrade.tgz + # Prevent configuration corruption on a power loss + sync } } From 37613d1ae4475e09e900a41f6676c92aaf445337 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 10 Sep 2020 17:24:52 +0200 Subject: [PATCH 26/36] base-files: drop default setup for vconfig vconfig has been disabled by default since 2015 [1] and there are no remaining uses in entire OpenWrt trunk. However, we still set up a specific name_type for it during boot. While this setup is properly implemented to be only triggered when vconfig is present, it still seems anachronistic and unnecessary to set up a standard for a tool that is not used anymore. Therefore, this removes the set_name_type initialization and leaves it for those people actually using the tool to configure it as needed. [1] 899a23227e55 ("busybox: improve applets & deprecate ifconfig, route") Signed-off-by: Adrian Schmutzler --- package/base-files/Makefile | 2 +- package/base-files/files/etc/init.d/boot | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index e3065770cf..ec40c79f2a 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=208 +PKG_RELEASE:=209 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index 45d72b13ef..5f85ab8a7e 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -20,7 +20,6 @@ uci_apply_defaults() { boot() { [ -f /proc/mounts ] || /sbin/mount_root [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc - [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD mkdir -p /var/run mkdir -p /var/log From dd5236d4b7258f22258dbec004af1aba70dada34 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 4 Jul 2019 23:28:44 +0200 Subject: [PATCH 27/36] base-files: Really check path in get_mac_binary Currently, path argument is only checked for being not empty. This changes behavior to actually check whether path exists. Signed-off-by: Adrian Schmutzler --- package/base-files/files/lib/functions/system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index 7ed62804a0..df671465be 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -4,7 +4,7 @@ get_mac_binary() { local path="$1" local offset="$2" - if [ -z "$path" ]; then + if [ -e "$path" ]; then echo "get_mac_binary: file $path not found!" >&2 return fi From c731bccc2a88d1d01d754aad59036dce4ae4e1d0 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 8 Jul 2019 10:17:28 +0200 Subject: [PATCH 28/36] base-files: Fix path check in get_mac_binary Logic was inverted when changing from string check to file check. Fix it. Fixes: 8592602d0a88 ("base-files: Really check path in get_mac_binary") Reported-by: Matthias Schiffer Signed-off-by: Adrian Schmutzler --- package/base-files/files/lib/functions/system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index df671465be..9b9d03df7b 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -4,7 +4,7 @@ get_mac_binary() { local path="$1" local offset="$2" - if [ -e "$path" ]; then + if ! [ -e "$path" ]; then echo "get_mac_binary: file $path not found!" >&2 return fi From c1b72b817844d8152d99210942244231c3f5bf32 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 5 Sep 2019 13:29:37 +0200 Subject: [PATCH 29/36] base-files: use get_mac_binary() in mtd_get_mac_binary_ubi() The actual retrieval of the MAC address in mtd_get_mac_binary_ubi() is the same as in get_mac_binary(). Thus, use the latter function in the former to reduce duplicate code. This will also allow to benefit from the enhanced path check there and bring mtd_get_mac_binary_ubi() more in line with the similar mtd_get_mac_binary(). Signed-off-by: Adrian Schmutzler --- package/base-files/files/lib/functions/system.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index 9b9d03df7b..dceb66a851 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -79,12 +79,7 @@ mtd_get_mac_binary_ubi() { local ubidev=$(nand_find_ubi $CI_UBIPART) local part=$(nand_find_volume $ubidev $1) - if [ -z "$part" ]; then - echo "mtd_get_mac_binary: ubi volume $mtdname not found!" >&2 - return - fi - - hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' /dev/$part 2>/dev/null + get_mac_binary "/dev/$part" "$offset" } mtd_get_part_size() { From ba5180c7474c590fadeaa501b3ee2410425f8b2a Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 15 Aug 2019 15:13:21 +0200 Subject: [PATCH 30/36] base-files: add function to retrieve label MAC address To refer to the MAC address on a device's label, one can specify the alias label-mac-device in the DTS which should point to the bearer of the corresponding MAC address. With the function get_mac_label, the user can retrieve then retrieve this address and use it as a value that uniquely identifies his device. This is severely helpful for several downstream functionalities, e.g. define MAC addresses of custom netifs or change the SSID to be easily recognizable. Signed-off-by: Adrian Schmutzler --- package/base-files/files/lib/functions/system.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index dceb66a851..c372d37e38 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -12,6 +12,16 @@ get_mac_binary() { hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null } +get_mac_label() { + local basepath="/proc/device-tree" + local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)" + local macaddr + + [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) + [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null) + echo $macaddr +} + find_mtd_chardev() { local INDEX=$(find_mtd_index "$1") local PREFIX=/dev/mtd From a34c043890a4521b41869a2fb41909f02809df9f Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Thu, 15 Aug 2019 15:13:27 +0200 Subject: [PATCH 31/36] base-files: provide option to specify label MAC address in board.d For many devices, MAC addresses cannot be retrieved via the device tree alias. To still provide the label MAC address for those, this implements a second mechanism that will put the address into uci config. Note that this stores the actual MAC address, whereas in DTS we reference the bearing device. This is based on the work of Rosy Song Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/config_generate | 6 ++++++ package/base-files/files/lib/functions/system.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 91396fb75d..a72702492f 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -20,6 +20,7 @@ generate_static_network() { uci -q batch <<-EOF delete network.globals set network.globals='globals' + set network.globals.ula_prefix='auto' EOF } @@ -256,6 +257,11 @@ generate_static_system() { uci -q set "system.@system[-1].hostname=$hostname" fi + local label_macaddr + if json_get_var label_macaddr label_macaddr; then + uci -q set "system.@system[-1].label_macaddr=$label_macaddr" + fi + if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index c372d37e38..6ff1c68577 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -19,6 +19,7 @@ get_mac_label() { [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null) + [ -n "$macaddr" ] || macaddr=$(uci -q get system.@system[0].label_macaddr) echo $macaddr } From 1398716680c74159393312137e3bc9bbeaa032f9 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 4 Nov 2019 20:44:41 +0100 Subject: [PATCH 32/36] base-files: don't store label MAC address in uci system config If set, label MAC address is available from one of two sources, device tree or board.json. So far, the function get_mac_label was meant for retrieving the address, while an option in uci system config was specified only for case 2 (board.json). The uci config option has several drawbacks: - it is only used for a fraction of devices (those not in DT) - label MAC address is a device property, while config implies user interaction - label_macaddr option will only be set if /etc/config/system does not exist (i.e. only for new installations) Thus, this patch changes the behavior of get_mac_label: Instead of writing the value in board.json to uci system config and reading from this location afterwards, get_mac_label now extracts data from board.json directly. The uci config option won't be used anymore. In addition, two utility functions for extraction only from DT or from board.json are introduced. Since this is only changing the access to the label MAC address, it won't interfere with the addresses stored in the code base so far. Signed-off-by: Adrian Schmutzler --- package/base-files/files/bin/config_generate | 5 --- .../base-files/files/lib/functions/system.sh | 35 +++++++++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index a72702492f..ea04d17d0b 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -257,11 +257,6 @@ generate_static_system() { uci -q set "system.@system[-1].hostname=$hostname" fi - local label_macaddr - if json_get_var label_macaddr label_macaddr; then - uci -q set "system.@system[-1].label_macaddr=$label_macaddr" - fi - if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index 6ff1c68577..1b82046f92 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -1,5 +1,7 @@ # Copyright (C) 2006-2013 OpenWrt.org +. /usr/share/libubox/jshn.sh + get_mac_binary() { local path="$1" local offset="$2" @@ -12,14 +14,41 @@ get_mac_binary() { hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null } -get_mac_label() { +get_mac_label_dt() { local basepath="/proc/device-tree" local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)" local macaddr - [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) + [ -n "$macdevice" ] || return + + macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null) [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null) - [ -n "$macaddr" ] || macaddr=$(uci -q get system.@system[0].label_macaddr) + + echo $macaddr +} + +get_mac_label_json() { + local cfg="/etc/board.json" + local macaddr + + [ -s "$cfg" ] || return + + json_init + json_load "$(cat $cfg)" + if json_is_a system object; then + json_select system + json_get_var macaddr label_macaddr + json_select .. + fi + + echo $macaddr +} + +get_mac_label() { + local macaddr=$(get_mac_label_dt) + + [ -n "$macaddr" ] || macaddr=$(get_mac_label_json) + echo $macaddr } From 902837432f65484be6c84e8278df1d77355dede5 Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Tue, 12 Nov 2019 01:20:45 +0900 Subject: [PATCH 33/36] base-files: config_generate: split macaddr with multiple ifaces netifd does not handle network.@device[x].name properly if it contains multiple ifaces separated by spaces. Due to this, board.d lan_mac setup does not work if multiple ifaces are set to LAN by ucidef_set_interface_lan. To fix this, create a device node for each member iface when running config_generate instead. Signed-off-by: Sungbo Eo [always use new scheme, extend description, change commit title] Signed-off-by: Adrian Schmutzler --- package/base-files/Makefile | 2 +- package/base-files/files/bin/config_generate | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package/base-files/Makefile b/package/base-files/Makefile index ec40c79f2a..ea525eaed5 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=209 +PKG_RELEASE:=210 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index ea04d17d0b..748e442a60 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -85,12 +85,16 @@ generate_network() { set network.$1.proto='none' EOF - [ -n "$macaddr" ] && uci -q batch <<-EOF - delete network.$1_dev - set network.$1_dev='device' - set network.$1_dev.name='$ifname' - set network.$1_dev.macaddr='$macaddr' - EOF + if [ -n "$macaddr" ]; then + for name in $ifname; do + uci -q batch <<-EOF + delete network.$1_${name/./_}_dev + set network.$1_${name/./_}_dev='device' + set network.$1_${name/./_}_dev.name='$name' + set network.$1_${name/./_}_dev.macaddr='$macaddr' + EOF + done + fi case "$protocol" in static) From e2aef722205fa078c56bde7efde5667b0a8e32eb Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 16 Jan 2020 20:43:59 -0800 Subject: [PATCH 34/36] base-files/system.sh: remove $ in $(()) Not needed. Signed-off-by: Rosen Penev --- package/base-files/files/lib/functions/system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index 1b82046f92..b93c30a125 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -140,7 +140,7 @@ macaddr_add() { local oui=${mac%:*:*:*} local nic=${mac#*:*:*:} - nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') + nic=$(printf "%06x" $((0x${nic//:/} + val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') echo $oui:$nic } From 2dc590d630d1c4646bc59d4b53f4ab0f62915244 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Fri, 13 Mar 2020 16:56:53 +0100 Subject: [PATCH 35/36] base-files: source functions.sh in /lib/functions/system.sh The file /lib/functions/system.sh depends on find_mtd_index() and find_mtd_part() located in /lib/function.sh, so let's source that file. Signed-off-by: Adrian Schmutzler --- package/base-files/files/lib/functions/system.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index b93c30a125..7321c022f2 100755 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -1,5 +1,6 @@ # Copyright (C) 2006-2013 OpenWrt.org +. /lib/functions.sh . /usr/share/libubox/jshn.sh get_mac_binary() { From f1c4318a5e75a5f682635a9fe5bc69b3a432fa1d Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Mon, 12 Oct 2020 20:58:01 +0200 Subject: [PATCH 36/36] glibc: update to latest 2.31 commit [BZ #26383] 32965a46ce intl: Handle translation output codesets with suffixes [BZ #26383] Signed-off-by: Hans Dedecker --- toolchain/glibc/common.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk index 6b3f15b129..2a223484da 100644 --- a/toolchain/glibc/common.mk +++ b/toolchain/glibc/common.mk @@ -12,8 +12,8 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=6fdf971c9dbf7dac9bea552113fe4694015bbc4d -PKG_MIRROR_HASH:=80998023c237bd0eaa38554e18536d8f66223e97fc5ade015a2d2aadf587d1f0 +PKG_SOURCE_VERSION:=32965a46ce978f271ec6d3745f951da111c8e74a +PKG_MIRROR_HASH:=f4d2e53aef57412740536fc9aea6cdcebc4b2b50461343f4eb438d507705e046 PKG_SOURCE_URL:=https://sourceware.org/git/glibc.git PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz