diff options
author | Jan Zeleny <jzeleny@redhat.com> | 2011-03-30 08:38:41 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-04-25 08:06:34 -0400 |
commit | 0e5879c0e3f83b0bbaff79d9c97f672055b61c4f (patch) | |
tree | 091171a2ae53082ef12e292a8d355ba32659fbd5 /src/config/SSSDConfig.py | |
parent | 7a0e6e2b9fc2fffc10f33e90926bb7edb5198dde (diff) | |
download | sssd-0e5879c0e3f83b0bbaff79d9c97f672055b61c4f.tar.gz sssd-0e5879c0e3f83b0bbaff79d9c97f672055b61c4f.tar.bz2 sssd-0e5879c0e3f83b0bbaff79d9c97f672055b61c4f.zip |
Configuration parsing updates
These changes are all related to following ticket:
https://fedorahosted.org/sssd/ticket/763
Changes in SSSDConfig.py merge old and new domain record instead of just
deleting the old and inserting the new one. The old approach let to loss
of some information like comments and blank lines in the config file.
Changes in API config were performed so our Python scripts (like
sss_obfuscate) don't add extra config options to the config file.
Diffstat (limited to 'src/config/SSSDConfig.py')
-rw-r--r-- | src/config/SSSDConfig.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/config/SSSDConfig.py b/src/config/SSSDConfig.py index 5135174a..c3d9ed40 100644 --- a/src/config/SSSDConfig.py +++ b/src/config/SSSDConfig.py @@ -1739,23 +1739,20 @@ class SSSDConfig(SSSDChangeConf): domain.oldname = None; sectionname = 'domain/%s' % name - # Ensure that the existing section is removed - # This way we ensure that we are getting a - # complete copy of the service. - # delete_option() is a noop if the section - # does not exist. - index = self.delete_option('section', sectionname) - addkw = [] + section_subtree = self.findOpts(self.opts, 'section', sectionname) + + if name not in self.list_domains(): + self.add_section(sectionname, []); + + for option in self.options(sectionname): + if option['type'] == 'option': + if option['name'] not in domain.get_all_options(): + self.delete_option_subtree(section_subtree, 'option', option['name'], True) + for option,value in domain.get_all_options().items(): if (type(value) == list): value = ', '.join(value) - addkw.append( { 'type' : 'option', - 'name' : option, - 'value' : str(value) } ) - if oldindex: - self.add_section(sectionname, addkw, oldindex) - else: - self.add_section(sectionname, addkw, index) + self.set(sectionname, option, str(value)) if domain.active: self.activate_domain(name) |