Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1162162

Summary: ipa_restore.py with "--data --online" fails to restore the LDAP data
Product: Red Hat Enterprise Linux 7 Reporter: Markus Opolka <markus>
Component: ipaAssignee: IPA Maintainers <ipa-maint>
Status: CLOSED DUPLICATE QA Contact: Namita Soman <nsoman>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.0CC: mkosek, rcritten
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-20 11:04:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Markus Opolka 2014-11-10 12:10:38 UTC
Description of problem:

ipa_restore.py with "--data --online" fails to restore the LDAP data without message - and all LDAP data is lost. /var/log/dirsrv/slapd-REALM/errors shows: 

[07/Nov/2014:10:56:58 +0100] - import userRoot: Could not open LDIF file "/tmp/tmpop8uB4ipa/ipa/SCHAEFFLER-COM-userRoot.ldif", errno 13 (Permission denied)
[07/Nov/2014:10:57:07 +0100] - import ipaca: Could not open LDIF file "/tmp/tmpop8uB4ipa/ipa/SCHAEFFLER-COM-ipaca.ldif", errno 13 (Permission denied)

The files below /tmp/tmp*ipa are correctly set to uid=dirsrv group=dirsrv and have read permissions, however "--online" directs the dirsrv to load the files (via LDAP task object cn=import,cn=tasks,cn=config), and the running dirsrv is prohibited by selinux to access the files.

"setenforce 0" shows success.

Possible fix: add "chcon" on files after extracting the TAR ball in /usr/lib/python2.7/site-packages/ipaserver/install/ipa_restore.py in extract_backup():

--- /usr/lib/python2.7/site-packages/ipaserver/install/ipa_restore.py.bak       2013-11-01 16:34:30.000000000 +0100
+++ /usr/lib/python2.7/site-packages/ipaserver/install/ipa_restore.py   2014-11-07 13:41:19.567269126 +0100
@@ -576,6 +576,7 @@
         pent = pwd.getpwnam(DS_USER)
         os.chown(self.top_dir, pent.pw_uid, pent.pw_gid)
         recursive_chown(self.dir, pent.pw_uid, pent.pw_gid)
+        run(['chcon', '-t', 'dirsrv_var_lib_t', '-R', self.top_dir])

         if encrypt:
             # We can remove the decoded tarball

Version-Release number of selected component (if applicable):

RHEL 7.0 
ipa-admintools-3.3.3-28.el7_0.1.x86_64
ipa-server-3.3.3-28.el7_0.1.x86_64
sssd-ipa-1.11.2-68.el7_0.6.x86_64
ipa-client-3.3.3-28.el7_0.1.x86_64
ipa-python-3.3.3-28.el7_0.1.x86_64

How reproducible:

Backup and restore data on an IPA Master Server installation with data records.

Steps to Reproduce:
1. Create full backup with ipa-backup.py
2. Restore data with ipa_restore.py "--data --online"

Actual results:

The "online" restore fails to open the LDIF file and thus fails to import the data.

Expected results:

Data should be restored without stopping the directory services.

Additional info:

"setenforce 0" shows success. So it seems to be a problem with SELinux attributes on the LDIF file.

Comment 2 Markus Opolka 2014-11-13 08:36:44 UTC
Could be already reported with 951581, but I don't have the permissions to check. Just to let you know. 

Cheers

Comment 3 Martin Kosek 2014-11-20 11:04:53 UTC
Hello Markus, thanks for reporting it.

Upstream FreeIPA project is tracking it in

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

which was already linked to Bug 951581 and being fixed there, as you correctly proposed. So I am closing this one as duplicate to Bug 951581 which I BTW made public so that you can track it.

*** This bug has been marked as a duplicate of bug 951581 ***