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
This commit is contained in:
Martin Kosek 2011-03-01 14:17:03 +01:00 committed by Rob Crittenden
parent 620903ff27
commit f785af4efe
3 changed files with 8 additions and 4 deletions

View File

@ -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)
@ -779,7 +779,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()

View File

@ -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))

View File

@ -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,6 +189,9 @@ class DsInstance(service.Service):
else:
self.suffix = None
if fstore:
self.fstore = fstore
else:
self.fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')