X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fadmin-full%2Fluasrc%2Fmodel%2Fcbi%2Fadmin_network%2Fwifi_add.lua;h=3d0d7550eb882dc0a4123db7065c21aceda7c137;hp=b4a442cad943b5fd3b5621e28a4a5ca0b4fb0e21;hb=1aa676d501f806109d626665cd82390c175fd029;hpb=9c3db58ee44dfd411336d7d460d0f7a6a10f0ee3
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua
index b4a442cad..3d0d7550e 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua
@@ -12,6 +12,7 @@ You may obtain a copy of the License at
$Id$
]]--
+local fs = require "nixio.fs"
local nw = require "luci.model.network"
local fw = require "luci.model.firewall"
local uci = require "luci.model.uci".cursor()
@@ -19,6 +20,8 @@ local http = require "luci.http"
local iw = luci.sys.wifi.getiwinfo(http.formvalue("device"))
+local has_firewall = fs.access("/etc/config/firewall")
+
if not iw then
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
return
@@ -89,25 +92,30 @@ newnet = m:field(Value, "_netname_new", translate("Name of the new network"),
newnet.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wwan"
newnet.datatype = "uciname"
-fwzone = m:field(Value, "_fwzone",
- translate("Create / Assign firewall-zone"),
- translate("Choose the firewall zone you want to assign to this interface. Select unspecified to remove the interface from the associated zone or fill out the create field to define a new zone and attach the interface to it."))
+if has_firewall then
+ fwzone = m:field(Value, "_fwzone",
+ translate("Create / Assign firewall-zone"),
+ translate("Choose the firewall zone you want to assign to this interface. Select unspecified to remove the interface from the associated zone or fill out the create field to define a new zone and attach the interface to it."))
-fwzone.template = "cbi/firewall_zonelist"
-fwzone.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wan"
+ fwzone.template = "cbi/firewall_zonelist"
+ fwzone.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wan"
+end
function newnet.parse(self, section)
local net, zone
- local value = self:formvalue(section)
- local zval = fwzone:formvalue(section)
+ local value = self:formvalue(section)
net = nw:add_network(value, { proto = "dhcp" })
- zone = fw:get_zone(zval)
- if not zone and zval == '-' then
- zval = m:formvalue(fwzone:cbid(section) .. ".newzone")
- if zval and #zval > 0 then
- zone = fw:add_zone(zval)
+ if has_firewall then
+ local zval = fwzone:formvalue(section)
+ zone = fw:get_zone(zval)
+
+ if not zone and zval == '-' then
+ zval = m:formvalue(fwzone:cbid(section) .. ".newzone")
+ if zval and #zval > 0 then
+ zone = fw:add_zone(zval)
+ end
end
end
@@ -165,10 +173,12 @@ function newnet.parse(self, section)
end
end
-function fwzone.cfgvalue(self, section)
- self.iface = section
- local z = fw:get_zone_by_network(section)
- return z and z:name()
+if has_firewall then
+ function fwzone.cfgvalue(self, section)
+ self.iface = section
+ local z = fw:get_zone_by_network(section)
+ return z and z:name()
+ end
end
return m