From 5d6a9d3befb5434dd7b2d1bbafd76050f22743a2 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Mon, 22 Apr 2013 12:55:38 +0200 Subject: Preserve already configured options in openldap conf We should respect already configured options present in /etc/openldap/ldap.conf when generating our own configuration. With this patch, we only rewrite URI, BASE and TLS_CACERT options only if they are not configured. In the case they are, our suggested configuration is inserted as a comment. Also adds tab as a delimeter character in /etc/openldap/ldap.conf https://fedorahosted.org/freeipa/ticket/3582 --- ipa-client/ipaclient/ipachangeconf.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ipa-client/ipaclient/ipachangeconf.py') diff --git a/ipa-client/ipaclient/ipachangeconf.py b/ipa-client/ipaclient/ipachangeconf.py index bdc5579fc..e802e177e 100644 --- a/ipa-client/ipaclient/ipachangeconf.py +++ b/ipa-client/ipaclient/ipachangeconf.py @@ -338,7 +338,16 @@ class IPAChangeConf: if no['action'] == 'set': opts.append(no) continue - raise SyntaxError('Unknown action: [%s]' % o['action']) + if no['action'] == 'addifnotset': + opts.append({'name': 'comment', 'type': 'comment', + 'value': self._dump_line(no['name'], + self.dassign, + no['value'], + u' # modified by IPA' + )}) + opts.append(o) + continue + raise SyntaxError('Unknown action: [%s]' % no['action']) raise SyntaxError('Unknown type: [%s]' % o['type']) @@ -365,7 +374,7 @@ class IPAChangeConf: if no['type'] == "option": (num, o) = self.findOpts(opts, no['type'], no['name'], True) if not o: - if no['action'] == 'set': + if no['action'] == 'set' or no['action'] == 'addifnotset': opts.append(no) continue cline = num + 1 @@ -385,6 +394,7 @@ class IPAChangeConf: # the options as indicated by the contents of newopts #Second we fill in the new opts tree with options as indicated # in the newopts tree (this is becaus eentire (sub)sections may + # in the newopts tree (this is becaus entire (sub)sections may # exist in the newopts that do not exist in oldopts) opts = self.mergeOld(oldopts, newopts) -- cgit