From f8bf8a62402a4385a7cc2f73b37b654b47713d60 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Thu, 21 Jul 2016 18:49:57 +0200 Subject: Use copy when replacing files to keep SELinux context When installer replaces any file with newer, it must use 'copy' instead of 'mv' to keep SELinux context valid. https://fedorahosted.org/freeipa/ticket/6111 Reviewed-By: Petr Spacek --- ipapython/ipautil.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 763a99c11..9964fba4f 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -528,10 +528,14 @@ def dir_exists(filename): except Exception: return False + def install_file(fname, dest): + # SELinux: use copy to keep the right context if file_exists(dest): os.rename(dest, dest + ".orig") - shutil.move(fname, dest) + shutil.copy(fname, dest) + os.remove(fname) + def backup_file(fname): if file_exists(fname): -- cgit