URL: https://github.com/freeipa/freeipa/pull/1693
Author: tiran
 Title: #1693: Keep owner when backing up CA.cfg
Action: opened

PR body:
"""
Closes: https://pagure.io/freeipa/issue/7426
Signed-off-by: Christian Heimes <chei...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1693/head:pr1693
git checkout pr1693
From 76662c77ed42bf2821ddfa108adeddd5b16a5e61 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Thu, 15 Mar 2018 13:09:48 +0100
Subject: [PATCH] Keep owner when backing up CA.cfg

Closes: https://pagure.io/freeipa/issue/7426
Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 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 d107191049..e847b18536 100644
--- a/ipaserver/install/dogtaginstance.py
+++ b/ipaserver/install/dogtaginstance.py
@@ -469,8 +469,12 @@ def backup_config(self):
         """
         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)
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to