Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
fwdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
36b312b6
authored
Jul 15, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logging
parent
89ad48aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
fw.py
+6
-3
utils.py
+8
-4
No files found.
fw.py
View file @
36b312b6
...
...
@@ -37,9 +37,12 @@ def reload_firewall(data4, data6, save_config=True):
if
isinstance
(
data6
,
dict
):
data6
=
(
'
\n
'
.
join
(
data6
[
'filter'
])
+
'
\n
'
)
ns_exec
(
NETNS
,
(
'ip6tables-restore'
,
'-c'
),
data6
)
ns_exec
(
NETNS
,
(
'iptables-restore'
,
'-c'
),
data4
)
try
:
ns_exec
(
NETNS
,
(
'ip6tables-restore'
,
'-c'
),
data6
)
ns_exec
(
NETNS
,
(
'iptables-restore'
,
'-c'
),
data4
)
except
:
logging
.
critical
(
'Unhandled exception: '
,
exc_info
=
True
)
raise
if
save_config
:
with
open
(
FIREWALL_CONF
,
'w'
)
as
f
:
...
...
utils.py
View file @
36b312b6
...
...
@@ -30,14 +30,18 @@ dhcp_no_free_re = re.compile(r'\S DHCPDISCOVER '
def
sudo
(
args
,
stdin
=
None
):
FNULL
=
open
(
devnull
,
'w'
)
args
=
(
'/usr/bin/sudo'
,
)
+
args
logger
.
debug
(
'EXEC {}'
.
format
(
' '
.
join
(
args
)))
p
=
sp
.
Popen
(
args
,
stdin
=
sp
.
PIPE
,
stderr
=
sp
.
PIPE
,
stdout
=
sp
.
PIPE
)
if
isinstance
(
stdin
,
basestring
):
proc
=
sp
.
Popen
(
args
,
stdin
=
sp
.
PIPE
,
stderr
=
FNULL
)
return
proc
.
communicate
(
stdin
)
stdout
,
stderr
=
p
.
communicate
(
stdin
)
else
:
return
sp
.
check_output
(
args
,
stderr
=
FNULL
)
stdout
,
stderr
=
p
.
communicate
()
if
p
.
returncode
!=
0
:
raise
sp
.
CalledProcessError
(
p
.
returncode
,
sp
.
list2cmdline
(
args
),
stderr
)
return
stdout
def
ns_exec
(
netns
,
args
,
stdin
=
None
):
...
...
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