Esempio n. 1
0
    def unlock_device(self, device_name, passphrase):
        """Unlocks LUKS device."""
        device_state = self._find_device_state(device_name)
        if device_state is None:
            # TODO: raise an exception?
            log.error("Can't find device to unlock %s", device_name)
            return False

        device = device_state.device
        device.format.passphrase = passphrase
        try:
            device.setup()
            device.format.setup()
            luks_device = LUKSDevice(device.format.map_name,
                                     parents=[device],
                                     exists=True)
            self._storage.devicetree._add_device(luks_device)

            # Wait for the device.
            # Otherwise, we could get a message about no Linux partitions.
            time.sleep(2)

            try_populate_devicetree(self._storage.devicetree)
        except StorageError as serr:
            log.error("Failed to unlock %s: %s", device.name, serr)
            device.teardown(recursive=True)
            device.format.passphrase = None
            return False
        else:
            device_state.set_unlocked(passphrase)
            return True
Esempio n. 2
0
    def unlock_device(self, device_name, passphrase):
        """Unlocks LUKS device."""
        device_state = self._find_device_state(device_name)
        if device_state is None:
            # TODO: raise an exception?
            log.error("Can't find device to unlock %s", device_name)
            return False

        device = device_state.device
        device.format.passphrase = passphrase
        try:
            device.setup()
            device.format.setup()
            luks_device = LUKSDevice(device.format.map_name,
                                     parents=[device],
                                     exists=True)
            self._storage.devicetree._add_device(luks_device)

            # Wait for the device.
            # Otherwise, we could get a message about no Linux partitions.
            time.sleep(2)

            try_populate_devicetree(self._storage.devicetree)
        except StorageError as serr:
            log.error("Failed to unlock %s: %s", device.name, serr)
            device.teardown(recursive=True)
            device.format.passphrase = None
            return False
        else:
            device_state.set_unlocked(passphrase)
            return True
Esempio n. 3
0
 def run(self):
     rc = self.window.run()
     self.window.destroy()
     # We need to call this to get the device nodes to show up
     # in our devicetree.
     if self._update_devicetree:
         try_populate_devicetree(self.storage.devicetree)
     return rc
Esempio n. 4
0
 def run(self):
     rc = self.window.run()
     self.window.destroy()
     # We need to call this to get the device nodes to show up
     # in our devicetree.
     if self._update_devicetree:
         try_populate_devicetree(self.storage.devicetree)
     return rc
Esempio n. 5
0
    def run(self):
        rc = self.window.run()
        self.window.destroy()

        if self._update_devicetree:
            try_populate_devicetree(self._storage.devicetree)

        return rc
Esempio n. 6
0
    def run(self):
        rc = self.window.run()
        self.window.destroy()

        if self._update_devicetree:
            try_populate_devicetree(self._storage.devicetree)

        return rc
Esempio n. 7
0
    def _unlock_devices(self):
        """
            Loop through devices and attempt to unlock any which are detected as
            LUKS devices.
        """
        try_passphrase = None
        for device in self.storage.devices:
            if device.format.type != "luks":
                continue

            skip = False
            unlocked = False
            while not (skip or unlocked):
                if try_passphrase is None:
                    p = PasswordDialog(self.app, device.name)
                    self.app.switch_screen_modal(p)
                    if p.answer:
                        passphrase = p.answer.strip()
                else:
                    passphrase = try_passphrase

                if passphrase is None:
                    # canceled
                    skip = True
                else:
                    device.format.passphrase = passphrase
                    try:
                        device.setup()
                        device.format.setup()
                        luks_dev = LUKSDevice(device.format.map_name,
                                              parents=[device],
                                              exists=True)
                        self.storage.devicetree._add_device(luks_dev)

                        # Wait for the device.
                        # Otherwise, we could get a message about no Linux partitions.
                        time.sleep(2)

                        try_populate_devicetree(self.storage.devicetree)
                        unlocked = True
                        # try to use the same passhprase for other devices
                        try_passphrase = passphrase
                    except StorageError as serr:
                        log.error("Failed to unlock %s: %s", device.name, serr)
                        device.teardown(recursive=True)
                        device.format.passphrase = None
                        try_passphrase = None
        return True
Esempio n. 8
0
    def _unlock_devices(self):
        """
            Loop through devices and attempt to unlock any which are detected as
            LUKS devices.
        """
        try_passphrase = None
        for device in self.storage.devices:
            if device.format.type != "luks":
                continue

            skip = False
            unlocked = False
            while not (skip or unlocked):
                if try_passphrase is None:
                    p = PasswordDialog(self.app, device.name)
                    self.app.switch_screen_modal(p)
                    if p.answer:
                        passphrase = p.answer.strip()
                else:
                    passphrase = try_passphrase

                if passphrase is None:
                    # canceled
                    skip = True
                else:
                    device.format.passphrase = passphrase
                    try:
                        device.setup()
                        device.format.setup()
                        luks_dev = LUKSDevice(device.format.mapName,
                                              parents=[device],
                                              exists=True)
                        self.storage.devicetree._addDevice(luks_dev)
                        try_populate_devicetree(self.storage.devicetree)
                        unlocked = True
                        # try to use the same passhprase for other devices
                        try_passphrase = passphrase
                    except StorageError as serr:
                        log.error("Failed to unlock %s: %s", device.name, serr)
                        device.teardown(recursive=True)
                        device.format.passphrase = None
                        try_passphrase = None
        return True
Esempio n. 9
0
 def on_refresh_clicked(self, widget, *args):
     try_populate_devicetree(self.storage.devicetree)
     self.refresh()
Esempio n. 10
0
 def on_refresh_clicked(self, widget, *args):
     try_populate_devicetree(self.storage.devicetree)
     self.refresh()
Esempio n. 11
0
 def _repopulate(self):
     log.info("nvdimm: repopulating device tree")
     self.storage.devicetree.reset()
     try_populate_devicetree(self.storage.devicetree)
     self._after_repopulate()
Esempio n. 12
0
 def _repopulate(self):
     log.info("nvdimm: repopulating device tree")
     self.storage.devicetree.reset()
     try_populate_devicetree(self.storage.devicetree)
     self._after_repopulate()