On 2007-05-03 17:20:39 +0200, Dominik Meyer wrote:
> I found out, that qpsmtpd is using the date format of currently set 
> locale to generate the date

Argl. I guess that's a bug that every mail-related program has at least
once during its lifetime.


> in it's received line, which Outlook uses to check when the message
> has arrived at the last mailserver.  So solve this problem i wrote a
> small patch for Qpstmpd::SMTP. 

I ran into a similar problem some time ago: When a UTF-8 locale was
selected and the PERL_UNICODE variable was set, qpsmtpd would mangle
mails with octets with the 8th bit set (the details varied a bit and
aren't relevant here). The general response was "if it hurts then don't
do it", so I "fixed" the problem only in the RPMs (by unsetting
PERL_UNICODE in /etc/init.d/qpsmtpd-forkserver). I meant to send a
similar patch to Devin (for the debian package), but I think I forgot.

Anyway, thanks for pointing out that there are other locale
dependencies, too. I'll unset LANG and LC_* in the init.d-script for
now, but such places should probably be identified and fixed
individually.

> My patch just sets the standard C locale before generating the Date
> string.
> 
> Hope this patch can be usefull to someone. Comments are also welcome
> but please be gentle with me, because this is my first patch.

I hope you don't mind my using words like "evil". That's a terminus
technicus, no offence intended ;-)


> --- SMTP.pm.old       2007-05-03 16:43:50.000000000 +0200
> +++ SMTP.pm   2007-05-03 16:47:25.000000000 +0200
> @@ -534,6 +534,9 @@
>    my $authheader = (defined $self->{_auth} and $self->{_auth} == OK) ?
>      "(smtp-auth username $self->{_auth_user}, mechanism 
> $self->{_auth_mechanism})\n" : "";
>  
> +   #me need the english/C Locale here otherwise problems with outlook client
> +   my $loc = setlocale( LC_ALL, "C" );
> +
>    $header->add("Received", "from ".$self->connection->remote_info
>                 ." (HELO ".$self->connection->hello_host . ") 
> (".$self->connection->remote_ip
>                 . ")\n  $authheader  by ".$self->config('me')." 
> (qpsmtpd/".$self->version

I don't like that much. Setting a specific locale at the start of a
program is slightly ugly but acceptable. But setting it as a side effect
of a deeply buried function is evil. If some other function also expects
a specific locale (either C or something else) you can search forever to
find out why it works until the first mail is accepted and then stops
working or vice versa.

So either the locale should be reset at the end of the function to the
original value or it should be set globally.

(Also, I'm not 100% convinced that the fix is even guaranteed to be
correct. I don't have the C standard at hand to check - I'll do so when
I get home)

        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