Skip to content

Commit

Permalink
qubes.NotifyTools: ignore '/qubes-tools/version' completely
Browse files Browse the repository at this point in the history
It isn't used for anything, so simply ignore it for good.

#109 (comment)
  • Loading branch information
marmarek committed Jun 14, 2017
1 parent 55669c3 commit 86a935e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 41 deletions.
2 changes: 1 addition & 1 deletion qubes/api/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def qubes_notify_tools(self):

untrusted_features = {}
safe_set = string.ascii_letters + string.digits
expected_features = ('version', 'qrexec', 'gui', 'default-user')
expected_features = ('qrexec', 'gui', 'default-user')
for feature in expected_features:
untrusted_value = self.src.qdb.read('/qubes-tools/' + feature)
if untrusted_value:
Expand Down
6 changes: 0 additions & 6 deletions qubes/ext/core_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ def qubes_features_request(self, vm, event, untrusted_features):
'Ignoring qubes.NotifyTools for template-based VM')
return

# for now used only to check for the tools presence
if 'version' in untrusted_features:
# any suspicious string will raise exception here,
# but otherwise ignored
int(untrusted_features['version'])

requested_features = {}
for feature in ('qrexec', 'gui'):
untrusted_value = untrusted_features.get(feature, None)
Expand Down
22 changes: 0 additions & 22 deletions qubes/tests/api_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,11 @@ def test_010_notify_tools(self):
mock.call.save()
])
self.assertEqual(self.src.mock_calls, [
mock.call.qdb.read('/qubes-tools/version'),
mock.call.qdb.read('/qubes-tools/qrexec'),
mock.call.qdb.read('/qubes-tools/gui'),
mock.call.qdb.read('/qubes-tools/default-user'),
mock.call.fire_event('features-request', untrusted_features={
'gui': '1',
'version': '1',
'default-user': 'user',
'qrexec': '1'}),
])
Expand All @@ -148,7 +146,6 @@ def test_013_notify_tools_no_version(self):
response = self.call_mgmt_func(b'qubes.NotifyTools')
self.assertIsNone(response)
self.assertEqual(self.src.mock_calls, [
mock.call.qdb.read('/qubes-tools/version'),
mock.call.qdb.read('/qubes-tools/qrexec'),
mock.call.qdb.read('/qubes-tools/gui'),
mock.call.qdb.read('/qubes-tools/default-user'),
Expand All @@ -159,23 +156,6 @@ def test_013_notify_tools_no_version(self):
])
self.assertEqual(self.app.mock_calls, [mock.call.save()])

def test_014_notify_tools_invalid_version(self):
qdb_entries = {
'/qubes-tools/version': b'this is invalid',
'/qubes-tools/qrexec': b'0',
'/qubes-tools/gui': b'0',
'/qubes-tools/os': b'Linux',
'/qubes-tools/default-user': b'user',
}
self.configure_qdb(qdb_entries)
with self.assertRaises(AssertionError):
self.call_mgmt_func(b'qubes.NotifyTools')
# should be rejected later
self.assertEqual(self.src.mock_calls, [
mock.call.qdb.read('/qubes-tools/version'),
])
self.assertEqual(self.app.mock_calls, [])

def test_015_notify_tools_invalid_value_qrexec(self):
qdb_entries = {
'/qubes-tools/version': b'1',
Expand All @@ -189,7 +169,6 @@ def test_015_notify_tools_invalid_value_qrexec(self):
self.call_mgmt_func(b'qubes.NotifyTools')
self.assertEqual(self.app.mock_calls, [])
self.assertEqual(self.src.mock_calls, [
mock.call.qdb.read('/qubes-tools/version'),
mock.call.qdb.read('/qubes-tools/qrexec'),
])

Expand All @@ -206,7 +185,6 @@ def test_016_notify_tools_invalid_value_gui(self):
self.call_mgmt_func(b'qubes.NotifyTools')
self.assertEqual(self.app.mock_calls, [])
self.assertEqual(self.src.mock_calls, [
mock.call.qdb.read('/qubes-tools/version'),
mock.call.qdb.read('/qubes-tools/qrexec'),
mock.call.qdb.read('/qubes-tools/gui'),
])
Expand Down
12 changes: 0 additions & 12 deletions qubes/tests/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ def test_013_notify_tools_no_version(self):
('fire_event', ('template-postinstall',), {})
])

def test_014_notify_tools_invalid_version(self):
del self.vm.template
with self.assertRaises(ValueError):
self.ext.qubes_features_request(self.vm, 'features-request',
untrusted_features={
'version': 'this is invalid',
'qrexec': '1',
'gui': '1',
'default-user': 'user',
})
self.assertEqual(self.vm.mock_calls, [])

def test_015_notify_tools_invalid_value_qrexec(self):
del self.vm.template
self.ext.qubes_features_request(self.vm, 'features-request',
Expand Down

0 comments on commit 86a935e

Please sign in to comment.