diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-03-27 14:54:06 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-03-27 14:54:06 +0000 |
commit | 903bea9683aa6f6843c9cd3697d40ca15989f104 (patch) | |
tree | e211d4e174ce578a4394a405a3326b0970398d85 /modules/admin-mini | |
parent | e20c891d1cc164e8083bd478864a3b7798517ffa (diff) |
modules/admin-{mini,full}: prevent crash in iface overview page if ifconfig does not return information
Diffstat (limited to 'modules/admin-mini')
-rw-r--r-- | modules/admin-mini/luasrc/model/cbi/mini/network.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/admin-mini/luasrc/model/cbi/mini/network.lua b/modules/admin-mini/luasrc/model/cbi/mini/network.lua index 43ad212cc..57edc4718 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/network.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/network.lua @@ -41,9 +41,18 @@ hwaddr = s:option(DummyValue, "_hwaddr", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"), translate("Hardware Address")) 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 |