aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2012-05-01 11:18:46 +0000
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2012-05-01 11:18:46 +0000
commit1bc58d4a16cc7f3e8af1f08a187f264d3df98e28 (patch)
treed7b2f5662d8d39d45a1d3a0461436b80defeb4e1
parent71803c12b8e2f725a32fabaefa211538237c5f11 (diff)
downloadawall-0.1.1.tar.bz2
awall-0.1.1.tar.xz
policy file description attributev0.1.1
-rwxr-xr-xawall-cli4
-rw-r--r--awall/policy.lua24
-rw-r--r--sample-policy.json2
3 files changed, 20 insertions, 10 deletions
diff --git a/awall-cli b/awall-cli
index c2603b5..121aa9e 100755
--- a/awall-cli
+++ b/awall-cli
@@ -100,7 +100,9 @@ require 'awall'
policyset = awall.PolicySet.new(params.i, params.I)
if mode == 'list' then
- for name, status in policyset:list() do print(name, status) end
+ for name, status, desc in policyset:list() do
+ print(name, status, desc)
+ end
os.exit()
end
diff --git a/awall/policy.lua b/awall/policy.lua
index 572ff60..af00ace 100644
--- a/awall/policy.lua
+++ b/awall/policy.lua
@@ -73,6 +73,17 @@ function PolicySet:init(confdirs, importdirs)
end
+function PolicySet:loadJSON(name, fname)
+ local file = fname and io.open(fname) or open(name, self.importdirs)
+ if not file then error('Import failed: '..name) end
+
+ local data = ''
+ for line in file:lines() do data = data..line end
+ file:close()
+ return json.decode(data)
+end
+
+
function PolicySet:load()
local input = {}
@@ -86,20 +97,15 @@ function PolicySet:load()
error('Circular import: '..name)
end
- local file = fname and io.open(fname) or open(name, self.importdirs)
- if not file then error('Import failed: '..name) end
-
- local data = ''
- for line in file:lines() do data = data..line end
- file:close()
- data = json.decode(data)
+ local data = self:loadJSON(name, fname)
table.insert(required, name)
for i, iname in util.listpairs(data.import) do import(iname) end
table.insert(imported, name)
for cls, objs in pairs(data) do
- if cls ~= 'import' then
+ if not util.contains({'description', 'import'},
+ cls) then
if not input[cls] then input[cls] = objs
elseif objs[1] then util.extend(input[cls], objs)
else
@@ -160,6 +166,6 @@ function PolicySet:list()
elseif util.contains(imported, name) then status = 'required'
else status = 'disabled' end
- return name, status
+ return name, status, self:loadJSON(name, pols[i][2]).description
end
end
diff --git a/sample-policy.json b/sample-policy.json
index 73850c3..8dc9d95 100644
--- a/sample-policy.json
+++ b/sample-policy.json
@@ -1,4 +1,6 @@
{
+ "description": "Sample awall policy; copy to /etc/awall to use",
+
"variable": { "internet_if": "eth0" },
"zone": {