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
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
498a67cf
Commit
498a67cf
authored
Jun 26, 2012
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply ip[6]tables-restore only if protocol support loaded into kernel
parent
4fa8ce2e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
awall/iptables.lua
awall/iptables.lua
+29
-10
No files found.
awall/iptables.lua
View file @
498a67cf
...
...
@@ -15,8 +15,12 @@ require 'awall.util'
local
class
=
awall
.
object
.
class
local
families
=
{
inet
=
{
cmd
=
'iptables'
,
file
=
'rules-save'
},
inet6
=
{
cmd
=
'ip6tables'
,
file
=
'rules6-save'
}}
local
families
=
{
inet
=
{
cmd
=
'iptables'
,
file
=
'rules-save'
,
procfile
=
'/proc/net/ip_tables_names'
},
inet6
=
{
cmd
=
'ip6tables'
,
file
=
'rules6-save'
,
procfile
=
'/proc/net/ip6_tables_names'
}}
local
builtin
=
{
'INPUT'
,
'FORWARD'
,
'OUTPUT'
,
'PREROUTING'
,
'POSTROUTING'
}
...
...
@@ -34,19 +38,34 @@ function BaseIPTables:dump(dir)
end
end
function
BaseIPTables
:
restore
(
...
)
function
BaseIPTables
:
restore
(
test
)
local
disabled
=
true
for
family
,
params
in
pairs
(
families
)
do
local
pid
,
stdin
,
stdout
=
lpc
.
run
(
params
.
cmd
..
'-restore'
,
unpack
(
arg
))
local
file
=
io.open
(
params
.
procfile
)
if
file
then
io.close
(
file
)
local
pid
,
stdin
,
stdout
=
lpc
.
run
(
params
.
cmd
..
'-restore'
,
unpack
({
test
and
'-t'
or
nil
}))
stdout
:
close
()
self
:
dumpfile
(
family
,
stdin
)
stdin
:
close
()
assert
(
lpc
.
wait
(
pid
)
==
0
)
disabled
=
false
elseif
test
then
io.stderr
:
write
(
'Warning: '
..
family
..
' rules not tested\n'
)
end
end
if
disabled
then
error
(
'Firewall not enabled in kernel'
)
end
end
function
BaseIPTables
:
activate
()
self
:
restore
()
end
function
BaseIPTables
:
activate
()
self
:
restore
(
false
)
end
function
BaseIPTables
:
test
()
self
:
restore
(
'-t'
)
end
function
BaseIPTables
:
test
()
self
:
restore
(
true
)
end
IPTables
=
class
(
BaseIPTables
)
...
...
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