http://www.ezmlm.org/faq/FAQ6.html#ss6.7
--Adam
On Fri, Jan 01, 1999 at 08:41:47PM -0500, David Harris wrote:
> Hi,
>
> It appears that I've found a bug in qmail-1.03 regarding its handling of
> virtual domains. Actually, depending on your interpretation of the
> qmail-command(8), this could actually be a bug in ezmlm-0.53. However, my
> interpretation of qmail-command(8) seems to point to a bug in qmail.
>
> This apparent bug showed itself when I was trying to ezmlm to work with
> qmail on a virtual domain. I then re-produced the bug in a test case and
> documented it. From that I was able to patch together a solution whereas
> ezmlm would work in spite of the bug.
>
> Please entertain the assumption that my interpretation of qmail-command(8)
> is correct, and the bug lays in qmail, and I will present the test case,
> where I have isolated the bug first.
>
> test case
> ---------
>
> My basic q-mail configuration is as follows:
>
> ----
> [root@w1 /root]# cd /var/qmail/control
> [root@w1 control]# ls
> defaultdomain locals me
> plusdomain rcpthosts@ virtualdomains@
> [root@w1 control]#
> [root@w1 control]# cat defaultdomain
> drh.net
> [root@w1 control]# cat locals
> w1.drh.net
> [root@w1 control]# cat me
> w1.drh.net
> [root@w1 control]# cat plusdomain
> drh.net
> [root@w1 control]# cat rcpthosts
> w1.drh.net
> asdfasdf.com
> westegg.com
> westegg2.com
> [root@w1 control]# cat virtualdomains
> asdfasdf.com:davideous
> westegg.com:morgan
> westegg2.com:morgan
> [root@w1 control]#
> ----
>
> As you can see, the user morgan is setup to receive e-mail directed at
> westegg.com. Here are the relevant .qmail-* files from morgan's home
> directory:
>
> ----
> [root@w1 morgan]# cd ~morgan
> [root@w1 morgan]# ls -la .qmail-default .qmail-testforward*
> -rw-rw-r-- 1 morgan morgan 50 Jan 1 15:24 .qmail-default
> -rw-rw-r-- 1 morgan morgan 55 Jan 1 19:11 .qmail-testforward
> lrwxrwxrwx 1 morgan morgan 18 Jan 1 18:03
> .qmail-testforward-default -> .qmail-testforward
> [root@w1 morgan]# cat .qmail-default
> | ./.domains-update
> | fastforward -d .domains.cdb
> [root@w1 morgan]# cat .qmail-testforward
> |./fix-env sh -c "(cat;env;echo) >> /web/4/morgan/env"
> [root@w1 morgan]#
> ----
>
> (actually, I don't think .qmail-default is relevant, as it is not used in
> this example, but I included it anyway)
> (also, please excuse any un-intended line wrapping by my e-mail client of
> the above)
>
> So, I can send mail to [EMAIL PROTECTED] or
> [EMAIL PROTECTED] and it will fall under the jurisdiction of the
> ~morgan/.qmail-testforward file. Now, when qmail-local goes and processes
> this mail, it will not be delivered. Instead, a copy of the message and the
> environment will be sent to the file /web/4/morgan/env.
>
> When a test e-mail is sent to [EMAIL PROTECTED], here is what
> ends up in /web/4/morgan/env:
>
> ------
> Received: (qmail 9667 invoked by uid 512); 1 Jan 1999 22:38:26 -0000
> Date: 1 Jan 1999 22:38:09 -0000
> Message-ID: <[EMAIL PROTECTED]>
> to: [EMAIL PROTECTED]
> from: [EMAIL PROTECTED]
> subject: this is a test
>
> this is a test
> .
> EXT2=
> EXT3=
> EXT4=
> RPLINE=Return-Path: <[EMAIL PROTECTED]>
>
> LOCAL=morgan-testforward
> [EMAIL PROTECTED]
> TERM=dumb
> HOSTTYPE=i386
> PATH=/var/qmail/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/
> sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin
> EXT=testforward
> HOME=/web/4/morgan
> SHELL=/bin/bash
> HOST2=w1.drh
> HOST3=w1
> HOST4=w1
> [EMAIL PROTECTED]
> USER=morgan
> DTLINE=Delivered-To: [EMAIL PROTECTED]
>
> [EMAIL PROTECTED]
> HOST=w1.drh.net
> OSTYPE=Linux
> UFLINE=From [EMAIL PROTECTED] Fri Jan 01 22:38:29 1999
>
> SHLVL=1
> _=/usr/bin/env
> -----
>
> Note the RECIPIENT variable is set to "[EMAIL PROTECTED]", which
> is the intended recipient of the e-mail. Also HOST and LOCAL are the two
> parts of the RECIPIENT e-mail address.
>
> This is called for by the qmail-command(8) spec. To quote directly from the
> spec: "RECIPIENT is the envelope recipient address, local@domain. ... HOST
> is the domain part of the recipient address. LOCAL is the local part."
>
> Okay, that looks good. Now send an e-mail to [EMAIL PROTECTED] The
> following ends up in the /web/4/morgan/env file:
>
> -----
> Received: (qmail 9609 invoked by uid 512); 1 Jan 1999 22:31:30 -0000
> Date: 1 Jan 1999 22:31:11 -0000
> Message-ID: <[EMAIL PROTECTED]>
> to: [EMAIL PROTECTED]
> from: [EMAIL PROTECTED]
> subject: this is a test
>
> this is a test
> .
> EXT2=
> EXT3=
> EXT4=
> RPLINE=Return-Path: <[EMAIL PROTECTED]>
>
> LOCAL=morgan-testforward
> [EMAIL PROTECTED]
> TERM=dumb
> HOSTTYPE=i386
> PATH=/var/qmail/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/
> sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin
> EXT=testforward
> HOME=/web/4/morgan
> SHELL=/bin/bash
> HOST2=westegg
> HOST3=westegg
> HOST4=westegg
> [EMAIL PROTECTED]
> USER=morgan
> DTLINE=Delivered-To: [EMAIL PROTECTED]
>
> [EMAIL PROTECTED]
> HOST=westegg.com
> OSTYPE=Linux
> UFLINE=From [EMAIL PROTECTED] Fri Jan 01 22:31:35 1999
>
> SHLVL=1
> _=/usr/bin/env
> -----
>
> Now, the RECIPIENT environment variable is set to
> "[EMAIL PROTECTED]". Here is were the problem lies, RECIPIENT
> does not contain the actual recipient of the message, but some other
> address. This other address is not equivalent because it will not be handled
> in the same way by the qmail system, and may end up in a different mailbox
> than [EMAIL PROTECTED], the actual recipient.
>
> Additionally, because RECIPIENT is incorrect, LOCAL is also wrong. Also,
> this incorrect address ends up in the UFLINE environment variable.
>
> Furthermore, this wrong address is logged in the maillog:
>
> -----
> Jan 1 19:01:29 w1 qmail: 915235289.854352 new msg 32200
> Jan 1 19:01:29 w1 qmail: 915235289.854687 info msg 32200: bytes 210 from
> <[EMAIL PROTECTED]> qp 10255 uid 512
> Jan 1 19:01:29 w1 qmail: 915235289.914881 starting delivery 220: msg 32200
> to local [EMAIL PROTECTED]
> Jan 1 19:01:29 w1 qmail: 915235289.915041 status: local 1/10 remote 0/20
> Jan 1 19:01:29 w1 qmail: 915235289.928939 delivery 220: success: did_0+0+0/
> Jan 1 19:01:29 w1 qmail: 915235289.929194 status: local 0/10 remote 0/20
> Jan 1 19:01:29 w1 qmail: 915235289.929288 end msg 32200
> -----
>
> I believe that the RECIPIENT environment variable should be set to
> "[EMAIL PROTECTED]", as this is where the e-mail is being sent. Therefore,
> LOCAL would be "morgan", and UFLINE would have the correct address.
>
> But, because this error is also in the log files, I think it is not in the
> part of qmail-local which sets up the environment, but rather in the
> variables it's reading. I'm betting on the code which does the
> "[EMAIL PROTECTED] -> [EMAIL PROTECTED]" translation.
>
> actual case
> -----------
>
> I ran into this problem when configuration ezmlm to work under a
> virtualdomain. Because the enviorment was not setup correctly, it was
> rejecting the e-mail messages, claiming that it did not control the address.
> The message was bounced with the following error:
>
> -----
> Hi. This is the qmail-send program at w1.drh.net.
> I'm afraid I wasn't able to deliver your message to the following addresses.
> This is a permanent error; I've given up. Sorry it didn't work out.
>
> <[EMAIL PROTECTED]>:
> ezmlm-manage: fatal: I do not accept messages at this address (#5.1.1)
> -----
>
> I tried setting up another listserv and telling it that it was at
> [EMAIL PROTECTED], and everything worked fine.
>
> Searching through the source code for ezmlm, I found where this error was
> being produced in ezmlm-manage.c. It was comparing the environment variables
> LOCAL and HOST to some stored value, which I suspect is stored in the "key"
> file
>
> my workaround
> -------------
>
> Well, I wanted to get the ezmlm software working despite the weird
> environment produced by qmail-local. So, I just created a little wrapper for
> ezmlm-manage which fixes the environment before running ezmlm.
>
> Here is the wrapper and the modified .qmail-testlist-default file which
> calls it.
>
> -----
> [root@w1 morgan]# cd ~morgan
> [root@w1 morgan]# cat .qmail-testlist-default
> |./fix-env /usr/local/bin/ezmlm/ezmlm-manage '/web/4/morgan/testlist'
> |./fix-env /usr/local/bin/ezmlm/ezmlm-warn '/web/4/morgan/testlist' || exit
> 0
> [root@w1 morgan]# cat fix-env
> #!/usr/bin/perl
> #
> # fix-env
> # fixes enviorment created by qmail-local to match qmail-command(8) spec
> # basically, a fix for a bug in qmail
> #
>
> use strict var;
>
> {
> my $host = $ENV{'HOST'};
>
> if ( $host ne "w1.drh.net" )
> {
> my $local_wrong = $ENV{'LOCAL'};
> my $local_right = $local_wrong;
>
> $local_right =~ s/^[^-]+-//;
>
> my $local_wrong_re = quotemeta $local_wrong;
> my $local_right_re = quotemeta $local_right;
>
> $ENV{'DTLINE'} =~ s/$local_wrong_re/$local_right_re/g;
> $ENV{'RECIPIENT'} =~ s/$local_wrong_re/$local_right_re/g;
>
> $ENV{'LOCAL'} = $local_right;
> }
>
> exec(@ARGV);
>
> exit 111;
> }
>
>
> [root@w1 morgan]#
> -----
>
> With this wrapper in place, the ezmlm software works like a snap.
>
> - David Harris
> Principal Engineer, DRH Internet Services
>
>