api/admin: report unexpected driver options in admin.pool.Add

Fixes QubesOS/qubes-issues#5895
This commit is contained in:
Rusty Bird 2020-06-22 14:03:16 +00:00
parent c4739b7ed0
commit 8f1d59e9af
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF
2 changed files with 6 additions and 3 deletions

View File

@ -694,8 +694,11 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
self.enforce(pool_name not in self.app.pools)
driver_parameters = qubes.storage.driver_parameters(self.arg)
self.enforce(
all(key in driver_parameters for key in untrusted_pool_config))
unexpected_parameters = [key for key in untrusted_pool_config
if key not in driver_parameters]
if unexpected_parameters:
raise qubes.exc.QubesException(
'unexpected driver options: ' + ' '.join(unexpected_parameters))
pool_config = untrusted_pool_config
self.fire_event_for_permission(name=pool_name,

View File

@ -768,7 +768,7 @@ netvm default=True type=vm \n'''
add_pool_mock, self.app.add_pool = self.coroutine_mock()
with self.assertRaises(qubes.api.PermissionDenied):
with self.assertRaises(qubes.exc.QubesException):
self.call_mgmt_func(b'admin.pool.Add', b'dom0',
b'driver1', b'name=test-pool\nparam3=some-value\n')
self.assertEqual(mock_drivers.mock_calls, [unittest.mock.call()])