Add NFSv4 spool file patch hs12/nfsv4-spool exim-4_91_hs
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Tue, 29 Jan 2019 19:55:35 +0000 (20:55 +0100)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Tue, 29 Jan 2019 19:55:35 +0000 (20:55 +0100)
Do not complain about a failed fchown() if the file
has the proper ownership.

src/src/receive.c

index cba53c20dd4d433173dc3d6acae5e291f446ef78..bda0f79bf0803efb7be62075faa788eb78e4ff5a 100644 (file)
@@ -3039,9 +3039,22 @@ if ((data_fd = Uopen(spool_name, O_RDWR|O_CREAT|O_EXCL, SPOOL_MODE)) < 0)
 because the group setting doesn't always get set automatically. */
 
 if (fchown(data_fd, exim_uid, exim_gid))
-  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));
+}
 (void)fchmod(data_fd, SPOOL_MODE);
 
 /* We now have data file open. Build a stream for it and lock it. We lock only
@@ -4188,7 +4201,7 @@ if(!smtp_reply)
   if (deliver_freeze) log_write(0, LOG_MAIN, "frozen by %s", frozen_by);
   if (queue_only_policy) log_write(L_delay_delivery, LOG_MAIN,
     "no immediate delivery: queued%s%s by %s",
-    *queue_name ? " in " : "", *queue_name ? CS queue_name : "",       
+    *queue_name ? " in " : "", *queue_name ? CS queue_name : "",
     queued_by);
   }
 receive_call_bombout = FALSE;