Browse Source

ext/r3compatibility: features/services

QubesOS/qubes-issues#1812
Marek Marczykowski-Górecki 8 years ago
parent
commit
b6d8c7fb81
1 changed files with 17 additions and 0 deletions
  1. 17 0
      qubes/ext/r3compatibility.py

+ 17 - 0
qubes/ext/r3compatibility.py

@@ -37,6 +37,14 @@ class R3Compatibility(qubes.ext.Extension):
     '''Maintain VM interface compatibility with R3.0 and R3.1.
     At lease where possible.
     '''
+
+    features_to_services = {
+        'services/ntpd': 'ntpd',
+        'check-updates': 'qubes-update-check',
+        'dvm': 'qubes-dvm',
+
+    }
+
     # noinspection PyUnusedLocal
     @qubes.ext.handler('qdb-created')
     def on_qdb_created(self, vm, event):
@@ -107,6 +115,8 @@ class R3Compatibility(qubes.ext.Extension):
         vm.qdb.write("/qubes-iptables-error", '')
         self.write_iptables_qubesdb_entry(vm)
 
+        self.write_services(vm)
+
     # FIXME use event after creating Xen domain object, but before "resume"
     @qubes.ext.handler('domain-started')
     def on_domain_started(self, vm, event, **kwargs):
@@ -212,3 +222,10 @@ class R3Compatibility(qubes.ext.Extension):
         # no need for ending -A FORWARD -j DROP, cause default action is DROP
 
         firewallvm.qdb.write("/qubes-iptables", 'reload')
+
+    def write_services(self, vm):
+        for feature, value in vm.features.items():
+            service = self.features_to_services.get(feature, feature)
+            # forcefully convert to '0' or '1'
+            vm.qdb.write('/qubes-service/{}'.format(service),
+                str(int(bool(value))))