aboutsummaryrefslogtreecommitdiffstats
path: root/awall-cli
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-03-31 22:23:12 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-03-31 22:58:30 +0300
commit8dd40541fa82425f89b514ddf89fa0946932cc62 (patch)
tree1476be4248a20201040b730dafeefb306a492d3c /awall-cli
parent4e6cf81a7cff31c765101636791365ce2ffae3ee (diff)
downloadawall-8dd40541fa82425f89b514ddf89fa0946932cc62.tar.bz2
awall-8dd40541fa82425f89b514ddf89fa0946932cc62.tar.xz
deterministic ordering in 'awall dump'
Diffstat (limited to 'awall-cli')
-rwxr-xr-xawall-cli26
1 files changed, 15 insertions, 11 deletions
diff --git a/awall-cli b/awall-cli
index aa9bbea..69ab3e9 100755
--- a/awall-cli
+++ b/awall-cli
@@ -136,6 +136,7 @@ if not call(
local awall = require('awall')
local printtabular = util.printtabular
+ local sortedkeys = util.sortedkeys
local policyset = awall.PolicySet(pol_paths)
@@ -143,7 +144,7 @@ if not call(
local imported = policyset:load().policies
local data = {}
- for i, name in util.sortedkeys(policyset.policies) do
+ for i, name in sortedkeys(policyset.policies) do
local policy = policyset.policies[name]
if all or policy.type == 'optional' then
@@ -200,38 +201,41 @@ if not call(
return cls:sub(1, 1):upper()..cls:sub(2, -1)
end
- for cls, objs in pairs(input.data) do
+ for _, cls in sortedkeys(input.data) do
if level > 2 or (level == 2 and cls ~= 'service') or contains(
{'variable', 'zone'},
cls
) then
if level == 0 then print(capitalize(cls)..'s:') end
-
+
+ local clsdata = input.data[cls]
local items = {}
- for k, v in pairs(objs) do
- local exp = expinput[cls][k]
+
+ for _, key in sortedkeys(clsdata) do
+ local exp = expinput[cls][key]
local expj = json.encode(exp)
- local src = input.source[cls][k]
+ local src = input.source[cls][key]
- if level == 0 then table.insert(items, {k, expj, src})
+ if level == 0 then table.insert(items, {key, expj, src})
else
+ local value = clsdata[key]
local data = {
- {capitalize(cls)..' '..k, json.encode(v)},
+ {capitalize(cls)..' '..key, json.encode(value)},
{
'('..src..')',
- util.compare(exp, v) and '' or '-> '..expj
+ util.compare(exp, value) and '' or '-> '..expj
}
}
if level > 3 then
- local obj = config.objects[cls][k]
+ local obj = config.objects[cls][key]
if type(obj) == 'table' and obj.info then
util.extend(data, obj:info())
end
end
- table.insert(items, {k, data})
+ table.insert(items, {key, data})
end
end
table.sort(items, function(a, b) return a[1] < b[1] end)