From b2007beeb0203c8f9f3d6d07329d0d1fceea91c7 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 18 Oct 2019 23:48:16 +0800 Subject: [PATCH] bring back fsync_parent_dir --- gensignkey.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gensignkey.c b/gensignkey.c index 8317feaf1..34b6f5a29 100644 --- a/gensignkey.c +++ b/gensignkey.c @@ -152,6 +152,10 @@ int signkey_generate(enum signkey_type keytype, int bits, const char* filename, } } + /* ensure directory update is flushed to disk, otherwise we can end up + with zero-byte hostkey files if the power goes off */ + fsync_parent_dir(filename); + out: if (buf) { buf_burn(buf);