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
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
def run(self): rc = self.window.run() self.window.destroy() if self._update_devicetree: try_populate_devicetree(self._storage.devicetree) return rc
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
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
def on_refresh_clicked(self, widget, *args): try_populate_devicetree(self.storage.devicetree) self.refresh()
def _repopulate(self): log.info("nvdimm: repopulating device tree") self.storage.devicetree.reset() try_populate_devicetree(self.storage.devicetree) self._after_repopulate()