modules/admin-{mini,full}: prevent crash in iface overview page if ifconfig does...
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / network.lua
index c117e93..2dc9e9b 100644 (file)
@@ -25,6 +25,7 @@ local netstat = sys.net.deviceinfo()
 
 s = m:section(TypedSection, "interface", "")
 s.addremove = true
+s.anonymous = false
 s.extedit   = luci.dispatcher.build_url("admin", "network", "network") .. "/%s"
 s.template  = "cbi/tblsection"
 s.override_scheme = true
@@ -74,7 +75,7 @@ ifname.titleref = luci.dispatcher.build_url("admin", "network", "vlan")
 
 
 if luci.model.uci.cursor():load("firewall") then
-       zone = s:option(DummyValue, "_zone", translate("zone"))
+       zone = s:option(DummyValue, "_zone", translate("Zone"))
        zone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
 
        function zone.cfgvalue(self, section)
@@ -85,9 +86,18 @@ end
 hwaddr = s:option(DummyValue, "_hwaddr")
 function hwaddr.cfgvalue(self, section)
        local ix = self.map:get(section, "ifname") or ""
-       return fs.readfile("/sys/class/net/" .. ix .. "/address")
-        or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
-        or "n/a"
+       local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
+
+       if not mac then
+               mac = luci.util.exec("ifconfig " .. ix)
+               mac = mac and mac:match(" ([A-F0-9:]+)%s*\n")
+       end
+
+       if mac and #mac > 0 then
+               return mac:upper()
+       end
+
+       return "?"
 end