[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SMTP to user@[1.2.3.4]



> Hi,	(I do seem to be filling this list up a lot lately :-)

	No problem, except that sometimes I can't easily come
	up with an answer.  Oh btw, have a look at:  www.zmailer.org
	I am pushing my manual writing project stuff into there again
	latter today.  Comments are solicited.

> This is my latest problem, which I seem to have been able to resolve.
> 
> I have some mail aliases in the form "user@[1.2.3.4]", which I wish to be
> sent to the smtp channel.  First of all I fixed the default rrouter.cf file:
> 
> --- rrouter.cf	Sun Jun 15 23:25:01 1997
> +++ /var/lib/zmailer/cf/rrouter.cf	Wed Oct 22 00:57:42 1997
> @@ -78,10 +97,10 @@
>  ## Following two are two approaces to the same problem, generally
>  ## speaking we should use the SECOND one, but your mileage may vary..
>  ## (Problems exist when WE are the target..)
> -#	(.*)<@\[(.)\]>(.*)
> +#	(.*)<@\[([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\]>(.*)
>  #		address="\1$plustail<@$(gethostbyaddr \2)>\3"
>  #		;;
> -	(.*)<@\[(.)\]>(.*)
> +	(.*)<@\[([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\]>(.*)
>  		# numeric internet spec
>  		if [ $(selfmatch "\2") ]; then
>  			address="\1$plustail<@>\3"
> 
> 
> Matti: I am not sure if you received my mail I sent a few days ago with
>        that patch, you kindly replied to query I sent to the list, I sent
>        this diff before.  Basically I think a missing "+" char in \2
>        (.*)<@\[(.+)\]>(.*) is the problem.  If you didn't receive my
>        message then that is probably my IAP silently dropping my mail.

	No, I don't see it, which does not necesserily mean that I have
	not received it.  I may have accidentally thrown it away...

	Your analysis is essentially correct.  The selfaddrs routines
	were tested when they were implemented way back before 2.99.48,
	but then my underlying systems changed a bit -- automatic interface
	scanning including, and although things were tested on the smtp
	transport agent, apparently I skipped router..

> This worked fine for the system sending the mail, the zmailer system
> receiving this would send the postmaster a message:
> 
> --------------------------------------
> Content-Type: text/plain
> 
> This is a collection of reports about email delivery
> process concerning a message you originated:
> 
> <smtp [44.131.137.9] user@thor.g7led.ampr.org 2>: Trying to talk with myself!
> --------------------------------------
> 
> Presumably the system 44.131.137.9 was connecting to itself and trying to
> send the mail.  I went back to the same routing rule.
> 
> This is what the default configuration more-o-less indicates in
> rrouter.cf with:
> 
> ## -----------------------------------------------------------------
> ## Following two are two approaces to the same problem, generally
> ## speaking we should use the SECOND one, but your mileage may vary..
> ## (Problems exist when WE are the target..)
> #	(.*)<@\[([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\]>(.*)
> #		address="\1$plustail<@$(gethostbyaddr \2)>\3"
> #		;;
> 	(.*)<@\[([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\]>(.*)
> 		# numeric internet spec
> 		if [ $(selfmatch "\2") ]; then
> 			address="\1$plustail<@>\3"
> 			domain="@[\2]"
> 			plustail=""
> 		else
> 			return (((smtp "[\2]" "\1$plustail@$(gethostbyaddr \2)\3" $A)))
> 		fi
> 		;;
> ## end of [1.2.3.4] address case..
> ## -----------------------------------------------------------------
> 
> I note the "Problems exist when WE are the target..." (I'm not one to
> be put off by such things ]:-).
> 
> The $(selfmatch "\2") test ALWAYS fails, I have not tried putting anything
> into /etc/zmailer.conf for SELFADDRESSES since I wanted to know why an
> strace (with Linux) showed it scanning my network interfaces (which do
> match the address it was checking).

	The SELFADDRESSES was initial attempt at providing the address
	information for the systems, but after that I did have a need
	to install the beast into "high availability pair" -- two hosts
	backing up each other, and I used sendmail sources to have interface
	scanner for IPv4 (IPv6 does not have well established API for it)

	Pretty soon after the subsequent code was installed at my work
	for the pair of smtp servers, one of them crashed, and it took
	me entire 15 minutes to configure the other one to take up also
	its roles.  (Mostly I just had to verify that router does not
	have special assumptions in it about the role the system is in
	so that I can do "ifconfig eth0:0 1.2.3.4" with the other host's
	IP address with minimum fuss.  Smtpserver, scheduler and transport
	agents didn't need any alterations, nor restarts.)
	It had taken 15 minutes since the crash before I was called in
	for help...


	I think one of the "trouble brewing up" things with the numeric
	addresses is that in case of this kind of backup pairs it really
	does not guarantee that the delivery of email will end up in
	correct host -- but using it is very kludgy thing anyway :-)

> I planked about in the source of zmailer looking for selfmatch, found it in
> ./router/libdb/selfmatch.c and examined it more closely.  I can up with the
> following patch (I have NOT tested the IPV6 parts, and have never programmed
> for IPV6 socket, nor are sure if the naming conventions for sockaddr have
> been set, but linux uses sin6_addr).

	That is what the IETF IPng socket API defines.
	(And IMO it is high time to have formal API specification
	 for things like this, and not just try to mimic somebody's
	 implementation -- the original socket API is BSD thing.)

> Basically what was happening is the string address "44.131.137.9" was being
> converted into a 32bit network byte order address, but being copied to the
> wrong place in the sockaddr struct.

	Oops..  Fix inserted.

> --- selfmatch.c~	Mon Oct 27 23:39:43 1997
> +++ selfmatch.c	Mon Oct 27 23:39:43 1997
> -----------------------------------------------------------
> 
> Now my system:
> 
> g7led:/# sendmail -bt
> ZMailer router (2.99.49p4 #1: Mon Oct 20 22:14:50 BST 1997)
>   root@odin:/thor/usr4/zmailer-2.99.49p3/router
> Copyright 1992 Rayan S. Zachariassen
> Copyright 1992-1997 Matti Aarnio
> 
> z# if [ $(selfmatch "127.0.0.1") ]; then echo Yes; else echo No; fi
> Yes
> z# if [ $(selfmatch "44.1.2.3") ]; then echo Yes; else echo No; fi
> No
> z# if [ $(selfmatch "44.131.137.9") ]; then  echo Yes; else echo No; fi
> Yes
> z#
> 
> I'm a happy chappy.
> 
> 
> I wonder if this is the ONLY problem known about for using user@[1.2.3.4]
> form?

	Basically yes.

> BTW: I am running 2.99.49p4 not 2.99.49p5 (which is the latest, but does
>      anyone have the patch between the two?  funet hasn't).  Perhaps all
>      this has been fixed already?

	It will be in 2.99.49p9.
	(ftp.funet.fi has 2.99.49p8, but p6 and p7 never made it to public..)

> -- 
> Darryl Miles

/Matti Aarnio