From d693ffd819a2016c6cc871107d5f66353c999888 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pviktori@redhat.com>
Date: Mon, 10 Nov 2014 13:29:58 +0100
Subject: [PATCH] ipa-restore: Don't crash if AD trust is not installed
https://fedorahosted.org/freeipa/ticket/4668
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
---
ipaserver/install/ipa_restore.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index 239de99c462639854e8e25c6b9278cb94b6fc6b8..352a1ca2bf283c0beb8c95925c6eb9c9984b3338 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -37,7 +37,6 @@ from ipaserver.install.replication import (wait_for_task, ReplicationManager,
get_cs_replication_manager)
from ipaserver.install import installutils
from ipaserver.install import httpinstance
-from ipaserver.install import adtrustinstance
from ipapython import ipaldap
import ipapython.errors
from ipaplatform.tasks import tasks
@@ -45,6 +44,11 @@ from ipaserver.install.ipa_backup import BACKUP_DIR
from ipaplatform import services
from ipaplatform.paths import paths
+try:
+ from ipaserver.install import adtrustinstance
+except ImportError:
+ adtrustinstance = None
+
def recursive_chown(path, uid, gid):
'''
@@ -646,7 +650,12 @@ class Restore(admintool.AdminTool):
def restore_selinux_booleans(self):
bools = dict(httpinstance.SELINUX_BOOLEAN_SETTINGS)
if 'ADTRUST' in self.backup_services:
- bools.update(adtrustinstance.SELINUX_BOOLEAN_SETTINGS)
+ if adtrustinstance:
+ bools.update(adtrustinstance.SELINUX_BOOLEAN_SETTINGS)
+ else:
+ self.log.error(
+ 'The AD trust package was not found, '
+ 'not setting SELinux booleans.')
try:
tasks.set_selinux_booleans(bools)
except ipapython.errors.SetseboolError as e:
--
2.1.0