Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 43 additions & 20 deletions qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
from qubesadmin import utils
from qubesadmin.tools import qvm_start

# pylint: disable=import-error
from PyQt6 import QtWidgets

# pylint: disable=import-error
from PyQt6.QtCore import (Qt, QAbstractTableModel, QObject, pyqtSlot, QEvent,
QSettings, QRegularExpression, QSortFilterProxyModel,
Expand Down Expand Up @@ -959,6 +962,34 @@

def change_network(self, netvm_name):
selected_vms = self.get_selected_vms()
netvm = None
check_power = None

if netvm_name:
check_power = any(info.state['power'] == 'Running' for info
in self.get_selected_vms())
if netvm_name == 'default':
netvm = self._get_default_netvm()
else:
netvm = self.qubes_cache.get_vm(name=netvm_name)
netvm = netvm.vm

if netvm:
vms_tags = {tag
for selected_vm in selected_vms
for tag in selected_vm.vm.tags}
if 'anon-vm' in vms_tags and not 'anon-gateway' in netvm.tags:
QtWidgets.QMessageBox.warning(

Check warning on line 982 in qubesmanager/qube_manager.py

View check run for this annotation

Codecov / codecov/patch

qubesmanager/qube_manager.py#L982

Added line #L982 was not covered by tests
self,
self.tr("Warning!"),
self.tr(
"Anonymous qubes must be connected to an anonymous "
"gateway to ensure privacy and anonymity. By "
"changing the net qube to a gateway that does not "
"provide anonymity, your IP address will be leaked "
"on the Internet. Continue at your own risk.")
)

reply = QMessageBox.question(
self, self.tr("Network Change Confirmation"),
self.tr("Do you want to change '{0}'<br>"
Expand All @@ -969,27 +1000,19 @@
if reply != QMessageBox.StandardButton.Yes:
return

if netvm_name:
check_power = any(info.state['power'] == 'Running' for info
in self.get_selected_vms())
if netvm_name == 'default':
netvm = self._get_default_netvm()
else:
netvm = self.qubes_cache.get_vm(name=netvm_name)
netvm = netvm.vm
if check_power and netvm and not netvm.is_running():
reply = QMessageBox.question(
self, self.tr("Qube Start Confirmation"),
self.tr("<br>Can not change netvm to a halted Qube.<br>"
"Do you want to start the Qube <b>'{0}'</b>?").format(
netvm_name),
QMessageBox.StandardButton.Yes |
QMessageBox.StandardButton.Cancel)
if check_power and netvm and not netvm.is_running():
reply = QMessageBox.question(

Check warning on line 1004 in qubesmanager/qube_manager.py

View check run for this annotation

Codecov / codecov/patch

qubesmanager/qube_manager.py#L1004

Added line #L1004 was not covered by tests
self, self.tr("Qube Start Confirmation"),
self.tr("<br>Can not change netvm to a halted Qube.<br>"
"Do you want to start the Qube <b>'{0}'</b>?").format(
netvm_name),
QMessageBox.StandardButton.Yes |
QMessageBox.StandardButton.Cancel)

if reply == QMessageBox.StandardButton.Yes:
self.start_vm(netvm, True)
else:
return
if reply == QMessageBox.StandardButton.Yes:
self.start_vm(netvm, True)

Check warning on line 1013 in qubesmanager/qube_manager.py

View check run for this annotation

Codecov / codecov/patch

qubesmanager/qube_manager.py#L1012-L1013

Added lines #L1012 - L1013 were not covered by tests
else:
return

Check warning on line 1015 in qubesmanager/qube_manager.py

View check run for this annotation

Codecov / codecov/patch

qubesmanager/qube_manager.py#L1015

Added line #L1015 was not covered by tests

errors = []
for info in self.get_selected_vms():
Expand Down