[exim-cvs] Use message_id for tempfile creation Closes 2390

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] Use message_id for tempfile creation Closes 2390
Gitweb: https://git.exim.org/exim.git/commitdiff/cb80814d149dcab2d967bbf1b24e50436bcf374b
Commit:     cb80814d149dcab2d967bbf1b24e50436bcf374b
Parent:     cef8a6effdef4cb157c566369b61087b42d9b162
Author:     Heiko Schlittermann (HS12-RIPE) <hs@???>
AuthorDate: Wed Apr 17 08:38:19 2019 +0200
Committer:  Heiko Schlittermann (HS12-RIPE) <hs@???>
CommitDate: Thu Apr 18 12:28:11 2019 +0200


    Use message_id for tempfile creation Closes 2390


    Make tempfile names unique across Exim instances running in a cluster on
    a shared $spool_directory. (They need to set localhost_number to have
    cluster-unique message_exim_ids.)
---
 doc/doc-txt/ChangeLog | 6 ++++++
 src/src/spool_out.c   | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 07ab3f0..01ee179 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -64,6 +64,12 @@ JH/14 Bug 1891: Close the log file if receiving a non-smtp message, without
       (a previous attempt to fix addressed lack, for a long time, of initial
       input).


+HS/01 Bug 2390: Use message_id for tempfile creation to avoid races in a
+      shared (NFS) environment. The length of the tempfile name is now
+      4 + 16 ("hdr.$message_exim_id") which might break on file
+      systems which restrict the file name length to lower values.
+      (It was "hdr.$pid".)
+


Exim version 4.92
-----------------
diff --git a/src/src/spool_out.c b/src/src/spool_out.c
index 3970206..a4a734a 100644
--- a/src/src/spool_out.c
+++ b/src/src/spool_out.c
@@ -134,8 +134,7 @@ struct stat statbuf;
uschar * tname;
uschar * fname;

-tname = spool_fname(US"input", message_subdir,
-            string_sprintf("hdr.%d", (int)getpid()), US"");
+tname = spool_fname(US"input", message_subdir, US"hdr.", message_id);


if ((fd = spool_open_temp(tname)) < 0)
return spool_write_error(where, errmsg, US"open", NULL, NULL);