Blob Blame History Raw
From be17d3c929027a5ef9f5024aa1bb4112006bb6f6 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Mon, 6 Aug 2018 16:57:48 +0200
Subject: [PATCH] Fix ipa-restore: create /var/run/ipa files

In ipa 4.5.4, ipa-restore fails because the file /etc/tmpfiles.d/ipa.conf
is not restored => /var/run/ipa and /var/run/ipa/ccaches directories
are not created.

The fix creates these directories in ipa-restore and creates ipa.conf.
With this approach, the fix allows to restore a backup done with 4.5.4
prior to the fix.

Note: the fix is specific to ipa-4-5, in ipa-4-6 and above version the file
/etc/tmpfiles.d/ipa.conf is created at package install time and not at
ipa server install time.

Fixes: https://pagure.io/freeipa/issue/7571
Reviewed-By: Christian Heimes <cheimes@redhat.com>
---
 ipaserver/install/ipa_restore.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index a3824df230857b02b47c12645fadee1200afdf66..e069b8ba9b7a01e7602e66d4404063bbc2a1e795 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -32,6 +32,7 @@ from six.moves.configparser import SafeConfigParser
 from ipaclient.install.client import update_ipa_nssdb
 from ipalib import api, errors
 from ipalib.constants import FQDN
+from ipalib.constants import IPAAPI_USER
 from ipapython import version, ipautil
 from ipapython.ipautil import run, user_input
 from ipapython import admintool
@@ -377,6 +378,8 @@ class Restore(admintool.AdminTool):
             if restore_type == 'FULL':
                 self.remove_old_files()
                 self.cert_restore_prepare()
+                tasks.create_tmpfiles_dirs(IPAAPI_USER)
+                tasks.configure_tmpfiles()
                 self.file_restore(options.no_logs)
                 self.cert_restore()
                 if 'CA' in self.backup_services:
-- 
2.17.1