comparison mod_firewall/definitions.lib.lua @ 4017:015452258952

mod_firewall: Ensure file lists are always initialized empty
author Matthew Wild <mwild1@gmail.com>
date Tue, 12 May 2020 12:31:51 +0100
parents b872f111b7af
children e9e10ec1b91c
comparison
equal deleted inserted replaced
4016:b872f111b7af 4017:015452258952
146 }; 146 };
147 147
148 -- %LIST: file:/path/to/file 148 -- %LIST: file:/path/to/file
149 file = { 149 file = {
150 init = function (self, file_spec, opts) 150 init = function (self, file_spec, opts)
151 local items = {}; 151 local n, items = 0, {};
152 local n = 0; 152 self.items = items;
153 local filename = file_spec:gsub("^file:", ""); 153 local filename = file_spec:gsub("^file:", "");
154 if opts.missing == "ignore" and not lfs.attributes(filename, "mode") then 154 if opts.missing == "ignore" and not lfs.attributes(filename, "mode") then
155 module:log("debug", "Ignoring missing list file: %s", filename); 155 module:log("debug", "Ignoring missing list file: %s", filename);
156 return; 156 return;
157 end 157 end
165 n = n + 1; 165 n = n + 1;
166 items[line] = true; 166 items[line] = true;
167 end 167 end
168 end 168 end
169 end 169 end
170 self.items = items;
171 module:log("debug", "Loaded %d items from %s", n, filename); 170 module:log("debug", "Loaded %d items from %s", n, filename);
172 end; 171 end;
173 add = function (self, item) 172 add = function (self, item)
174 self.items[item] = true; 173 self.items[item] = true;
175 end; 174 end;