diff options
author | Tomas Babej <tbabej@redhat.com> | 2013-10-30 12:22:56 +0100 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-10-31 13:18:00 +0100 |
commit | 4fd88140b181b5f69c9312070840a4020593eb90 (patch) | |
tree | 220d7acd67ae9b526af5a8ce8fef33189deab09b | |
parent | 775f2de4ecc047428034ed68dbbae934fa38de8a (diff) | |
download | freeipa-4fd88140b181b5f69c9312070840a4020593eb90.tar.gz freeipa-4fd88140b181b5f69c9312070840a4020593eb90.tar.xz freeipa-4fd88140b181b5f69c9312070840a4020593eb90.zip |
ipatests: Restore SELinux context after restoring files from backup
Part of: https://fedorahosted.org/freeipa/ticket/3833
-rw-r--r-- | ipatests/test_integration/tasks.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py index bb7688bc3..3fa328799 100644 --- a/ipatests/test_integration/tasks.py +++ b/ipatests/test_integration/tasks.py @@ -116,8 +116,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) |