From 3871fe6de563f0f1ba030174b59cda0a7d8a7456 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 15 Mar 2018 13:09:48 +0100 Subject: [PATCH] Keep owner when backing up CA.cfg DogtagInstance.backup_config uses shutil.copy to create a backup of the config file. The function does not retain owner and group, so it creates a backup as user and group root:root. Closes: https://pagure.io/freeipa/issue/7426 Signed-off-by: Christian Heimes Reviewed-By: Alexey Slaykovsky --- ipaserver/install/dogtaginstance.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py index d10719104..e847b1853 100644 --- a/ipaserver/install/dogtaginstance.py +++ b/ipaserver/install/dogtaginstance.py @@ -469,8 +469,12 @@ class DogtagInstance(service.Service): """ Create a backup copy of CS.cfg """ - path = self.config + config = self.config + bak = config + '.ipabkp' if services.knownservices['pki_tomcatd'].is_running('pki-tomcat'): raise RuntimeError( - "Dogtag must be stopped when creating backup of %s" % path) - shutil.copy(path, path + '.ipabkp') + "Dogtag must be stopped when creating backup of %s" % config) + shutil.copy(config, bak) + # shutil.copy() doesn't copy owner + s = os.stat(config) + os.chown(bak, s.st_uid, s.st_gid)