# HG changeset patch # User Kim Alvefur # Date 1520853975 -3600 # Node ID b0d92332b87fba99f1904cbd44a8525540917d38 # Parent 7953b7dde6e7eabd5bfa3550d3e5169e55be06d0 mod_firewall: Add special case for $local zone (fixes #1090) diff -r 7953b7dde6e7 -r b0d92332b87f mod_firewall/conditions.lib.lua --- a/mod_firewall/conditions.lib.lua Sat Mar 10 05:01:15 2018 +0100 +++ b/mod_firewall/conditions.lib.lua Mon Mar 12 12:26:15 2018 +0100 @@ -87,12 +87,14 @@ end local function zone_check(zone, which) + local zone_var = zone; + if zone == "$local" then zone_var = "_local" end local which_not = which == "from" and "to" or "from"; return ("(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s]) " .."and not(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s])" ) - :format(zone, which, zone, which, zone, which, - zone, which_not, zone, which_not, zone, which_not), { + :format(zone_var, which, zone_var, which, zone_var, which, + zone_var, which_not, zone_var, which_not, zone_var, which_not), { "split_to", "split_from", "bare_to", "bare_from", "zone:"..zone }; end diff -r 7953b7dde6e7 -r b0d92332b87f mod_firewall/mod_firewall.lua --- a/mod_firewall/mod_firewall.lua Sat Mar 10 05:01:15 2018 +0100 +++ b/mod_firewall/mod_firewall.lua Mon Mar 12 12:26:15 2018 +0100 @@ -183,8 +183,13 @@ is_admin = { global_code = [[local is_admin = require "core.usermanager".is_admin;]]}; core_post_stanza = { global_code = [[local core_post_stanza = prosody.core_post_stanza;]] }; zone = { global_code = function (zone) - assert(idsafe(zone), "Invalid zone name: "..zone); - return ("local zone_%s = zones[%q] or {};"):format(zone, zone); + local var = zone; + if var == "$local" then + var = "_local"; -- See #1090 + else + assert(idsafe(var), "Invalid zone name: "..zone); + end + return ("local zone_%s = zones[%q] or {};"):format(var, zone); end }; date_time = { global_code = [[local os_date = os.date]]; local_code = [[local current_date_time = os_date("*t");]] }; time = { local_code = function (what)