# HG changeset patch # User Matthew Wild # Date 1479222074 0 # Node ID 3ebd3cb4d7d296353a5543cd7aa1ad1e99b16535 # Parent 14021c93a962ca02e5e902dac097a03bb9b51ffc mod_firewall: When compiling on the command-line with -v, ensure chain function names are unique and valid ids diff -r 14021c93a962 -r 3ebd3cb4d7d2 mod_firewall/mod_firewall.lua --- a/mod_firewall/mod_firewall.lua Tue Nov 15 15:00:38 2016 +0000 +++ b/mod_firewall/mod_firewall.lua Tue Nov 15 15:01:14 2016 +0000 @@ -476,22 +476,25 @@ print("local active_definitions = "..serialize(active_definitions)..";"); print(); end + local c = 0; for chain, handler_code in pairs(chain_functions) do + c = c + 1; print("---- Chain "..chain:gsub("_", " ")); + local chain_func_name = "chain_"..tostring(c).."_"..chain:gsub("%p", "_"); if not verbose then - print(("%s = %s;"):format(chain, handler_code:sub(8))); + print(("%s = %s;"):format(chain_func_name, handler_code:sub(8))); else - print(("local %s = (%s)(active_definitions, fire_event, logger(%q));"):format(chain, handler_code:sub(8), filename)); + print(("local %s = (%s)(active_definitions, fire_event, logger(%q));"):format(chain_func_name, handler_code:sub(8), filename)); print(); local chain_definition = chains[chain]; if chain_definition and chain_definition.type == "event" then for _, event_name in ipairs(chain_definition) do - print(("module:hook(%q, %s, %d);"):format(event_name, chain, chain_definition.priority or 0)); + print(("module:hook(%q, %s, %d);"):format(event_name, chain_func_name, chain_definition.priority or 0)); end end - print(("module:hook(%q, %s, %d);"):format("firewall/chains/"..chain, chain, chain_definition.priority or 0)); + print(("module:hook(%q, %s, %d);"):format("firewall/chains/"..chain, chain_func_name, chain_definition.priority or 0)); end print("---- End of chain "..chain);