[exim-cvs] fdatasync the spool data file

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Exim Git Commits Mailing List
Ημερομηνία:  
Προς: exim-cvs
Αντικείμενο: [exim-cvs] fdatasync the spool data file
Gitweb: https://git.exim.org/exim.git/commitdiff/690bc2ce8c7f0a76f01d03b5b158b0d64abbc86a
Commit:     690bc2ce8c7f0a76f01d03b5b158b0d64abbc86a
Parent:     f0ce0ecaa054ad9773a2078bc8f011a59518120a
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Oct 14 19:35:34 2023 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Dec 31 11:45:51 2023 +0000


    fdatasync the spool data file
---
 doc/doc-txt/ChangeLog |  4 ++++
 src/src/exim.h        |  2 +-
 src/src/receive.c     | 10 +++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index a7b8b68c7..b72819fb4 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -63,6 +63,10 @@ JH/12 Refuse to accept a line "dot, LF" as end-of-DATA unless operating in
       accept that in (normal) CRLF mode; this has been raised as a possible
       attack scenario (under the name "smtp smuggling").


+JH/13 Add an fdatasync call for the received message data file in spool, before
+      loggging reception and sending the SMTP ack.  Previously we only flushed
+      the stdio buffer so there was still the possibility of a disk error.
+



Exim version 4.97
diff --git a/src/src/exim.h b/src/src/exim.h
index ccf14f0fd..699b39165 100644
--- a/src/src/exim.h
+++ b/src/src/exim.h
@@ -569,7 +569,7 @@ requires various things that are set therein. */
#endif

#ifdef ENABLE_DISABLE_FSYNC
-# define EXIMfsync(f) (disable_fsync? 0 : fsync(f))
+# define EXIMfsync(f) (disable_fsync ? 0 : fsync(f))
#else
# define EXIMfsync(f) fsync(f)
#endif
diff --git a/src/src/receive.c b/src/src/receive.c
index ae7045068..63aded09f 100644
--- a/src/src/receive.c
+++ b/src/src/receive.c
@@ -4052,7 +4052,15 @@ else

receive_messagecount++;

-if (fflush(spool_data_file))
+if ( fflush(spool_data_file)
+#if _POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500
+# ifdef ENABLE_DISABLE_FSYNC
+ || !disable_fsync && fdatasync(data_fd)
+# else
+ || fdatasync(data_fd)
+# endif
+#endif
+ )
{
errmsg = string_sprintf("Spool write error: %s", strerror(errno));
log_write(0, LOG_MAIN, "%s\n", errmsg);

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/