[Freeipa-devel] [PATCH 5 of 8] Use tempfile.mkdtemp() rather than hardcoded tmpdir

Mark McLoughlin markmc at redhat.com
Fri Jan 11 12:00:42 UTC 2008


# HG changeset patch
# User Mark McLoughlin <markmc at redhat.com>
# Date 1200047785 0
# Node ID 6ac6e1ca0049e22e03b5a8df56e0efd232eb672b
# Parent  47a30c3995b2198532255777511d96878fade079
Use tempfile.mkdtemp() rather than hardcoded tmpdir

httpinstance.py currently uses a hardcoded /tmp/ipa temporary
directory. Make it use tempfile.mkdtemp() instead.

Signed-off-by: Mark McLoughlin <markmc at redhat.com>

diff -r 47a30c3995b2 -r 6ac6e1ca0049 ipa-server/ipaserver/httpinstance.py
--- a/ipa-server/ipaserver/httpinstance.py	Fri Jan 11 10:36:25 2008 +0000
+++ b/ipa-server/ipaserver/httpinstance.py	Fri Jan 11 10:36:25 2008 +0000
@@ -131,15 +131,10 @@ class HTTPInstance(service.Service):
         shutil.copy(ds_ca.cacert_fname, "/usr/share/ipa/html/ca.crt")
         os.chmod("/usr/share/ipa/html/ca.crt", 0444)
 
-        try:
-            shutil.rmtree("/tmp/ipa")
-        except:
-            pass
-        os.mkdir("/tmp/ipa")
-        shutil.copy("/usr/share/ipa/html/preferences.html", "/tmp/ipa")
-
+        tmpdir = tempfile.mkdtemp(prefix = "tmp-")
+        shutil.copy("/usr/share/ipa/html/preferences.html", tmpdir)
         ca.run_signtool(["-k", "Signing-Cert",
                          "-Z", "/usr/share/ipa/html/configure.jar",
                          "-e", ".html",
-                         "/tmp/ipa"])
-        shutil.rmtree("/tmp/ipa")
+                         tmpdir])
+        shutil.rmtree(tmpdir)




More information about the Freeipa-devel mailing list