mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 07:33:27 -06:00
ipatests: Restore SELinux context after restoring files from backup
Part of: https://fedorahosted.org/freeipa/ticket/3833
This commit is contained in:
parent
775f2de4ec
commit
4fd88140b1
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user