summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2015-07-15 16:20:59 +0200
committerPetr Vobornik <pvoborni@redhat.com>2015-07-17 13:46:23 +0200
commit9f701283534745bf93b41a1886183e9ef1d06566 (patch)
tree673f8b9260df49c4f3790427bff61f6a48462f87
parentf1f3ef478d8d2786269a919bb428cb2ee5372ba6 (diff)
downloadfreeipa-9f701283534745bf93b41a1886183e9ef1d06566.tar.gz
freeipa-9f701283534745bf93b41a1886183e9ef1d06566.tar.xz
freeipa-9f701283534745bf93b41a1886183e9ef1d06566.zip
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>
-rw-r--r--ipapython/sysrestore.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py
index c058ff7c0..99d78b1b4 100644
--- a/ipapython/sysrestore.py
+++ b/ipapython/sysrestore.py
@@ -186,7 +186,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))
@@ -217,7 +219,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))