Blob Blame History Raw
diff -rup virtinst-0.400.3.orig/virtinst/Installer.py virtinst-0.400.3.new/virtinst/Installer.py
--- virtinst-0.400.3.orig/virtinst/Installer.py	2009-03-10 03:32:15.000000000 +0000
+++ virtinst-0.400.3.new/virtinst/Installer.py	2009-04-03 18:15:10.000000000 +0100
@@ -136,12 +136,28 @@ class Installer(object):
     def get_scratchdir(self):
         if platform.system() == 'SunOS':
             return '/var/tmp'
-        if self.type == "xen" and os.path.exists(XEN_SCRATCH):
+        if os.geteuid() == 0 and self.type == "xen" and os.path.exists(XEN_SCRATCH):
             return XEN_SCRATCH
         if os.geteuid() == 0 and os.path.exists(LIBVIRT_SCRATCH):
             return LIBVIRT_SCRATCH
-        else:
-            return os.path.expanduser("~/.virtinst/boot")
+
+        appdir = os.path.expanduser("~/.virtinst")
+        bootdir = appdir + "/boot"
+        # Try and make directory immediately and set selinux
+        # context if possible
+        try:
+            import selinux
+            if not os.access(appdir, os.W_OK):
+                os.mkdir(appdir)
+            if not os.access(bootdir, os.W_OK):
+                os.mkdir(bootdir)
+            selinux.restorecon(bootdir, recursive=True)
+            logging.info("Restored SELinux context on %s" % bootdir)
+        except Exception, e:
+            logging.error("Unable to restore SELinux context on %s: %s" % (bootdir, str(e)))
+            pass
+
+        return bootdir
     scratchdir = property(get_scratchdir)
 
     def get_cdrom(self):