Backup ipa-custodia conf and keys

https://pagure.io/freeipa/issue/7247

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Simo Sorce <ssorce@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Christian Heimes authored and Tomas Krizek committed 2017-11-13 18:10:54 +01:00
1 parent 49c77d7781
commit 8bbeedc93f
6 files changed
+43 -12

No files matched your search

+19
View File
@@ -326,6 +326,25 @@ def write_tmp_file(txt):
return fd
def flush_sync(f):
"""Flush and fsync file to disk
:param f: a file object with fileno and name
"""
# flush file buffer to file descriptor
f.flush()
# flush Kernel buffer to disk
os.fsync(f.fileno())
# sync metadata in directory
dirname = os.path.dirname(os.path.abspath(f.name))
dirfd = os.open(dirname, os.O_RDONLY | os.O_DIRECTORY)
try:
os.fsync(dirfd)
finally:
os.close(dirfd)
def shell_quote(string):
if isinstance(string, str):
return "'" + string.replace("'", "'\\''") + "'"