luci-0.9: merge r5948
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 27 Mar 2010 14:56:35 +0000 (14:56 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 27 Mar 2010 14:56:35 +0000 (14:56 +0000)
modules/admin-full/luasrc/model/cbi/admin_network/network.lua
modules/admin-mini/luasrc/model/cbi/mini/network.lua

index d645f0f0bb296868535b90dc3e047fc941a3d9e9..255f684674cfd00a228307722966ceab7de9ff85 100644 (file)
@@ -91,14 +91,17 @@ end
 hwaddr = s:option(DummyValue, "_hwaddr")
 function hwaddr.cfgvalue(self, section)
        local ix = utl.trim(self.map:get(section, "ifname") or "")
-       if #ix > 0 then
-               local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
-                       or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
+       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
+       if mac and #mac > 0 then
+               return mac:upper()
        end
+
        return "?"
 end
 
index 14414e999eb3343f12732f4726fd98acd2bf7666..57db2a6fde59df9c6e02cdd42b35ad39ca1002b6 100644 (file)
@@ -41,9 +41,18 @@ hwaddr = s:option(DummyValue, "_hwaddr",
  translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
 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