summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2014-01-22 15:11:04 +0100
committerPetr Viktorin <pviktori@redhat.com>2014-02-05 15:38:53 +0100
commit1601860023193ec295458a71f1f097edbb57d787 (patch)
treed184a3c16403f47cd5d90d4aa3b06c34b3522d76
parentbaf9b4c02a668b8ccd624706e923bbf5fb85172f (diff)
downloadfreeipa-1601860023193ec295458a71f1f097edbb57d787.tar.gz
freeipa-1601860023193ec295458a71f1f097edbb57d787.tar.xz
freeipa-1601860023193ec295458a71f1f097edbb57d787.zip
ipatests: Run restoring backup files and restoring their context in one session
Restoring backup files and restoring their context were two separate commands, what means that in case we use SSHTrasport, which creates a separate SSH session for each command, we try to restore the SELinux context of the changed files in a new session. This causes problems, if the access to files themselves are necessary for the creation of the new SSH session. https://fedorahosted.org/freeipa/ticket/4133 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
-rw-r--r--ipatests/test_integration/tasks.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index ab027e028..e13070a06 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -119,17 +119,21 @@ 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
+ # Prepare command for restoring 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))
+ restorecon_command = (
+ "find %s | "
+ "sed '%s' | "
+ "sed '/^$/d' | "
+ "xargs -d '\n' "
+ "/sbin/restorecon -v" % (backupname, sed_remove_backupdir))
+
+ # Prepare command for actual restoring of the backed up files
+ copyfiles_command = 'cp -arvf %s/* /' % ipautil.shell_quote(backupname)
+
+ # Run both commands in one session. For more information, see:
+ # https://fedorahosted.org/freeipa/ticket/4133
+ host.run_command('%s ; (%s ||:)' % (restorecon_command, copyfiles_command))
# Remove all the files that did not exist and were 'backed up'
host.run_command(['xargs', '-d', r'\n', '-a', rmname, 'rm', '-vf'],