diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-03-31 18:59:19 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-03-31 18:59:19 +0300 |
commit | 0f5c611d351ed27ef83a122e30f45c9d0e028da0 (patch) | |
tree | f0b3d7a31a5654660b477af15c2e8c4f4bf17307 | |
parent | 26bf38cd2e24b2d6c352d6c9bb61310ec72fd404 (diff) | |
download | awall-0f5c611d351ed27ef83a122e30f45c9d0e028da0.tar.bz2 awall-0f5c611d351ed27ef83a122e30f45c9d0e028da0.tar.xz |
default 'after' to relative complement of 'before' in 'imported'v1.1.0
-rw-r--r-- | awall/policy.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/awall/policy.lua b/awall/policy.lua index 4e5d72b..d7e28d4 100644 --- a/awall/policy.lua +++ b/awall/policy.lua @@ -15,7 +15,7 @@ local raise = require('awall.uerror').raise local util = require('awall.util') local contains = util.contains -local list = util.list +local listpairs = util.listpairs local PolicyConfig = class() @@ -158,13 +158,21 @@ function PolicySet:load() local data = policy:load() imported[policy.name] = data - if not data.after then data.after = util.copy(list(data.import)) end + if not data.after then + data.after = {} + for _, name in listpairs(data.import) do + if not contains(data.before, name) then + table.insert(data.after, name) + end + end + end + if not contains(data.before, '%defaults') then - data.after = list(data.after) + data.after = util.list(data.after) table.insert(data.after, '%defaults') end - for i, name in util.listpairs(data.import) do + for i, name in listpairs(data.import) do if string.sub(name, 1, 1) ~= '%' then local pol = self.policies[name] if not pol then |