Commit 5d877896 authored by Tom Niget's avatar Tom Niget

Properly close popen

parent 57f204ca
......@@ -77,9 +77,10 @@ def main():
print("WARNING: it is strongly recommended to use --fingerprint option.")
network = x509.networkFromCa(ca)
if config.is_needed:
route, err = subprocess.Popen(('ip', '-6', '-o', 'route', 'get',
with subprocess.Popen(('ip', '-6', '-o', 'route', 'get',
utils.ipFromBin(network)),
stdout=subprocess.PIPE).communicate()
stdout=subprocess.PIPE) as proc:
route, err = proc.communicate()
sys.exit(err or route and
utils.binFromIp(route.split()[8]).startswith(network))
......@@ -90,7 +91,7 @@ def main():
reserved = 'CN', 'serial'
req = crypto.X509Req()
try:
with open(cert_path) as f:
with open(cert_path, "rb") as f:
cert = loadCert(f.read())
components = dict(cert.get_subject().get_components())
components = {k.decode(): v for k, v in components.items()}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment