https://fedorahosted.org/freeipa/ticket/4896
--
David Kupka
From c295d33db32152118013d4e85493b012dd687347 Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Wed, 4 Mar 2015 06:49:54 -0500
Subject: [PATCH] Add realm name to backup header file.

When ipa server is restored after uninstalation there is no way to tell
what Kerberos realm should be used.

https://fedorahosted.org/freeipa/ticket/4896
---
 ipaserver/install/ipa_backup.py  |  1 +
 ipaserver/install/ipa_restore.py | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/ipaserver/install/ipa_backup.py b/ipaserver/install/ipa_backup.py
index 72d1475d6db92b6b9e715afdae85d169a036c085..a0b6196b0d5cbc631c2665fd84ada101791b7254 100644
--- a/ipaserver/install/ipa_backup.py
+++ b/ipaserver/install/ipa_backup.py
@@ -507,6 +507,7 @@ class Backup(admintool.AdminTool):
         config.set('ipa', 'host', api.env.host)
         config.set('ipa', 'ipa_version', str(version.VERSION))
         config.set('ipa', 'version', '1')
+        config.set('ipa', 'realm', api.env.realm)
 
         dn = DN(('cn', api.env.host), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
         services_cns = []
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index efe3b9b1c0c10775b3a72b9d843924263526209a..ee7c285c20c2cad632df858541b274fba4b1a84e 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -203,16 +203,10 @@ class Restore(admintool.AdminTool):
         options = self.options
         super(Restore, self).run()
 
-        api.bootstrap(in_server=False, context='restore')
-        api.finalize()
-
         self.backup_dir = self.args[0]
         if not os.path.isabs(self.backup_dir):
             self.backup_dir = os.path.join(BACKUP_DIR, self.backup_dir)
 
-        self.log.info("Preparing restore from %s on %s",
-                      self.backup_dir, api.env.host)
-
         self.header = os.path.join(self.backup_dir, 'header')
 
         try:
@@ -225,6 +219,14 @@ class Restore(admintool.AdminTool):
         else:
             restore_type = self.backup_type
 
+        if restore_type == 'FULL' and self.backup_realm:
+            api.env.realm = self.backup_realm
+        api.bootstrap(in_server=False, context='restore')
+        api.finalize()
+
+        self.log.info("Preparing restore from %s on %s",
+                      self.backup_dir, api.env.host)
+
         instances = [realm_to_serverid(api.env.realm), 'PKI-IPA']
         backends = ['userRoot', 'ipaca']
 
@@ -649,6 +651,7 @@ class Restore(admintool.AdminTool):
         self.backup_ipa_version = config.get('ipa', 'ipa_version')
         self.backup_version = config.get('ipa', 'version')
         self.backup_services = config.get('ipa', 'services').split(',')
+        self.backup_realm = config.get('ipa', 'realm')
 
 
     def extract_backup(self, keyring=None):
-- 
2.1.0

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

Reply via email to