|
|
590d18 |
From fcd40cd3f47b15dae8c2e964e890b69906045f32 Mon Sep 17 00:00:00 2001
|
|
|
590d18 |
From: David Kupka <dkupka@redhat.com>
|
|
|
590d18 |
Date: Wed, 19 Aug 2015 08:10:03 +0200
|
|
|
590d18 |
Subject: [PATCH] Backup/resore authentication control configuration
|
|
|
590d18 |
|
|
|
590d18 |
https://fedorahosted.org/freeipa/ticket/5071
|
|
|
590d18 |
|
|
|
590d18 |
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
|
|
|
590d18 |
---
|
|
|
590d18 |
ipaplatform/base/tasks.py | 15 +++++++++++++++
|
|
|
590d18 |
ipaplatform/redhat/authconfig.py | 6 ++++++
|
|
|
590d18 |
ipaplatform/redhat/tasks.py | 8 ++++++++
|
|
|
590d18 |
ipaserver/install/ipa_backup.py | 4 ++++
|
|
|
590d18 |
ipaserver/install/ipa_restore.py | 4 ++++
|
|
|
590d18 |
5 files changed, 37 insertions(+)
|
|
|
590d18 |
|
|
|
590d18 |
diff --git a/ipaplatform/base/tasks.py b/ipaplatform/base/tasks.py
|
|
|
590d18 |
index 08fdb494a3bfc6c59bebf4af2f72f54a26724700..65715145af533c90038b3e8667da07fd28b7ec56 100644
|
|
|
590d18 |
--- a/ipaplatform/base/tasks.py
|
|
|
590d18 |
+++ b/ipaplatform/base/tasks.py
|
|
|
590d18 |
@@ -150,6 +150,21 @@ class BaseTaskNamespace(object):
|
|
|
590d18 |
|
|
|
590d18 |
return
|
|
|
590d18 |
|
|
|
590d18 |
+ def backup_auth_configuration(self, path):
|
|
|
590d18 |
+ """
|
|
|
590d18 |
+ Create backup of access control configuration.
|
|
|
590d18 |
+ :param path: store the backup here. This will be passed to
|
|
|
590d18 |
+ restore_auth_configuration as well.
|
|
|
590d18 |
+ """
|
|
|
590d18 |
+ return
|
|
|
590d18 |
+
|
|
|
590d18 |
+ def restore_auth_configuration(self, path):
|
|
|
590d18 |
+ """
|
|
|
590d18 |
+ Restore backup of access control configuration.
|
|
|
590d18 |
+ :param path: restore the backup from here.
|
|
|
590d18 |
+ """
|
|
|
590d18 |
+ return
|
|
|
590d18 |
+
|
|
|
590d18 |
def set_selinux_booleans(self, required_settings, backup_func=None):
|
|
|
590d18 |
"""Set the specified SELinux booleans
|
|
|
590d18 |
|
|
|
590d18 |
diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py
|
|
|
590d18 |
index 901eb51637d193d80bc3927929d7d436065ec262..edefee8b2b4922ad67cdbac158615ef32c776bb4 100644
|
|
|
590d18 |
--- a/ipaplatform/redhat/authconfig.py
|
|
|
590d18 |
+++ b/ipaplatform/redhat/authconfig.py
|
|
|
590d18 |
@@ -84,3 +84,9 @@ class RedHatAuthConfig(object):
|
|
|
590d18 |
|
|
|
590d18 |
args = self.build_args()
|
|
|
590d18 |
ipautil.run(["/usr/sbin/authconfig"] + args)
|
|
|
590d18 |
+
|
|
|
590d18 |
+ def backup(self, path):
|
|
|
590d18 |
+ ipautil.run(["/usr/sbin/authconfig", "--savebackup", path])
|
|
|
590d18 |
+
|
|
|
590d18 |
+ def restore(self, path):
|
|
|
590d18 |
+ ipautil.run(["/usr/sbin/authconfig", "--restorebackup", path])
|
|
|
590d18 |
diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py
|
|
|
590d18 |
index b26604aa736eb472c88bc0dcbc3a4b515712ce9d..1af99d318c6745b1e5285c7829c2b292f86c8390 100644
|
|
|
590d18 |
--- a/ipaplatform/redhat/tasks.py
|
|
|
590d18 |
+++ b/ipaplatform/redhat/tasks.py
|
|
|
590d18 |
@@ -161,6 +161,14 @@ class RedHatTaskNamespace(BaseTaskNamespace):
|
|
|
590d18 |
auth_config.add_option("nostart")
|
|
|
590d18 |
auth_config.execute()
|
|
|
590d18 |
|
|
|
590d18 |
+ def backup_auth_configuration(self, path):
|
|
|
590d18 |
+ auth_config = RedHatAuthConfig()
|
|
|
590d18 |
+ auth_config.backup(path)
|
|
|
590d18 |
+
|
|
|
590d18 |
+ def restore_auth_configuration(self, path):
|
|
|
590d18 |
+ auth_config = RedHatAuthConfig()
|
|
|
590d18 |
+ auth_config.restore(path)
|
|
|
590d18 |
+
|
|
|
590d18 |
def reload_systemwide_ca_store(self):
|
|
|
590d18 |
try:
|
|
|
590d18 |
ipautil.run([paths.UPDATE_CA_TRUST])
|
|
|
590d18 |
diff --git a/ipaserver/install/ipa_backup.py b/ipaserver/install/ipa_backup.py
|
|
|
590d18 |
index d7afb3654b09e88321f1ce9f279749b19c2f6414..0ba44b280dfb7c9d9cbbe2470392c3c98ef35bcc 100644
|
|
|
590d18 |
--- a/ipaserver/install/ipa_backup.py
|
|
|
590d18 |
+++ b/ipaserver/install/ipa_backup.py
|
|
|
590d18 |
@@ -41,6 +41,7 @@ from ipapython import ipaldap
|
|
|
590d18 |
from ipalib.session import ISO8601_DATETIME_FMT
|
|
|
590d18 |
from ipalib.constants import CACERT
|
|
|
590d18 |
from ConfigParser import SafeConfigParser
|
|
|
590d18 |
+from ipaplatform.tasks import tasks
|
|
|
590d18 |
|
|
|
590d18 |
"""
|
|
|
590d18 |
A test gpg can be generated like this:
|
|
|
590d18 |
@@ -302,6 +303,9 @@ class Backup(admintool.AdminTool):
|
|
|
590d18 |
self.db2ldif(instance, 'userRoot', online=options.online)
|
|
|
590d18 |
self.db2bak(instance, online=options.online)
|
|
|
590d18 |
if not options.data_only:
|
|
|
590d18 |
+ # create backup of auth configuration
|
|
|
590d18 |
+ auth_backup_path = os.path.join(paths.VAR_LIB_IPA, 'auth_backup')
|
|
|
590d18 |
+ tasks.backup_auth_configuration(auth_backup_path)
|
|
|
590d18 |
self.file_backup(options)
|
|
|
590d18 |
self.finalize_backup(options.data_only, options.gpg, options.gpg_keyring)
|
|
|
590d18 |
|
|
|
590d18 |
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
|
|
|
590d18 |
index 528a6daf0d4b6d3dfc69b6bbf8e8b05ad91ce02d..8960626d0f0e438ef198e2d92803983e520051a8 100644
|
|
|
590d18 |
--- a/ipaserver/install/ipa_restore.py
|
|
|
590d18 |
+++ b/ipaserver/install/ipa_restore.py
|
|
|
590d18 |
@@ -386,6 +386,10 @@ class Restore(admintool.AdminTool):
|
|
|
590d18 |
self.log.info('Starting Directory Server')
|
|
|
590d18 |
dirsrv.start(capture_output=False)
|
|
|
590d18 |
else:
|
|
|
590d18 |
+ # restore access controll configuration
|
|
|
590d18 |
+ auth_backup_path = os.path.join(paths.VAR_LIB_IPA, 'auth_backup')
|
|
|
590d18 |
+ if os.path.exists(auth_backup_path):
|
|
|
590d18 |
+ tasks.restore_auth_configuration(auth_backup_path)
|
|
|
590d18 |
# explicitly enable then disable the pki tomcatd service to
|
|
|
590d18 |
# re-register its instance. FIXME, this is really wierd.
|
|
|
590d18 |
services.knownservices.pki_tomcatd.enable()
|
|
|
590d18 |
--
|
|
|
590d18 |
2.4.3
|
|
|
590d18 |
|