Skip to content

Commit 00beb5e

Browse files
committed
Merge remote-tracking branch 'origin/pr/422'
* origin/pr/422: anon gateway warning box on main qubesmanager page Pull request description: Solves: > Please re-open. > > [A user reported](https://forums.whonix.org/t/re-stop-users-from-changing-their-anon-whonix-net-qube-to-sys-firewall-to-avoid-ip-leaks/17255/7): > > I remember looking at this and patching my Qubes Manager temporarily and it failed to account for switching NetVM in the basic view. The pop up only shows in the settings tab, meaning this is only half solved > > This should be verified and reported before 4.3 is out, I have not checked the code again _Originally posted by @adrelanos in [#8551](QubesOS/qubes-issues#8551 (comment)
2 parents 4529252 + b682d54 commit 00beb5e

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

qubesmanager/qube_manager.py

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
from qubesadmin import utils
3434
from qubesadmin.tools import qvm_start
3535

36+
# pylint: disable=import-error
37+
from PyQt6 import QtWidgets
38+
3639
# pylint: disable=import-error
3740
from PyQt6.QtCore import (Qt, QAbstractTableModel, QObject, pyqtSlot, QEvent,
3841
QSettings, QRegularExpression, QSortFilterProxyModel,
@@ -959,6 +962,34 @@ def change_template(self, template):
959962

960963
def change_network(self, netvm_name):
961964
selected_vms = self.get_selected_vms()
965+
netvm = None
966+
check_power = None
967+
968+
if netvm_name:
969+
check_power = any(info.state['power'] == 'Running' for info
970+
in self.get_selected_vms())
971+
if netvm_name == 'default':
972+
netvm = self._get_default_netvm()
973+
else:
974+
netvm = self.qubes_cache.get_vm(name=netvm_name)
975+
netvm = netvm.vm
976+
977+
if netvm:
978+
vms_tags = {tag
979+
for selected_vm in selected_vms
980+
for tag in selected_vm.vm.tags}
981+
if 'anon-vm' in vms_tags and not 'anon-gateway' in netvm.tags:
982+
QtWidgets.QMessageBox.warning(
983+
self,
984+
self.tr("Warning!"),
985+
self.tr(
986+
"Anonymous qubes must be connected to an anonymous "
987+
"gateway to ensure privacy and anonymity. By "
988+
"changing the net qube to a gateway that does not "
989+
"provide anonymity, your IP address will be leaked "
990+
"on the Internet. Continue at your own risk.")
991+
)
992+
962993
reply = QMessageBox.question(
963994
self, self.tr("Network Change Confirmation"),
964995
self.tr("Do you want to change '{0}'<br>"
@@ -969,27 +1000,19 @@ def change_network(self, netvm_name):
9691000
if reply != QMessageBox.StandardButton.Yes:
9701001
return
9711002

972-
if netvm_name:
973-
check_power = any(info.state['power'] == 'Running' for info
974-
in self.get_selected_vms())
975-
if netvm_name == 'default':
976-
netvm = self._get_default_netvm()
977-
else:
978-
netvm = self.qubes_cache.get_vm(name=netvm_name)
979-
netvm = netvm.vm
980-
if check_power and netvm and not netvm.is_running():
981-
reply = QMessageBox.question(
982-
self, self.tr("Qube Start Confirmation"),
983-
self.tr("<br>Can not change netvm to a halted Qube.<br>"
984-
"Do you want to start the Qube <b>'{0}'</b>?").format(
985-
netvm_name),
986-
QMessageBox.StandardButton.Yes |
987-
QMessageBox.StandardButton.Cancel)
1003+
if check_power and netvm and not netvm.is_running():
1004+
reply = QMessageBox.question(
1005+
self, self.tr("Qube Start Confirmation"),
1006+
self.tr("<br>Can not change netvm to a halted Qube.<br>"
1007+
"Do you want to start the Qube <b>'{0}'</b>?").format(
1008+
netvm_name),
1009+
QMessageBox.StandardButton.Yes |
1010+
QMessageBox.StandardButton.Cancel)
9881011

989-
if reply == QMessageBox.StandardButton.Yes:
990-
self.start_vm(netvm, True)
991-
else:
992-
return
1012+
if reply == QMessageBox.StandardButton.Yes:
1013+
self.start_vm(netvm, True)
1014+
else:
1015+
return
9931016

9941017
errors = []
9951018
for info in self.get_selected_vms():

0 commit comments

Comments
 (0)