- log_write(0, LOG_MAIN|LOG_PANIC_DIE,
- "Failed setting ownership on spool file %s: %s",
- spool_name, strerror(errno));
+{
+ int chown_errno = errno;
+ struct stat buf;
+
+ /* On NFSv4 with UID mapping the above fchown() might fail. If the
+ file is owned by the proper uid and gid, we won't report this failure. */
+ if (fstat(data_fd, &buf))
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE,
+ "Failed to stat on spool file %s: %s",
+ spool_name, strerror(errno));
+
+ if (buf.st_uid != exim_uid || buf.st_gid != exim_gid)
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE,
+ "Failed setting ownership on spool file %s: %s",
+ spool_name, strerror(chown_errno));
+}