Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/646'
Browse files Browse the repository at this point in the history
* origin/pr/646:
  Do not set timezone for VMs with anon-timezone feature
  • Loading branch information
marmarek committed Jan 8, 2025
2 parents 74b877e + c76735f commit 6dbdfc7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
52 changes: 28 additions & 24 deletions qubes/tests/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2163,31 +2163,35 @@ def test_620_qdb_standalone(
"-A FORWARD -i vif+ -o vif+ -j DROP\n"
"COMMIT\n".format(datetime.datetime.now().ctime())
)
data = {
"/name": "test-inst-test",
"/type": "StandaloneVM",
"/default-user": "user",
"/qubes-vm-type": "AppVM",
"/qubes-debug-mode": "0",
"/qubes-base-template": "",
"/qubes-timezone": "UTC",
"/qubes-random-seed": base64.b64encode(b"A" * 64),
"/qubes-vm-persistence": "full",
"/qubes-vm-updateable": "True",
"/qubes-block-devices": "",
"/qubes-usb-devices": "",
"/qubes-iptables": "reload",
"/qubes-iptables-error": "",
"/qubes-iptables-header": iptables_header,
"/qubes-service/qubes-update-check": "0",
"/qubes-service/meminfo-writer": "1",
"/connected-ips": "",
"/connected-ips6": "",
}

self.assertEqual(
test_qubesdb.data,
{
"/name": "test-inst-test",
"/type": "StandaloneVM",
"/default-user": "user",
"/qubes-vm-type": "AppVM",
"/qubes-debug-mode": "0",
"/qubes-base-template": "",
"/qubes-timezone": "UTC",
"/qubes-random-seed": base64.b64encode(b"A" * 64),
"/qubes-vm-persistence": "full",
"/qubes-vm-updateable": "True",
"/qubes-block-devices": "",
"/qubes-usb-devices": "",
"/qubes-iptables": "reload",
"/qubes-iptables-error": "",
"/qubes-iptables-header": iptables_header,
"/qubes-service/qubes-update-check": "0",
"/qubes-service/meminfo-writer": "1",
"/connected-ips": "",
"/connected-ips6": "",
},
)
self.assertEqual(test_qubesdb.data, data)

test_qubesdb.data.clear()
vm.features["anon-timezone"] = "1"
vm.create_qdb_entries()
del data["/qubes-timezone"]
self.assertEqual(test_qubesdb.data, data)

@unittest.mock.patch("datetime.datetime")
@unittest.mock.patch("qubes.utils.get_timezone")
Expand Down
6 changes: 5 additions & 1 deletion qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2616,8 +2616,12 @@ def create_qdb_entries(self):
)

tzname = qubes.utils.get_timezone()
if tzname:
if tzname and not self.features.check_with_template(
"anon-timezone", False
):
self.untrusted_qdb.write("/qubes-timezone", tzname)
else:
self.untrusted_qdb.rm("/qubes-timezone")

self.untrusted_qdb.write("/qubes-block-devices", "")
self.untrusted_qdb.write("/qubes-usb-devices", "")
Expand Down

0 comments on commit 6dbdfc7

Please sign in to comment.