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
ad677b62
Commit
ad677b62
authored
Jun 26, 2012
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset all built-in chains on activation/fallback regardless of translation results
parent
6d4ff188
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
awall/iptables.lua
awall/iptables.lua
+22
-4
No files found.
awall/iptables.lua
View file @
ad677b62
...
...
@@ -22,8 +22,12 @@ local families = {inet={cmd='iptables',
file
=
'rules6-save'
,
procfile
=
'/proc/net/ip6_tables_names'
}}
local
builtin
=
{
'INPUT'
,
'FORWARD'
,
'OUTPUT'
,
'PREROUTING'
,
'POSTROUTING'
}
local
builtin
=
{
filter
=
{
'FORWARD'
,
'INPUT'
,
'OUTPUT'
},
mangle
=
{
'FORWARD'
,
'INPUT'
,
'OUTPUT'
,
'POSTROUTING'
,
'PREROUTING'
},
nat
=
{
'INPUT'
,
'OUTPUT'
,
'POSTROUTING'
,
'PREROUTING'
},
raw
=
{
'OUTPUT'
,
'PREROUTING'
},
security
=
{
'FORWARD'
,
'INPUT'
,
'OUTPUT'
}}
local
backupdir
=
'/var/run/awall'
...
...
@@ -63,7 +67,21 @@ function BaseIPTables:restore(test)
if
disabled
then
error
(
'Firewall not enabled in kernel'
)
end
end
function
BaseIPTables
:
activate
()
self
:
restore
(
false
)
end
function
BaseIPTables
:
activate
()
local
empty
=
IPTables
.
new
()
for
family
,
params
in
pairs
(
families
)
do
local
success
,
lines
=
pcall
(
io.lines
,
params
.
procfile
)
if
success
then
for
tbl
in
lines
do
for
i
,
chain
in
ipairs
(
builtin
[
tbl
])
do
empty
.
config
[
family
][
tbl
][
chain
]
=
{}
end
end
end
end
empty
:
restore
(
false
)
self
:
restore
(
false
)
end
function
BaseIPTables
:
test
()
self
:
restore
(
true
)
end
...
...
@@ -86,7 +104,7 @@ function IPTables:dumpfile(family, iptfile)
iptfile
:
write
(
'*'
..
tbl
..
'
\n
'
)
for
chain
,
rules
in
pairs
(
chains
)
do
local
policy
=
'-'
if
awall
.
util
.
contains
(
builtin
,
chain
)
then
if
awall
.
util
.
contains
(
builtin
[
tbl
]
,
chain
)
then
policy
=
tbl
==
'filter'
and
'DROP'
or
'ACCEPT'
end
iptfile
:
write
(
':'
..
chain
..
' '
..
policy
..
' [0:0]\n'
)
...
...
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