590d18
From 630a9b60995e2d6eb02281a3dd176f0252f632db Mon Sep 17 00:00:00 2001
590d18
From: Martin Basti <mbasti@redhat.com>
590d18
Date: Wed, 15 Jul 2015 16:20:59 +0200
590d18
Subject: [PATCH] sysrestore: copy files instead of moving them to avoind
590d18
 SELinux issues
590d18
590d18
Copying files restores SELinux context.
590d18
590d18
https://fedorahosted.org/freeipa/ticket/4923
590d18
590d18
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
590d18
---
590d18
 ipapython/sysrestore.py | 8 ++++++--
590d18
 1 file changed, 6 insertions(+), 2 deletions(-)
590d18
590d18
diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py
590d18
index 580df9a4fd6d0fae35602dad1f81d498fa8f0173..1a111258bc0f6dd503673028d3a990821f077fef 100644
590d18
--- a/ipapython/sysrestore.py
590d18
+++ b/ipapython/sysrestore.py
590d18
@@ -187,7 +187,9 @@ class FileStore:
590d18
         if new_path is not None:
590d18
             path = new_path
590d18
 
590d18
-        shutil.move(backup_path, path)
590d18
+        shutil.copy(backup_path, path)  # SELinux needs copy
590d18
+        os.remove(backup_path)
590d18
+
590d18
         os.chown(path, int(uid), int(gid))
590d18
         os.chmod(path, int(mode))
590d18
 
590d18
@@ -218,7 +220,9 @@ class FileStore:
590d18
                 root_logger.debug("  -> Not restoring - '%s' doesn't exist", backup_path)
590d18
                 continue
590d18
 
590d18
-            shutil.move(backup_path, path)
590d18
+            shutil.copy(backup_path, path)  # SELinux needs copy
590d18
+            os.remove(backup_path)
590d18
+
590d18
             os.chown(path, int(uid), int(gid))
590d18
             os.chmod(path, int(mode))
590d18
 
590d18
-- 
590d18
2.4.3
590d18