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 <pspacek@redhat.com>
This commit is contained in:
Martin Basti authored and Martin Babinsky committed 2016-07-22 16:46:55 +02:00
1 parent bc7eb99a29
commit f8bf8a6240
1 file changed
+5 -1
+5 -1
View File
@@ -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):