diff options
author | Papoteur <papoteur@mageia.org> | 2020-01-20 09:42:52 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2020-01-20 09:42:52 +0100 |
commit | 6bf666a534f5376ba813b0aaf8993691d2925496 (patch) | |
tree | df20b98b0257618d994f2736107b08383cc82693 /lib | |
parent | 9f89ca4f026e708f7a5ddc59a0f0ee5f581ef37c (diff) | |
download | isodumper-6bf666a534f5376ba813b0aaf8993691d2925496.tar isodumper-6bf666a534f5376ba813b0aaf8993691d2925496.tar.gz isodumper-6bf666a534f5376ba813b0aaf8993691d2925496.tar.bz2 isodumper-6bf666a534f5376ba813b0aaf8993691d2925496.tar.xz isodumper-6bf666a534f5376ba813b0aaf8993691d2925496.zip |
Add encryption for persistent partition
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/isodumper.py | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index 785c996..23c506b 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -116,7 +116,7 @@ class Info(object): self.richtext=richtext self.text=text - + class IsoDumper(object): RELEASE="v1.15" @@ -212,12 +212,14 @@ class IsoDumper(object): self.progress.setDisabled() self.refreshbt.setEnabled() self.persistencecb.setDisabled() + self.cryptcb.setDisabled() + self.cryptkey.setDisabled() def onProgress(self, frac): self.logger(_('Wrote: {}% '.format(frac))) self.progress.setValue(frac) self.dialog.pollEvent() - + def raw_format(self, usb_path, fstype, label): self.operation=True if os.geteuid() > 0: @@ -310,7 +312,6 @@ class IsoDumper(object): success, message = iface.do_unmount(target) if success: #Writing step - #Dump mode iface.do_write(source, target, b) iface.get_sum(source) progress = iface.progress @@ -324,8 +325,8 @@ class IsoDumper(object): self.logger(_('Image {source} successfully written to {target}').format( source=source.split('/')[-1], target=target)) self.logger(_('Bytes written: ')+str(b)) self.progress.setLabel(_('Checking ')+target.split('/')[-1]) - self.progress.setValue(0) - self.dialog.pollEvent() + self.progress.setValue(0) + self.dialog.pollEvent() # Checking iface.check_write(target, source) progress = iface.progress @@ -340,13 +341,20 @@ class IsoDumper(object): self.dialog.pollEvent() self.logger(message) # Add persistent partition if asked - if self.persistencecb.value(): + if self.persistencecb.isChecked(): self.logger(_("Adding persistent partition")) - iface.do_persistence(target,"mgalive-persist") - self.logger(_("Added persistent partition")) + if self.cryptcb.isChecked(): + if self.cryptkey.value() == "": + self.logger(_("No key for crypted partition provided. Adding the partition aborted.")) + else: + iface.do_persistence(target,"mgalive-persist",self.cryptkey.value()) + self.logger(_("Added crypted persistent partition")) + else: + iface.do_persistence(target,"mgalive-persist", "") + self.logger(_("Added persistent partition")) #Eject self.u.eject(target) - self.success() + self.success() else: self.emergency(message) else: @@ -401,7 +409,7 @@ class IsoDumper(object): self.backupbt.setDisabled() self.refreshbt.setDisabled() self.persistencecb.setDisabled() - + def close(self): self.write_logfile() self.dialog.destroy() @@ -473,13 +481,13 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B #TODO Read log level from command line - + # define size of the selected device self.deviceSize=0 # Operation running self.operation=False - + self.ChooseImage = _("Choose an image") self.warning = _("Warning\nThis will destroy all data on the target device,\n\ are you sure you want to proceed?\n\ @@ -528,8 +536,17 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B self.writebt = self.atelier.createPushButton(self.writebox, _("&Write to device" )) self.writebt.setDisabled() self.persistencebox = self.atelier.createHBox(self.box) - self.persistencecb = self.atelier.createCheckBox(self.persistencebox, _("Add a persistent partition in the remaining space")) + self.persistencecol1 = self.atelier.createVBox(self.persistencebox) + self.persistencecol2 = self.atelier.createVBox(self.persistencebox) + self.persistencecb = self.atelier.createCheckBox(self.persistencecol1, _("Add a persistent partition in the remaining space")) + self.persistencebox2 = self.atelier.createHBox(self.box) + self.cryptcb = self.atelier.createCheckBox(self.persistencecol1, _("Crypt partition")) + self.cryptkey = self.atelier.createInputField(self.persistencecol2, _("Key:")) self.persistencecb.setDisabled() + self.persistencecb.setNotify() + self.cryptcb.setDisabled() + self.cryptcb.setNotify() + self.cryptkey.setDisabled() self.backupbox = self.atelier.createHBox(self.box) self.atelier.createLabel(self.backupbox,_("Backup to:")) # add file picker for backup file name @@ -576,7 +593,7 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B self.ancrage.showChild() def ask_format(self): - atelier = yui.YUI.widgetFactory() + atelier = yui.YUI.widgetFactory() dialog = atelier.createPopupDialog() # dialog.setTitle(_("Choose format")) vb=atelier.createVBox(dialog) @@ -626,7 +643,7 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B return True,format_type,format_label else: return False," "," " - + def ask_OK(self, info): yui.YUI.widgetFactory @@ -655,7 +672,7 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B dlg = mgafactory.createAboutDialog("Isodumper", self.RELEASE, "GPLv2", _("Oliver Grawert<BR />Papoteur<BR />Pictures : Timothée Giet"), _("A tool for writing ISO images to a device")+"<BR />http://gitweb.mageia.org/software/isodumper", "") dlg.show(); - + def nodevDialog(self): yui.YUI.widgetFactory mgafactory = yui.YMGAWidgetFactory.getYMGAWidgetFactory(yui.YExternalWidgets.externalWidgetFactory("mga")) @@ -685,6 +702,19 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B self.writebt.setEnabled() self.activate_devicelist() self.persistencecb.setEnabled() + if event.widget() == self.persistencecb: + print(self.persistencecb.value) + if self.persistencecb.isChecked() : + self.cryptcb.setEnabled() + else: + self.cryptcb.setDisabled() + self.cryptkey.setDisabled() + self.cryptcb.setChecked(False) + if event.widget() == self.cryptcb: + if self.cryptcb.isChecked() : + self.cryptkey.setEnabled() + else: + self.cryptkey.setDisabled() if event.widget() == self.writebt: self.wip_unsensitive() self.do_write() @@ -728,7 +758,7 @@ NTFS or ext. You can specify a volume name and the format in a new dialog box.<B except Exception as e: print(str(e)) yui.YDialog.deleteAllDialogs() - + if __name__ == "__main__": app = IsoDumper() @@ -736,4 +766,3 @@ if __name__ == "__main__": # next line seems to be a workaround to prevent the qt-app from crashing # see https://github.com/libyui/libyui-qt/issues/41 yui.YUILoader.deleteUI() - |