Commits

Anonymous committed fc80a84

Fixed crash when bootsector cannot be read and replaced it with a friendly error message on the ui

Comments (0)

Files changed (1)

src/vasm/ui/tui/modules/tui_bootloaders.py

         # FIXME:
         # When running in a chroot environment, this will produce an error
         # because the chroot has no / mountpoint            
+	if not bsector:
+	    logger.error('Unable to find current bootsector.  Possible chroot environment.')
+	    logger.error('%s bailing out.'% __file__)
+	    self.parent.return_home()
+
         if bsector:
             rootdev = bsector[:len('/dev/sda'):]
             currentbootloader = BOOTLOADERS.MBR(rootdev).read_bootloader() or \
 def __vasm_test__():
     return os.geteuid() == 0
 
+
 def __run__(parent):
+    # check if we can read the bootsector.
+    bsector = BOOTLOADERS.get_current_bootsector()
+    if bsector is None:
+	msg = (
+		_("This module is not available because your current bootsector cannot be read."),
+		_("This could indicate that you are working inside a chroot environment."),
+		)
+	dia = dialogs.Error(
+		parent = parent,
+		buttons = [("OK", parent.return_home)],
+		message = '  '.join(msg)
+		)
+	logger.error('Unable to read bootsector.  %s bailing out'% __file__)
+	return parent.pop_module(dia)
     mod = BootloaderTui(parent)
     parent.pop_module(mod)