Commit 2dc0acb9 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Verify configuration version number before parsing

As the attempt to convert the dict used as json representation
of the configuration into a configuration object already makes
assumptions about the internal representation, verify the version
before such an attempt. Fixes issue 783.
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarHrvoje Ribicic <>
parent 7bb22823
......@@ -62,7 +62,7 @@ _UPGRADE_CONFIG_JID = "jid-cfg-upgrade"
def _ValidateConfig(data):
"""Verifies that a configuration objects looks valid.
"""Verifies that a configuration dict looks valid.
This only verifies the version of the configuration.
......@@ -70,8 +70,9 @@ def _ValidateConfig(data):
we expect
if data.version != constants.CONFIG_VERSION:
raise errors.ConfigVersionMismatch(constants.CONFIG_VERSION, data.version)
if data['version'] != constants.CONFIG_VERSION:
raise errors.ConfigVersionMismatch(constants.CONFIG_VERSION,
class TemporaryReservationManager:
......@@ -2275,13 +2276,15 @@ class ConfigWriter(object):
raw_data = utils.ReadFile(self._cfg_file)
data = objects.ConfigData.FromDict(serializer.Load(raw_data))
data_dict = serializer.Load(raw_data)
# Make sure the configuration has the right version
data = objects.ConfigData.FromDict(data_dict)
except errors.ConfigVersionMismatch:
except Exception, err:
raise errors.ConfigurationError(err)
# Make sure the configuration has the right version
if (not hasattr(data, "cluster") or
not hasattr(data.cluster, "rsahostkeypub")):
raise errors.ConfigurationError("Incomplete configuration"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment