On 2007-05-05 18:56:20 -0400, Guy Hulbert wrote:
> On Sat, 2007-05-05 at 14:23 -0700, Ask Bjørn Hansen wrote:
> > If we want to set LANG={undef,C}, I think we should do it from the  
> > run/init.d script

I already did that for the RPM (but I ran into packaging problems - the
Danga stuff is drawing dependencies in which I haven't sorted out yet,
so for those of you who use my RPMs please don't try to upgrade now).

> > and just have qpsmtpd warn if it's set and not to C.
> 
> Agreed.

A warning may be too easy to miss.


> > Another option, saner seeming by now, is to just explicitly format  
> > the dates we generate ...
> 
> How "explicit"?  

Like this: 

    my @weekdays = qw(Sun Mon Tue Wed Thu Fri Sat);
    my @months   = qw(Jan Feb Mar ... Dec);
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
    my $date = sprintf("%s, %02d %s %d %02d:%02d:%02d %s",
                       $weekdays[$wday],
                       $mday,
                       $monts[$mon],
                       $year + 1900,
                       $hour, $min, $sec,
                       $timezone):

It's a bit tricky to compute the timezone correctly, though.



> What do the SMTP RFCs say about date formats in mail headers?  If they
> specify ASCII/English then LANG=C is sufficient ... let me see ...
> RFC 2822, section 3.3 specifies English 3-letter abreviations for day
> and month names and specifies that:
> 
>         A date-time specification MUST be semantically valid.  That is, the
>         day-of-the-week (if included) MUST be the day implied by the date,
>         the numeric day-of-month MUST be between 1 and the number of days
>         allowed for the specified month [etc]
> 
> It has some rules for numeric formats ... I suspect that 'strftime' with
> LANG=C is consistent with this

For C99, yes.

> and rolling your own would be a fair bit of work to get everything
> correct.

The timezone is a bit tricky, the rest is easy (see above).


> RFC 2822 does say that time zones should be represented as offsets from
> gmtime ... my own notes say that 'z' gives this but this is not in the
> portable list from POSIX and my notes say:
> 
>       # z numeric time-zone RFC 822/ISO 8601:1988 ( ISO C99 and POSIX.1-2001)

Thanks for noticing this. Yes, "z" was only introduced in C99.

So basically, if we can assume a C99-compatible strftime implementation,
and we make sure that LC_TIME is (implicitely or explicitely) set to
"C", we can use strftime. If we care about platforms where this is not
the case we must format the datestring ourselves.

        hp

-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | [EMAIL PROTECTED]         |
__/   | http://www.hjp.at/ |    -- Sam in "Freefall"

Attachment: signature.asc
Description: Digital signature

Reply via email to