Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bind-dnssec
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Valentin Samir
bind-dnssec
Commits
c0dc9d35
Commit
c0dc9d35
authored
Jun 18, 2017
by
Valentin Samir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the subprocess.Popen parameter encoding= in python 3
parent
296bfa68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
config.ini.sample
config.ini.sample
+3
-0
routine.py
routine.py
+14
-6
No files found.
config.ini.sample
View file @
c0dc9d35
...
...
@@ -37,3 +37,6 @@ dnssec_keygen=/usr/sbin/dnssec-keygen
# path to the rndc binary
rndc=/usr/sbin/rndc
# charset of the filesystem
fscharset=utf-8
routine.py
View file @
c0dc9d35
...
...
@@ -45,6 +45,7 @@ DNSSEC_SETTIME = "/usr/sbin/dnssec-settime"
DNSSEC_DSFROMKEY
=
"/usr/sbin/dnssec-dsfromkey"
DNSSEC_KEYGEN
=
"/usr/sbin/dnssec-keygen"
RNDC
=
"/usr/sbin/rndc"
FSCHARSET
=
"utf-8"
def
_print
(
data
,
file
=
sys
.
stdout
):
...
...
@@ -52,6 +53,11 @@ def _print(data, file=sys.stdout):
data
=
data
.
decode
(
"utf-8"
)
print
(
data
,
file
=
file
)
def
_Popen
(
*
args
,
**
kwargs
):
if
sys
.
version_info
.
major
>=
3
:
kwargs
[
"encoding"
]
=
FSCHARSET
return
subprocess
.
Popen
(
*
args
,
**
kwargs
)
def
get_zones
(
zone_names
=
None
):
l
=
[]
if
zone_names
is
None
:
...
...
@@ -71,7 +77,7 @@ def settime(path, flag, date):
"-i"
,
str
(
int
(
INTERVAL
.
total_seconds
())),
"-%s"
%
flag
,
date
,
path
]
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
p
=
_
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
err
=
p
.
communicate
()[
1
]
if
p
.
returncode
!=
0
:
raise
ValueError
(
"err %s: %s"
%
(
p
.
returncode
,
err
))
...
...
@@ -98,7 +104,7 @@ def bind_chown(path):
def
bind_reload
():
"""Reload bind config"""
cmd
=
[
RNDC
,
"reload"
]
p
=
subprocess
.
Popen
(
cmd
)
p
=
_
Popen
(
cmd
)
p
.
wait
()
...
...
@@ -106,7 +112,7 @@ def nsec3(zone, salt="-"):
"""Enable nsec3 for the zone ``zone``"""
cmd
=
[
RNDC
,
"signing"
,
"-nsec3param"
,
"1"
,
"0"
,
"10"
,
salt
,
zone
]
_print
(
"Enabling nsec3 for zone %s: "
%
zone
,
file
=
sys
.
stdout
)
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
)
p
=
_
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
)
out
=
p
.
communicate
()[
0
]
_print
(
out
,
file
=
sys
.
stdout
)
p
.
wait
()
...
...
@@ -218,7 +224,7 @@ class Zone(object):
"""Display the DS of the KSK of the zone"""
for
ksk
in
self
.
KSK
:
cmd
=
[
DNSSEC_DSFROMKEY
,
ksk
.
_path
]
p
=
subprocess
.
Popen
(
cmd
)
p
=
_
Popen
(
cmd
)
p
.
wait
()
def
key
(
self
,
show_ksk
=
False
,
show_zsk
=
False
):
...
...
@@ -387,7 +393,7 @@ class Key(object):
raise
ValueError
(
"typ must be KSK or ZSK"
)
cmd
.
extend
(
options
)
cmd
.
extend
([
"-K"
,
path
,
name
])
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
)
p
=
_
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
)
p
.
wait
()
if
p
.
returncode
!=
0
:
raise
ValueError
(
"The key creation has failed"
)
...
...
@@ -400,7 +406,7 @@ class Key(object):
DNSSEC_KEYGEN
,
"-i"
,
str
(
int
(
INTERVAL
.
total_seconds
())),
"-S"
,
self
.
_path
,
"-K"
,
os
.
path
.
dirname
(
self
.
_path
)
]
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
)
p
=
_
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
)
err
=
p
.
communicate
()[
1
]
if
p
.
returncode
!=
0
:
raise
ValueError
(
"err %s: %s"
%
(
p
.
returncode
,
err
))
...
...
@@ -632,6 +638,8 @@ if __name__ == '__main__':
DNSSEC_KEYGEN
=
config_parser
.
get
(
"path"
,
"dnssec_keygen"
)
if
config_parser
.
has_option
(
"path"
,
"rndc"
):
RNDC
=
config_parser
.
get
(
"path"
,
"rndc"
)
if
config_parser
.
has_option
(
"path"
,
"fscharset"
):
FSCHARSET
=
config_parser
.
get
(
"path"
,
"fscharset"
)
for
path
in
[
DNSSEC_SETTIME
,
DNSSEC_DSFROMKEY
,
DNSSEC_KEYGEN
,
RNDC
]:
if
not
os
.
path
.
isfile
(
path
)
or
not
os
.
access
(
path
,
os
.
X_OK
):
...
...
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