diff options
author | Martin Basti <mbasti@redhat.com> | 2017-01-10 13:45:11 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-01-24 13:25:47 +0100 |
commit | e0641092770530e3b93c00de415172751d031210 (patch) | |
tree | e3479c5fdabf440cce1cd5dd86a7412b8a64c4d5 /ipaserver/install/service.py | |
parent | 23239bccc18f2fdc10431134a1c6a777f450704e (diff) | |
download | freeipa-e0641092770530e3b93c00de415172751d031210.tar.gz freeipa-e0641092770530e3b93c00de415172751d031210.tar.xz freeipa-e0641092770530e3b93c00de415172751d031210.zip |
py3: service.py: replace mkstemp by NamedTemporaryFile
NamedTemporaryfile can be used in more pythonic way and file can be
opened in textual mode that is required with PY3
https://fedorahosted.org/freeipa/ticket/4985
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaserver/install/service.py')
-rw-r--r-- | ipaserver/install/service.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py index 6451f92f0..fbe3f23e5 100644 --- a/ipaserver/install/service.py +++ b/ipaserver/install/service.py @@ -208,9 +208,10 @@ class Service(object): args += ["-H", ldap_uri] if dm_password: - [pw_fd, pw_name] = tempfile.mkstemp() - os.write(pw_fd, dm_password) - os.close(pw_fd) + with tempfile.NamedTemporaryFile( + mode='w', delete=False) as pw_file: + pw_file.write(dm_password) + pw_name = pw_file.name auth_parms = ["-x", "-D", "cn=Directory Manager", "-y", pw_name] # Use GSSAPI auth when not using DM password or not being root elif os.getegid() != 0: |