Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
awall
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
awall
Commits
4fa8ce2e
Commit
4fa8ce2e
authored
Jun 26, 2012
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pretty output from awall list
parent
20ae74c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
15 deletions
+30
-15
awall-cli
awall-cli
+1
-3
awall/policy.lua
awall/policy.lua
+12
-12
awall/util.lua
awall/util.lua
+17
-0
No files found.
awall-cli
View file @
4fa8ce2e
...
...
@@ -103,9 +103,7 @@ require 'awall'
policyset
=
awall
.
PolicySet
.
new
(
params
.
i
,
params
.
I
)
if
mode
==
'list'
then
for
name
,
status
,
desc
in
policyset
:
list
()
do
print
(
name
,
status
,
desc
)
end
awall
.
util
.
printtabular
(
policyset
:
list
())
os.exit
()
end
...
...
awall/policy.lua
View file @
4fa8ce2e
...
...
@@ -220,19 +220,19 @@ end
function
PolicySet
:
list
()
local
config
,
imported
=
self
:
load
()
local
pols
=
list
(
self
.
importdirs
)
local
i
=
0
local
res
=
{}
for
i
,
pol
in
ipairs
(
list
(
self
.
importdirs
))
do
local
name
=
pol
[
1
]
return
function
()
i
=
i
+
1
if
i
>
#
pols
then
return
end
local
name
=
pols
[
i
][
1
]
local
status
if
self
:
findsymlink
(
name
)
then
status
=
'enabled'
elseif
util
.
contains
(
imported
,
name
)
then
status
=
'required'
else
status
=
'disabled'
end
local
status
if
self
:
findsymlink
(
name
)
then
status
=
'enabled'
elseif
util
.
contains
(
imported
,
name
)
then
status
=
'required'
else
status
=
'disabled'
end
table.insert
(
res
,
{
name
,
status
,
self
:
loadJSON
(
name
,
pol
[
2
]).
description
})
end
return
name
,
status
,
self
:
loadJSON
(
name
,
pols
[
i
][
2
]).
description
end
return
res
end
awall/util.lua
View file @
4fa8ce2e
...
...
@@ -37,3 +37,20 @@ end
function
extend
(
tbl1
,
tbl2
)
for
i
,
var
in
listpairs
(
tbl2
)
do
table.insert
(
tbl1
,
var
)
end
end
function
printtabular
(
tbl
)
local
colwidth
=
{}
for
i
,
row
in
ipairs
(
tbl
)
do
for
j
,
col
in
ipairs
(
row
)
do
colwidth
[
j
]
=
math.max
(
colwidth
[
j
]
or
0
,
string.len
(
col
))
end
end
for
i
,
row
in
ipairs
(
tbl
)
do
for
j
,
col
in
ipairs
(
row
)
do
if
j
>
1
then
io.write
(
' '
)
end
io.write
(
col
)
for
k
=
1
,
colwidth
[
j
]
-
string.len
(
col
)
do
io.write
(
' '
)
end
end
io.write
(
'
\n
'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment