From 488d01ced715929d47f6766a63b7d6c597125562 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Feb 10 2017 13:03:04 +0000 Subject: py3: create DNS zonefile: use textual mode Also code was rewritten to use NamedTemporaryFile with context https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Jan Cholasta --- diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index b1024aa..03dce56 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -670,10 +670,13 @@ class BindInstance(service.Service): system_records.get_base_records() ) ) - [fd, name] = tempfile.mkstemp(".db","ipa.system.records.") - os.write(fd, text) - os.close(fd) - print("Please add records in this file to your DNS system:", name) + with tempfile.NamedTemporaryFile( + mode="w", prefix="ipa.system.records.", + suffix=".db", delete=False + ) as f: + f.write(text) + print("Please add records in this file to your DNS system:", + f.name) def create_instance(self):