From 23d5c05232bcedda31ed520a487db0f6317ed92e Mon Sep 17 00:00:00 2001 From: Oleg Kozlov Date: Wed, 24 Apr 2019 13:56:24 +0200 Subject: [PATCH] Check have packages for extra features been installed before restoring backup `iparestore --full` should check that packages for extra features such as dns and adtrust are installed in the system before restoring a backup in case the backup includes content for these features. If the packages are not installed full backup should be refused and an error message with suggestions should be showed. If corresponding packages for these features are not installed before the backup restoring, it may cause a situation when the packages are going to be installed after the restoring. In that case configuration files restored by `ipa-restore` will be replaced by default configuration files if the files are tracked by `rpm`. E.g. if `freeipa-server-trust-ad` is not installed before `ipa-restore --full` running, when the package will be installed it also will bring `samba` package according to the dependencies. At `samba` installation step exist correct `/etc/samba/smb.conf` is going to be replaced by the default one from the `samba` package. Fixes: https://pagure.io/freeipa/issue/7630 Reviewed-By: Christian Heimes --- ipaserver/install/ipa_restore.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py index 5685c66c7..5607ef354 100644 --- a/ipaserver/install/ipa_restore.py +++ b/ipaserver/install/ipa_restore.py @@ -324,6 +324,28 @@ class Restore(admintool.AdminTool): not user_input("Continue to restore?", False)): raise admintool.ScriptError("Aborted") + # Check have optional dependencies been installed for extra + # features from backup + if restore_type == 'FULL': + if 'ADTRUST' in self.backup_services: + if not adtrustinstance or not adtrustinstance.check_inst(): + raise admintool.ScriptError( + "Backup includes AD trust feature, it requires '{}' " + "package. Please install the package and " + "run ipa-restore again.".format( + constants.IPA_ADTRUST_PACKAGE_NAME + ) + ) + if 'DNS' in self.backup_services: + if not os.path.isfile(paths.IPA_DNS_INSTALL): + raise admintool.ScriptError( + "Backup includes Integrated DNS feature, it requires " + "'{}' package. Please install the package and " + "run ipa-restore again.".format( + constants.IPA_DNS_PACKAGE_NAME + ) + ) + pent = pwd.getpwnam(constants.DS_USER) # Temporary directory for decrypting files before restoring