[Dovecot] dovecot and time

Ben Morrow ben at morrow.me.uk
Wed Jun 5 20:32:38 EEST 2013


At 11AM -0500 on  5/06/13 you (Rick Romero) wrote:
> I found something interesting via strace.  lda is writing a timestamp  
> with utime before doign the fsync, but I'm really not a C guy, so I  
> have no idea why that's going on via procmail and not via commandline.  
>   I assume it's related to the choice of pread64 vs read.
> 
> when called from commandline (working):
> 
> read(0, "July 14-20, 2013\n10 courses. Bon"..., 4096) = 4096
[...]
> open("/usr/home/vpopmail/domains/havokmon.com/rick/Maildir/tmp/1370448645.M589211P14191.smtp101", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_LARGEFILE, 0777) =  
> 11
[...]
> 
> when called from procmail (not working):
> 
> pread64(10, "00.vfemail.net,S=10941\n968 W2552"..., 4064, 52993) = 4064
[...]
> open("/usr/home/vpopmail/domains/havokmon.com/rick/Maildir/tmp/1370449940.M313792P17436.smtp101",
> O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_LARGEFILE, 0777) =  
> 11
[...]
> utime("/usr/home/vpopmail/domains/havokmon.com/rick/Maildir/tmp/1370449940.M313792P17436.smtp101", [2013/06/05-16:32:20, 2013/06/05-21:32:18]) =  
[...]

Eeenteresting. The pread64 vs read is presumably because procmail is
passing lda a regular file on stdin rather than a pipe; you can't use
pread on a pipe. I wondered if maybe lda might be copying the timestamp
across from its input file, which it isn't, but while checking that I
found this (in src/lda/main.c):

	/* If input begins with a From-line, drop it */
	ret = i_stream_read_data(input, &data, &size, 5);
	if (ret > 0 && size >= 5 && memcmp(data, "From ", 5) == 0) {
            /* ... */
				(void)mbox_from_parse(data, i, mtime_r, &tz,
						      &sender);
            /* ... */
	}

which says to me that if lda is passed a mail starting with an
mbox-format From_ line, it will use the datestamp from that line rather
than the current time. Procmail likes to give things From_ lines, so
it's likely this is what's happening.

Can you add something to the procmail recipe to write the mail out
somewhere unmodified, to see whether procmail is writing the date out
wrong or dovecot is parsing it wrong? Presumably the timezone
information is getting screwed up somewhere; is procmail leaving it out
altogether, or maybe writing a named timezone (which Dovecot will
ignore, apparently)?

You may be able to help matters by running the whole delivery process
(both procmail and lda) with TZ=UTC (and probably LC_ALL=C for good
measure), just to try and get things to use machine-readable rather than
human-readable timestamp formats. You could also try head -n +1 | lda,
or something a little less crude.

Ben



More information about the dovecot mailing list