From fd54380d684494e13d8e797b17412a6713937b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Dudl=C3=A1k?= Date: Thu, 2 Aug 2018 18:05:51 +0200 Subject: [PATCH] Re-open the ldif file to prevent error message There was an issue with ipa-server-upgrade and it was showing an error while upgrading: DN... does not exists or haven't been updated, caused by not moving pointer to file begining when re-reading. Resolves: https://pagure.io/freeipa/issue/7644 Reviewed-By: Florence Blanc-Renaud Reviewed-By: Christian Heimes Reviewed-By: Rob Crittenden --- ipaserver/install/upgradeinstance.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ipaserver/install/upgradeinstance.py b/ipaserver/install/upgradeinstance.py index 19a06a0a84536cb548822e47038142e97d8bee39..cb83d7bb1817d1fd9a36f2e97a5cc80bf806cabd 100644 --- a/ipaserver/install/upgradeinstance.py +++ b/ipaserver/install/upgradeinstance.py @@ -237,17 +237,22 @@ class IPAUpgrade(service.Service): def __disable_schema_compat(self): ldif_outfile = "%s.modified.out" % self.filename + + with open(self.filename, "r") as in_file: + parser = GetEntryFromLDIF(in_file, entries_dn=[COMPAT_DN]) + parser.parse() + + try: + compat_entry = parser.get_results()[COMPAT_DN] + except KeyError: + return + + if not compat_entry.get('nsslapd-pluginEnabled'): + return + with open(ldif_outfile, "w") as out_file: with open(self.filename, "r") as in_file: - parser = GetEntryFromLDIF(in_file, entries_dn=[COMPAT_DN]) - parser.parse() - try: - compat_entry = parser.get_results()[COMPAT_DN] - except KeyError: - return parser = installutils.ModifyLDIF(in_file, out_file) - if not compat_entry.get('nsslapd-pluginEnabled'): - return parser.remove_value(COMPAT_DN, "nsslapd-pluginEnabled") parser.remove_value(COMPAT_DN, "nsslapd-pluginenabled") parser.add_value(COMPAT_DN, "nsslapd-pluginEnabled", -- 2.17.1