diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-10-29 14:17:22 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-11-03 10:16:14 -0500 |
commit | c4644ab0dc97ed47fcb72e56a41b4524544582e9 (patch) | |
tree | 17c27b2300b3b389d08491a4ca26a467ffa32944 /server/config/SSSDConfig.py | |
parent | c2a29bea5248554a9112d051a7b5be492aa729b6 (diff) | |
download | sssd-c4644ab0dc97ed47fcb72e56a41b4524544582e9.tar.gz sssd-c4644ab0dc97ed47fcb72e56a41b4524544582e9.tar.xz sssd-c4644ab0dc97ed47fcb72e56a41b4524544582e9.zip |
Make config_file_version a hidden setting in SSSDConfig API
The config_file_version should never be changed by the API, so we
will hide the option inside the SSSDConfig API and remove it from
the schema.
Guarantee that the config file is of the correct version
Diffstat (limited to 'server/config/SSSDConfig.py')
-rw-r--r-- | server/config/SSSDConfig.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/server/config/SSSDConfig.py b/server/config/SSSDConfig.py index 07e967bac..6d3a8c6b7 100644 --- a/server/config/SSSDConfig.py +++ b/server/config/SSSDConfig.py @@ -199,12 +199,20 @@ class SSSDService: # Set up the service object with any known defaults self.options = {} + # Include a list of hidden options + self.hidden_options = [] + # Set up default options for all services self.options.update(self.schema.get_defaults('service')) # Set up default options for this service self.options.update(self.schema.get_defaults(self.name)) + # For the [sssd] service, force the config file version + if servicename == 'sssd': + self.options['config_file_version'] = 2 + self.hidden_options.append('config_file_version') + def get_name(self): return self.name @@ -228,6 +236,10 @@ class SSSDService: option_schema = self.schema.get_option(self.name, optionname) elif self.schema.has_option('service', optionname): option_schema = self.schema.get_option('service', optionname) + elif optionname in self.hidden_options: + # Set this option and do not add it to the list of changeable values + self.options[optionname] = value + return else: raise NoOptionError('Section [%s] has no option [%s]' % (self.name, optionname)) @@ -442,6 +454,7 @@ class SSSDConfig(RawConfigParser): self.schema = SSSDConfigSchema(schemafile, schemaplugindir) self.configfile = None self.initialized = False + self.API_VERSION = 2 def import_config(self,configfile=None): if self.initialized: @@ -462,6 +475,14 @@ class SSSDConfig(RawConfigParser): self.configfile = configfile self.initialized = True + try: + if int(self.get('sssd', 'config_file_version')) != self.API_VERSION: + raise ParsingError("Wrong config_file_version") + except: + # Either the 'sssd' section or the 'config_file_version' was not + # present in the config file + raise ParsingError("File contains no config_file_version") + def new_config(self): if self.initialized: raise AlreadyInitializedError |