From: Shaun A. Johnson Date: Mon, 13 Aug 2018 23:35:54 +0000 (-0700) Subject: lib: Split up logic in nfs_flush_chown_uid X-Git-Tag: 2.3.8~199 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4b7711bffca93531da663f82d172c05007d028c;p=thirdparty%2Fdovecot%2Fcore.git lib: Split up logic in nfs_flush_chown_uid This splits up the logic of nfs_flush_chown_uid() so that there is an individual chown call for each platform instead of a single call that is compiled for both platforms. This is the first step to adjusting how nfs attributes are flushed on Linux because of an issue with chown resetting permissions on the files. --- diff --git a/src/lib/nfs-workarounds.c b/src/lib/nfs-workarounds.c index 9498cb195d..bcbfcd7579 100644 --- a/src/lib/nfs-workarounds.c +++ b/src/lib/nfs-workarounds.c @@ -150,6 +150,17 @@ static void nfs_flush_chown_uid(const char *path) #ifdef ATTRCACHE_FLUSH_CHOWN_UID_1 uid = (uid_t)-1; + if (chown(path, uid, (gid_t)-1) < 0) { + if (errno == ESTALE || errno == EPERM || errno == ENOENT) { + /* attr cache is flushed */ + return; + } + if (likely(errno == ENOENT)) { + nfs_flush_file_handle_cache_parent_dir(path); + return; + } + i_error("nfs_flush_chown_uid: chown(%s) failed: %m", path); + } #else struct stat st; @@ -167,7 +178,6 @@ static void nfs_flush_chown_uid(const char *path) i_error("nfs_flush_chown_uid: stat(%s) failed: %m", path); return; } -#endif if (chown(path, uid, (gid_t)-1) < 0) { if (errno == ESTALE || errno == EPERM || errno == ENOENT) { /* attr cache is flushed */ @@ -179,6 +189,7 @@ static void nfs_flush_chown_uid(const char *path) } i_error("nfs_flush_chown_uid: chown(%s) failed: %m", path); } +#endif } #ifdef __FreeBSD__