From 5f866603056616889b32e142b0d4181532f02823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 11 Dec 2019 00:44:48 +0100 Subject: [PATCH 1/3] Added handling for supported services to VM settings Slight change to layout of services tab, made it hopefully less confusing. Dropdown will now list services supported by this VM and its template, not just an assortment of hardcoded services. --- qubesmanager/settings.py | 54 ++++++++++------- ui/settingsdlg.ui | 123 +++++++++++++++++++++++---------------- 2 files changed, 105 insertions(+), 72 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 73bf647..56a6fef 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -209,8 +209,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): ####### services tab self.__init_services_tab__() - self.service_line_edit.lineEdit().returnPressed.connect( - self.__add_service__) self.add_srv_button.clicked.connect(self.__add_service__) self.remove_srv_button.clicked.connect(self.__remove_service__) @@ -1074,35 +1072,49 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.services_list.addItem(item) self.new_srv_dict[service] = self.vm.features[feature] - # add suggested services - self.service_line_edit.addItem('clocksync') - self.service_line_edit.addItem('crond') - self.service_line_edit.addItem('cups') - self.service_line_edit.addItem('disable-default-route') - self.service_line_edit.addItem('disable-dns-server') - self.service_line_edit.addItem('network-manager') - self.service_line_edit.addItem('qubes-firewall') - self.service_line_edit.addItem('qubes-network') - self.service_line_edit.addItem('qubes-update-check') - self.service_line_edit.addItem('qubes-updates-proxy') - self.service_line_edit.addItem('qubes-yum-proxy') - self.service_line_edit.addItem('updates-proxy-setup') - self.service_line_edit.addItem('yum-proxy-setup') + self.service_line_edit.addItem("") + + supported_services = [] + service_prefix = "supported-service." + + for feature in self.vm.features: + if feature.startswith(service_prefix): + supported_services.append(feature[len(service_prefix):]) + if getattr(self.vm, "template", None): + for feature in self.vm.template.features: + if feature.startswith(service_prefix): + supported_services.add(feature[len(service_prefix):]) + + for service in sorted(supported_services): + self.service_line_edit.addItem(service) + + self.service_line_edit.addItem(self.tr('(custom...)')) self.service_line_edit.setEditText("") def __add_service__(self): srv = str(self.service_line_edit.currentText()).strip() + if srv != "": + if self.service_line_edit.currentIndex() == \ + len(self.service_line_edit) - 1: + (custom_name, ok) = QtWidgets.QInputDialog.getText( + self, self.tr("Custom service name"), + self.tr( + "Name of the service:")) + if ok: + srv = custom_name.strip() + else: + return if srv in self.new_srv_dict: QtWidgets.QMessageBox.information( self, '', self.tr('Service already on the list!')) - else: - item = QtWidgets.QListWidgetItem(srv) - item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked) - self.services_list.addItem(item) - self.new_srv_dict[srv] = True + return + item = QtWidgets.QListWidgetItem(srv) + item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked) + self.services_list.addItem(item) + self.new_srv_dict[srv] = True def __remove_service__(self): item = self.services_list.currentItem() diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index e5f7563..96e51c6 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 1 + 5 @@ -1433,47 +1433,85 @@ The qube must be running to disable seamless mode; this setting is not persisten Services - - - - Qt::Vertical + + + + + 0 + 0 + - - - 20 - 40 - - - + - - - - + Checked services will be turned on. - - - - Unchecked services will be turned off. - - - - + Unlisted services will follow default settings. - + + + + Unchecked services will be turned off. + + + + + + + + + Select a service: + + + + + + + + 0 + 0 + + + + Services listed here are explicitly supported by the qube. Additional services may be added with the '+' button on the right. + + + + + + + + + + Add + + + + :/add.png:/add.png + + + + 24 + 24 + + + + + + + - + Remove service @@ -1487,32 +1525,18 @@ The qube must be running to disable seamless mode; this setting is not persisten - - - - Services listed here are only base Qubes services - other services may be installed and implemented. + + + + Qt::Vertical - - true - - - - - - - - - - - :/add.png:/add.png - - + - 24 - 24 + 20 + 40 - + @@ -1568,10 +1592,7 @@ The qube must be running to disable seamless mode; this setting is not persisten temp_full_access_time no_strict_reset_button refresh_apps_button - service_line_edit - add_srv_button services_list - remove_srv_button From 4298de656446da37aa822dadbff5fa53d1eaf4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 11 Dec 2019 23:22:32 +0100 Subject: [PATCH 2/3] Moved debug mode checkbox to advanced settings It really had no place in Basic settings, and will free up space for future settings. --- qubesmanager/settings.py | 32 ++++++++++++++++---------------- ui/settingsdlg.ui | 29 ++++++++++++++--------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 56a6fef..a1221f2 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -395,12 +395,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.include_in_backups.setChecked(self.vm.include_in_backups) - try: - self.run_in_debug_mode.setChecked(self.vm.debug) - self.run_in_debug_mode.setVisible(True) - except AttributeError: - self.run_in_debug_mode.setVisible(False) - try: self.autostart_vm.setChecked(self.vm.autostart) self.autostart_vm.setVisible(True) @@ -477,14 +471,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) - # run_in_debug_mode - try: - if self.run_in_debug_mode.isVisible(): - if self.vm.debug != self.run_in_debug_mode.isChecked(): - self.vm.debug = self.run_in_debug_mode.isChecked() - except qubesadmin.exc.QubesException as ex: - msg.append(str(ex)) - # autostart_vm try: if self.autostart_vm.isVisible(): @@ -732,6 +718,12 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): "NetVM by the following qubes:\n") + "\n".join(domains_using)) + try: + self.run_in_debug_mode.setChecked(self.vm.debug) + self.run_in_debug_mode.setVisible(True) + except AttributeError: + self.run_in_debug_mode.setVisible(False) + def enable_seamless(self): self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS') @@ -810,6 +802,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): except Exception as ex: # pylint: disable=broad-except msg.append(str(ex)) + # run_in_debug_mode + try: + if self.run_in_debug_mode.isVisible(): + if self.vm.debug != self.run_in_debug_mode.isChecked(): + self.vm.debug = self.run_in_debug_mode.isChecked() + except qubesadmin.exc.QubesException as ex: + msg.append(str(ex)) + return msg def include_in_balancing_changed(self, state): @@ -1074,12 +1074,12 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.service_line_edit.addItem("") - supported_services = [] + supported_services = set() service_prefix = "supported-service." for feature in self.vm.features: if feature.startswith(service_prefix): - supported_services.append(feature[len(service_prefix):]) + supported_services.add(feature[len(service_prefix):]) if getattr(self.vm, "template", None): for feature in self.vm.template.features: if feature.startswith(service_prefix): diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index 96e51c6..3bb901a 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 5 + 1 @@ -373,13 +373,6 @@ - - - - Run in debug mode - - - @@ -813,14 +806,14 @@ border-width: 1px; 15 - + Provides network - + <html><head/><body><p>Allows using this qube as a template for DisposableVMs. The DisposableVMs will inherit the VM's state (configuration, installed programs etc.), but their state will not persist between restarts. </p><p>Setting this option will cause this qube to be listed as an option in the &quot;Default DisposableVM Template&quot; dropdown for all other qubes. </p></body></html> @@ -830,14 +823,14 @@ border-width: 1px; - + Boot qube from CDROM - + @@ -863,7 +856,7 @@ The qube must be running to disable seamless mode; this setting is not persisten - + @@ -893,6 +886,13 @@ The qube must be running to disable seamless mode; this setting is not persisten + + + + Run in debug mode + + + @@ -1322,7 +1322,7 @@ The qube must be running to disable seamless mode; this setting is not persisten This qube has direct network access and Qubes Firewall settings will not be used. Configure other qubes' network access in their network settings or in a dedicated firewall qube. - true + true @@ -1564,7 +1564,6 @@ The qube must be running to disable seamless mode; this setting is not persisten template_name netVM include_in_backups - run_in_debug_mode autostart_vm max_priv_storage root_resize From 6a5b0a3b8bc6425eca49da4586c89a4812c1f9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 11 Dec 2019 23:26:29 +0100 Subject: [PATCH 3/3] Fixed tab order --- ui/settingsdlg.ui | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index 3bb901a..bb29417 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 1 + 5 @@ -1573,6 +1573,7 @@ The qube must be running to disable seamless mode; this setting is not persisten max_mem_size vcpus include_in_balancing + run_in_debug_mode provides_network_checkbox dvm_template_checkbox default_dispvm @@ -1591,7 +1592,10 @@ The qube must be running to disable seamless mode; this setting is not persisten temp_full_access_time no_strict_reset_button refresh_apps_button + service_line_edit + add_srv_button services_list + remove_srv_button