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