mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-11-02 20:30:26 -06:00
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:
1 parent
49c77d7781
commit
8bbeedc93f
6 files changed
+43
-12
No files matched your search
@@ -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("'", "'\\''") + "'"
|
||||
|
||||
Reference in new issue
Block a user