[Dovecot] Maildir files with mtime in the future

Holger Weiss holger at CIS.FU-Berlin.DE
Thu Apr 2 20:36:15 EEST 2009


If Maildir storage is used, the mtime of a given Maildir file is set to
the message's INTERNALDATE.  Now, when a client APPENDs a message to an
IMAP mailbox, the client may optionally specify the INTERNALDATE:

| If a date-time is specified, the internal date SHOULD be set in the
| resulting message; otherwise, the internal date of the resulting
| message is set to the current date and time by default.

[ ftp://ftp.fu-berlin.de/doc/rfc/rfc3501.txt (6.3.11. APPEND Command) ]

However, if the client does so, Dovecot will set the mtime of the
Maildir file in question to the date specified by the client even if
it's in the future.  Since files with an mtime in the future can cause
all sorts of trouble (e.g., they might get backed up repeatedly by
incremental backups), it would be nice if Dovecot would (optionally?)
use the current time if the client specifies a time in the future.  For
example, we use the following patch:

---------- 8< ---------------------------------------- 8< ----------

diff --git a/src/imap/cmd-append.c b/src/imap/cmd-append.c
index 0b22fd5..b7e42b9 100644
--- a/src/imap/cmd-append.c
+++ b/src/imap/cmd-append.c
@@ -319,6 +319,12 @@ static bool cmd_append_continue_parsing(struct client_command_context *cmd)
 		return cmd_append_cancel(ctx, nonsync);
 	}
 
+	if (internal_date != (time_t)-1 && internal_date > time(NULL)) {
+		/* the client specified a time in the future, set it to now. */
+		internal_date = (time_t)-1;
+		timezone_offset = 0;
+	}
+
 	if (ctx->msg_size == 0) {
 		/* no message data, abort */
 		client_send_tagline(cmd, "NO Can't save a zero byte message.");

---------- 8< ---------------------------------------- 8< ----------

Holger


More information about the dovecot mailing list