From 0717bc9dcaddf4f43bb9412af979b37a5a61c55b Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Tue, 20 Jan 2015 11:22:29 +0000 Subject: [PATCH] Put LDIF files to their original location in ipa-restore This prevents SELinux failures during online data restore. https://fedorahosted.org/freeipa/ticket/4822 Reviewed-By: Martin Kosek --- ipaserver/install/ipa_restore.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py index be487166d9b2319aeee5fcb54bf4779afcac5afa..562a793c2c9383d7495c84a817ac9f7a1407f9bb 100644 --- a/ipaserver/install/ipa_restore.py +++ b/ipaserver/install/ipa_restore.py @@ -504,10 +504,17 @@ class Restore(admintool.AdminTool): cn = time.strftime('import_%Y_%m_%d_%H_%M_%S') dn = DN(('cn', cn), ('cn', 'import'), ('cn', 'tasks'), ('cn', 'config')) + ldifdir = paths.SLAPD_INSTANCE_LDIF_DIR_TEMPLATE % instance ldifname = '%s-%s.ldif' % (instance, backend) + ldiffile = os.path.join(ldifdir, ldifname) srcldiffile = os.path.join(self.dir, ldifname) - ldiffile = '%s.noruv' % srcldiffile + if not os.path.exists(ldifdir): + pent = pwd.getpwnam(DS_USER) + os.mkdir(ldifdir, 0770) + os.chown(ldifdir, pent.pw_uid, pent.pw_gid) + + ipautil.backup_file(ldiffile) with open(ldiffile, 'wb') as out_file: ldif_writer = ldif.LDIFWriter(out_file) with open(srcldiffile, 'rb') as in_file: -- 2.1.0