Skip to content

Commit fbd3ec5

Browse files
committed
Hide internal qubes
For: QubesOS/qubes-issues#1512
1 parent 7d96daa commit fbd3ec5

7 files changed

Lines changed: 52 additions & 16 deletions

File tree

qubes_config/global_config/basics_handler.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,19 +740,27 @@ def __init__(self, gtk_builder: Gtk.Builder, qapp: qubesadmin.Qubes):
740740

741741
@staticmethod
742742
def _clock_vm_filter(vm) -> bool:
743-
return vm.klass != "TemplateVM"
743+
return (
744+
vm.klass != "TemplateVM"
745+
and not getattr(vm, "template_for_dispvms", False)
746+
and not get_boolean_feature(vm, "internal")
747+
)
744748

745749
@staticmethod
746750
def _default_template_filter(vm) -> bool:
747-
return vm.klass == "TemplateVM"
751+
return vm.klass == "TemplateVM" and not get_boolean_feature(vm, "internal")
748752

749753
@staticmethod
750754
def _default_netvm_filter(vm) -> bool:
751-
return getattr(vm, "provides_network", False)
755+
return getattr(vm, "provides_network", False) and not get_boolean_feature(
756+
vm, "internal"
757+
)
752758

753759
@staticmethod
754760
def _default_dispvm_filter(vm) -> bool:
755-
return getattr(vm, "template_for_dispvms", False)
761+
return getattr(vm, "template_for_dispvms", False) and not get_boolean_feature(
762+
vm, "internal"
763+
)
756764

757765
def save(self):
758766
for handler in self.handlers:

qubes_config/global_config/device_attachments.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from ..widgets.gtk_widgets import TokenName
3535
from ..widgets.gtk_utils import show_error
36+
from ..widgets.utils import get_boolean_feature
3637
from .device_widgets import (
3738
DevPolicyRow,
3839
DevPolicyDialogHandler,
@@ -122,7 +123,9 @@ def __init__(
122123
self.qapp,
123124
"edit_device",
124125
[],
125-
filter_function=lambda vm: vm.klass != "AdminVM",
126+
filter_function=lambda vm: vm.klass != "AdminVM"
127+
and not getattr(vm, "template_for_dispvms", False)
128+
and not get_boolean_feature(vm, "internal"),
126129
)
127130

128131
self.backend_vm: Optional[qubesadmin.vm.QubesVM] = None
@@ -398,7 +401,9 @@ def __init__(
398401
self.qapp,
399402
"required_device",
400403
[],
401-
filter_function=lambda vm: vm.klass != "AdminVM",
404+
filter_function=lambda vm: vm.klass != "AdminVM"
405+
and not getattr(vm, "template_for_dispvms", False)
406+
and not get_boolean_feature(vm, "internal"),
402407
)
403408

404409
self.dev_modeler = self.fill_combo_with_devices(

qubes_config/global_config/device_blocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from qubesadmin.device_protocol import DeviceCategory, DeviceInterface
2424

2525
from ..widgets.gtk_widgets import TokenName, VMListModeler
26+
from ..widgets.utils import get_feature
2627
from .device_widgets import (
2728
DevPolicyDialogHandler,
2829
DevPolicyRow,
@@ -57,7 +58,8 @@ def __init__(self, builder: Gtk.Builder, qapp, parent_window: Gtk.Window):
5758
self.qube_model = VMListModeler(
5859
combobox=self.qube_combo,
5960
qapp=self.qapp,
60-
filter_function=lambda vm: vm.klass != "AdminVM",
61+
filter_function=lambda vm: vm.klass != "AdminVM"
62+
and not get_feature(vm, "internal"),
6163
current_value=None,
6264
)
6365
self.qube_model.connect_change_callback(self._qube_selected)

qubes_config/global_config/rule_list_widgets.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
TokenName,
2828
)
2929
from ..widgets.gtk_utils import show_error, ask_question
30-
from ..widgets.utils import BiDictionary
30+
from ..widgets.utils import get_boolean_feature, BiDictionary
3131
from .policy_rules import AbstractRuleWrapper, AbstractVerbDescription
3232

3333
import gi
@@ -106,7 +106,9 @@ def __init__(
106106
self.qapp = qapp
107107
self.selected_value = initial_value
108108
self.filter_function = (
109-
filter_function if filter_function else lambda x: str(x) != "dom0"
109+
filter_function
110+
if filter_function
111+
else lambda x: str(x) != "dom0" and not get_boolean_feature(x, "internal")
110112
)
111113

112114
self.combobox: Gtk.ComboBox = Gtk.ComboBox.new_with_entry()
@@ -686,7 +688,9 @@ def __init__(
686688

687689
@staticmethod
688690
def _dvm_template_filter(vm: qubesadmin.vm.QubesVM):
689-
return getattr(vm, "template_for_dispvms", False)
691+
return getattr(vm, "template_for_dispvms", False) and not get_boolean_feature(
692+
vm, "internal"
693+
)
690694

691695
def _hide_target_on_deny(self):
692696
if self.action_widget.get_selected() == "deny":

qubes_config/global_config/updates_handler.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,17 @@ def _check_for_whonix(self) -> bool:
450450

451451
@staticmethod
452452
def _updatevm_filter(vm):
453-
return getattr(vm, "provides_network", False)
453+
return getattr(vm, "provides_network", False) and not get_boolean_feature(
454+
vm, "internal"
455+
)
454456

455457
@staticmethod
456458
def _whonixupdatevm_filter(vm):
457-
return "anon-gateway" in vm.tags
459+
return (
460+
"anon-gateway" in vm.tags
461+
and vm.klass != "TemplateVM"
462+
and not get_boolean_feature(vm, "internal")
463+
)
458464

459465
@staticmethod
460466
def _rule_filter(rule):
@@ -466,6 +472,8 @@ def _rule_filter(rule):
466472

467473
@staticmethod
468474
def _needs_updatevm_filter(vm):
475+
if get_boolean_feature(vm, "internal"):
476+
return False
469477
if vm.klass in ("AdminVM", "AppVM"):
470478
return False
471479
if vm.klass == "StandaloneVM":
@@ -683,6 +691,8 @@ def __init__(
683691
lambda vm: vm.klass != "TemplateVM"
684692
and vm.klass != "AdminVM"
685693
and vm.is_networked()
694+
and not getattr(vm, "template_for_dispvms", False)
695+
and not get_boolean_feature(vm, "internal")
686696
),
687697
current_value=self.qapp.updatevm,
688698
additional_options=NONE_CATEGORY,

qubes_config/global_config/usb_devices.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ def load_rules_for_usb_qube(self):
465465
self.error_handler.clear_all_errors()
466466

467467
for vm in self.qapp.domains:
468+
if get_feature(vm, "internal"):
469+
continue
468470
if vm.features.check_with_template(self.SUPPORTED_SERVICE_FEATURE):
469471
if vm == usb_qube:
470472
continue

qubes_config/new_qube/template_handler.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import qubesadmin.vm
2929
from ..widgets.gtk_widgets import VMListModeler
3030
from ..widgets.gtk_utils import show_error
31+
from ..widgets.utils import get_boolean_feature
3132
from .application_selector import ApplicationData
3233

3334
import gi
@@ -261,28 +262,32 @@ def __init__(self, gtk_builder: Gtk.Builder, qapp: qubesadmin.Qubes):
261262
gtk_builder=gtk_builder,
262263
qapp=self.qapp,
263264
name_suffix="app",
264-
filter_function=lambda x: x.klass == "TemplateVM",
265+
filter_function=lambda x: x.klass == "TemplateVM"
266+
and not get_boolean_feature(x, "internal"),
265267
default_value=self.qapp.default_template,
266268
),
267269
"qube_type_template": TemplateSelectorNoneCombo(
268270
gtk_builder=gtk_builder,
269271
qapp=self.qapp,
270272
name_suffix="template",
271-
filter_function=lambda x: x.klass == "TemplateVM",
273+
filter_function=lambda x: x.klass == "TemplateVM"
274+
and not get_boolean_feature(x, "internal"),
272275
default_value=None,
273276
),
274277
"qube_type_standalone": TemplateSelectorNoneCombo(
275278
gtk_builder=gtk_builder,
276279
qapp=self.qapp,
277280
name_suffix="standalone",
278-
filter_function=lambda x: x.klass in ("TemplateVM", "StandaloneVM"),
281+
filter_function=lambda x: x.klass in ("TemplateVM", "StandaloneVM")
282+
and not get_boolean_feature(x, "internal"),
279283
default_value=None,
280284
),
281285
"qube_type_disposable": TemplateSelectorCombo(
282286
gtk_builder=gtk_builder,
283287
qapp=self.qapp,
284288
name_suffix="dispvm",
285-
filter_function=lambda x: getattr(x, "template_for_dispvms", False),
289+
filter_function=lambda x: getattr(x, "template_for_dispvms", False)
290+
and not get_boolean_feature(x, "internal"),
286291
default_value=self.qapp.default_dispvm,
287292
),
288293
}

0 commit comments

Comments
 (0)