At 12:57 PM 8/26/2005, Mark Crispin wrote:
What mailbox format are you using?

mbx


One very obvious way that this problem could be caused is if your system uses traditional UNIX mailbox format with a delivery program that writes a "From " header in UTC without a timezone, e.g.,
        From fred Fri Aug 26 15:56:46 2005

You called it Mark.  That is the case!


Since the timezone is missing, UW imapd's parsing code assumes that the time is in the local timezone. On every UNIX system that I've seen so far, that assumption would be correct.

Are you delivering directly from procmail? Or, is procmail calling some program such as /bin/mail, /bin/mail.local, etc. for final delivery?

qmail hands it off to procmail-3.10, which does the final mbox delivery. This makes me wonder why I can't find any other references to such a problem.


There are three ways that you can get around it.

The first is to replace the delivery program with a program (such as the UW IMAP toolkit's tmail or dmail) that writes POSIX-style dates that include a timezone, e.g.,
        From fred Fri Aug 26 10:56:46 2005 -0500

Although this is what I would recommend, a problem with doing this is that there are some ancient UNIX programs which choke on POSIX-style dates.

Alternatively, you can change the traditional UNIX mailbox format's default handling of timezone by editing imap-????/src/osdep/unix/unix.c to change the string "LCL" to be "GMT" in the statement:
                                /* zzz */
        t = zn ? (t + zn + 1) : (unsigned char *) "LCL";

Finally, you can look into why your delivery program is writing UTC date/time in the From without a timestamp, and get it to either write the date/time in local time or to write a POSIX-style date with a timestamp.

Thanks for the choices and the fast response. We'll discuss these and make a choice.



One last thing...

Since you mentioned qmail; if you use maildir format with a third-party maildir driver in UW imapd, then this is probably a bug in that driver. I can't say for sure what's wrong (I don't pretend to support maildir), but the following may help:

no maildir but thanks again for taking the time to spell it all out so quickly.


You need to find out how it determines the internaldate. If it sets the internaldate from the file mtime, make sure that it does something like:
      struct tm *tm = gmtime (&sbuf.st_mtime);
      elt->day = tm->tm_mday; elt->month = tm->tm_mon + 1;
      elt->year = tm->tm_year + 1900 - BASEYEAR;
      elt->hours = tm->tm_hour; elt->minutes = tm->tm_min;
      elt->seconds = tm->tm_sec;
      elt->zhours = 0; elt->zminutes = 0;

The setting of zhours and zminutes to zero makes it be UTC.

If the maildir driver uses localtime(), make sure that it calculates the timezone offset using a delta from the gmtime() value and *NOT* the timezone values in the returned struct tm. Look at phile.c to see how this is done.

The reason that you have to do this is that localtime() depends upon environment that isn't always completely set up for daemons; thus you can get localtime() returning a struct tm with the correct timezone offset but the time being UTC! Calculating the delta with gmtime() avoids this.

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.

Jim O'Leary
University of Illinois at Chicago
Academic Computing and Communications Center
(312) 996-4643
www.accc.uic.edu
_______________________________________________
Imap-uw mailing list
Imap-uw@u.washington.edu
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw

Reply via email to