From 903bea9683aa6f6843c9cd3697d40ca15989f104 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 27 Mar 2010 14:54:06 +0000 Subject: modules/admin-{mini,full}: prevent crash in iface overview page if ifconfig does not return information --- .../admin-full/luasrc/model/cbi/admin_network/network.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'modules/admin-full/luasrc') diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua index 8d34fa7cff..2dc9e9b43a 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua @@ -86,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 -- cgit v1.2.3