modules/admin-full: check /etc/ethers and /var/dhcp.leases for existence before tryin...
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 23 May 2012 22:22:22 +0000 (22:22 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 23 May 2012 22:22:22 +0000 (22:22 +0000)
modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua

index 334d9f20fe83fe11f4a35b9c0e73d15ff472e51f..c502ea8020d8c1949979a842f9c65f97cdc47e75 100644 (file)
@@ -113,14 +113,18 @@ local function arplist(opt)
                arp[e["HW address"]:upper()] = { e["IP address"] }
        end
 
-       for e in io.lines("/etc/ethers") do
-               mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
-               if mac and ip then arp[mac:upper()] = { ip } end
+       if fs.access("/etc/ethers") then
+               for e in io.lines("/etc/ethers") do
+                       mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
+                       if mac and ip then arp[mac:upper()] = { ip } end
+               end
        end
 
-       for e in io.lines("/var/dhcp.leases") do
-               mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
-               if mac and ip then arp[mac:upper()] = { ip, name ~= "*" and name } end
+       if fs.access("/var/dhcp.leases") then
+               for e in io.lines("/var/dhcp.leases") do
+                       mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
+                       if mac and ip then arp[mac:upper()] = { ip, name ~= "*" and name } end
+               end
        end
 
        for mac, e in luci.util.kspairs(arp) do