Don't execute syspreps if the fs is not mounted rw
authorNikos Skalkotos <skalkoto@grnet.gr>
Fri, 17 May 2013 13:09:30 +0000 (16:09 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Fri, 17 May 2013 13:11:06 +0000 (16:11 +0300)
Check if the filesystem is mounted read-write before you execute
the do_sysprep function

image_creator/dialog_menu.py
image_creator/dialog_wizard.py
image_creator/main.py

index 0e32167..dc0c31b 100644 (file)
@@ -554,6 +554,18 @@ def sysprep(session):
                 try:
                     image.mount(readonly=False)
                     try:
+                        err_msg = \
+                            "Unable to execute the system preparation tasks."
+                        if not image.mounted:
+                            d.msgbox("%s Couldn't mount the media." % err_msg,
+                                title="System Preperation", width=SMALL_WIDTH)
+                            return
+                        elif image.mounted_ro:
+                            d.msgbox("%s Couldn't mount the media read-write."
+                                % err_msg, title="System Preperation",
+                                width=SMALL_WIDTH)
+                            return
+
                         # The checksum is invalid. We have mounted the image rw
                         if 'checksum' in session:
                             del session['checksum']
index 5605cc7..17204dc 100644 (file)
@@ -265,6 +265,12 @@ def create_image(session):
 
         #Sysprep
         image.mount(False)
+        err_msg = "Unable to execute the system preparation tasks."
+        if not image.mounted:
+            raise FatalError("%s Couldn't mount the media." % err_msg)
+        elif image.mounted_ro:
+            raise FatalError("%s Couldn't mount the media read-write."
+                             % err_msg)
         image.os.do_sysprep()
         metadata = image.os.meta
         image.umount()
index 4b86f7c..130f50a 100644 (file)
@@ -224,6 +224,12 @@ def image_creator():
                 return 0
 
             if options.sysprep:
+                err_msg = "Unable to apply the system preparation tasks."
+                if not image.mounted:
+                    raise FatalError("%s Couldn't mount the media." % err_msg)
+                elif image.mounted_ro:
+                    raise FatalError("%s Couldn't mount the media read-write."
+                                     % err_msg)
                 image.os.do_sysprep()
 
             metadata = image.os.meta