# HG changeset patch # User Matt Johnston # Date 1420381363 -28800 # Node ID 2b62f26cf808ab77a1f81e5dfd2ff9de147fea45 # Parent fd2e8bbb03337d9042da8c72b81238a78d60d4a7 Open directories O_RDONLY for fsync, add debugging if it fails diff -r fd2e8bbb0333 -r 2b62f26cf808 gensignkey.c --- a/gensignkey.c Sat Nov 08 22:15:16 2014 +0800 +++ b/gensignkey.c Sun Jan 04 22:22:43 2015 +0800 @@ -41,7 +41,9 @@ out: if (fd >= 0) { - fsync(fd); + if (fsync(fd) != 0) { + dropbear_log(LOG_ERR, "fsync of %s failed: %s", filename, strerror(errno)); + } m_close(fd); } return ret; diff -r fd2e8bbb0333 -r 2b62f26cf808 svr-kex.c --- a/svr-kex.c Sat Nov 08 22:15:16 2014 +0800 +++ b/svr-kex.c Sun Jan 04 22:22:43 2015 +0800 @@ -91,12 +91,15 @@ #ifdef HAVE_LIBGEN_H char *fn_dir = m_strdup(fn); char *dir = dirname(fn_dir); - /* some OSes need the fd to be writable for fsync */ - int dirfd = open(dir, O_RDWR); + int dirfd = open(dir, O_RDONLY); if (dirfd != -1) { - fsync(dirfd); + if (fsync(dirfd) != 0) { + TRACE(("fsync of directory %s failed: %s", dir, strerror(errno))) + } m_close(dirfd); + } else { + TRACE(("error opening directory %s for fsync: %s", dir, strerror(errno))) } free(fn_dir);