Hi,

Without this patch, restored directories get home_t SELinux context.

Part of: https://fedorahosted.org/freeipa/ticket/3833

--
Tomas Babej
Associate Software Engeneer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org


From 17d25a579434fc454f1a2be18a41b7921a53e5cc Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Wed, 30 Oct 2013 12:22:56 +0100
Subject: [PATCH] ipatests: Restore SELinux context after restoring files from
 backup

Part of: https://fedorahosted.org/freeipa/ticket/3833
---
 ipatests/test_integration/tasks.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 1bd1afa127d9ffda18a14eb70e3d9b52a504663c..84c2076626b99bcb763efc30421b994b1af0e2e3 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -118,8 +118,20 @@ def unapply_fixes(host):
 def restore_files(host):
     backupname = os.path.join(host.config.test_dir, 'file_backup')
     rmname = os.path.join(host.config.test_dir, 'file_remove')
+
+    # Restore the backed up files
     host.run_command('cp -arvf %s/* /' % ipautil.shell_quote(backupname),
                      raiseonerr=False)
+
+    # Restore context of the backed-up files
+    sed_remove_backupdir = 's/%s//g' % backupname.replace('/', '\/')
+    host.run_command("find %s | "
+                     "sed '%s' | "
+                     "sed '/^$/d' | "
+                     "xargs -d '\n' "
+                     "/sbin/restorecon -v" % (backupname, sed_remove_backupdir))
+
+    # Remove all the files that did not exist and were 'backed up'
     host.run_command(['xargs', '-d', r'\n', '-a', rmname, 'rm', '-vf'],
                      raiseonerr=False)
     host.run_command(['rm', '-rvf', backupname, rmname], raiseonerr=False)
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to