api/admin: report unexpected driver options in admin.pool.Add
Fixes QubesOS/qubes-issues#5895
This commit is contained in:
parent
c4739b7ed0
commit
8f1d59e9af
@ -694,8 +694,11 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
|
|||||||
self.enforce(pool_name not in self.app.pools)
|
self.enforce(pool_name not in self.app.pools)
|
||||||
|
|
||||||
driver_parameters = qubes.storage.driver_parameters(self.arg)
|
driver_parameters = qubes.storage.driver_parameters(self.arg)
|
||||||
self.enforce(
|
unexpected_parameters = [key for key in untrusted_pool_config
|
||||||
all(key in driver_parameters 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
|
pool_config = untrusted_pool_config
|
||||||
|
|
||||||
self.fire_event_for_permission(name=pool_name,
|
self.fire_event_for_permission(name=pool_name,
|
||||||
|
@ -768,7 +768,7 @@ netvm default=True type=vm \n'''
|
|||||||
|
|
||||||
add_pool_mock, self.app.add_pool = self.coroutine_mock()
|
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',
|
self.call_mgmt_func(b'admin.pool.Add', b'dom0',
|
||||||
b'driver1', b'name=test-pool\nparam3=some-value\n')
|
b'driver1', b'name=test-pool\nparam3=some-value\n')
|
||||||
self.assertEqual(mock_drivers.mock_calls, [unittest.mock.call()])
|
self.assertEqual(mock_drivers.mock_calls, [unittest.mock.call()])
|
||||||
|
Loading…
Reference in New Issue
Block a user