mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipatests: refactor FileBackup helper
* `cp` now preserves all attributes of original file, there is no reason to select only some of them * backup is now restored with `mv` instead of `cp` to avoid leaving junk Related to: https://pagure.io/freeipa/issue/8115 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
0f4c41ab26
commit
72540c4233
@ -1927,14 +1927,11 @@ class FileBackup:
|
||||
self._host = host
|
||||
self._filename = filename
|
||||
self._backup = create_temp_file(host)
|
||||
self._cp_cmd = ['cp']
|
||||
if is_selinux_enabled(host):
|
||||
self._cp_cmd.append('--preserve=context')
|
||||
host.run_command(self._cp_cmd + [filename, self._backup])
|
||||
host.run_command(['cp', '--preserve=all', filename, self._backup])
|
||||
|
||||
def restore(self):
|
||||
"""Restore file. Can be called multiple times."""
|
||||
self._host.run_command(self._cp_cmd + [self._backup, self._filename])
|
||||
self._host.run_command(['mv', self._backup, self._filename])
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
Loading…
Reference in New Issue
Block a user