IPA server/replica uninstallation may fail when it tries to restore
a Directory server configuration file in sysrestore directory, which
was already restored before.

The problem is in Directory Server uninstaller which uses and modifies
its own image of sysrestore directory state instead of using the
common uninstaller image.

https://fedorahosted.org/freeipa/ticket/1026

>From 1f03614a9bf3adfd54d5d6265d1310abbf291108 Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Tue, 1 Mar 2011 14:17:03 +0100
Subject: [PATCH] Inconsistent sysrestore file handling by IPA server installer

IPA server/replica uninstallation may fail when it tries to restore
a Directory server configuration file in sysrestore directory, which
was already restored before.

The problem is in Directory Server uninstaller which uses and modifies
its own image of sysrestore directory state instead of using the
common uninstaller image.

https://fedorahosted.org/freeipa/ticket/1026
---
 install/tools/ipa-server-install |    4 ++--
 ipapython/sysrestore.py          |    1 +
 ipaserver/install/dsinstance.py  |    7 +++++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 6ae02d89398baf7795a55424474407b08b128a1d..e3d2563affdd48e0b8c1ca47fee7c98cdde2b9a6 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -416,7 +416,7 @@ def uninstall():
     bindinstance.BindInstance(fstore).uninstall()
     httpinstance.HTTPInstance(fstore).uninstall()
     krbinstance.KrbInstance(fstore).uninstall()
-    dsinstance.DsInstance().uninstall()
+    dsinstance.DsInstance(fstore=fstore).uninstall()
     fstore.restore_all_files()
     try:
         os.remove(ANSWER_CACHE)
@@ -774,7 +774,7 @@ def main():
     service.start('messagebus')
 
     # Create a directory server instance
-    ds = dsinstance.DsInstance()
+    ds = dsinstance.DsInstance(fstore=fstore)
 
     if options.dirsrv_pin:
         [pw_fd, pw_name] = tempfile.mkstemp()
diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py
index 77495b2000f57392c3c65aa2a7e96ae1ddad022f..1025449c229f8d164cb78d44a580483192d2029b 100644
--- a/ipapython/sysrestore.py
+++ b/ipapython/sysrestore.py
@@ -190,6 +190,7 @@ class FileStore:
             backup_path = os.path.join(self._path, filename)
             if not os.path.exists(backup_path):
                 logging.debug("  -> Not restoring - '%s' doesn't exist", backup_path)
+                continue
 
             shutil.move(backup_path, path)
             os.chown(path, int(uid), int(gid))
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 2bb083fb95dd090214103a2702de776939fcf1df..2e271e61e81bc7f1c18a77d1ea14d757fa6143e6 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -171,7 +171,7 @@ info: IPA V2.0
 """
 
 class DsInstance(service.Service):
-    def __init__(self, realm_name=None, domain_name=None, dm_password=None):
+    def __init__(self, realm_name=None, domain_name=None, dm_password=None, fstore=None):
         service.Service.__init__(self, "dirsrv", dm_password=dm_password)
         self.realm_name = realm_name
         self.sub_dict = None
@@ -189,7 +189,10 @@ class DsInstance(service.Service):
         else:
             self.suffix = None
 
-        self.fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
+        if fstore:
+            self.fstore = fstore
+        else:
+            self.fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
 
 
     def __common_setup(self):
-- 
1.7.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to