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

SMTP to user@[1.2.3.4]




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

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.

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).

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).

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.

--- selfmatch.c~	Mon Oct 27 23:39:43 1997
+++ selfmatch.c	Mon Oct 27 23:39:43 1997
@@ -53,7 +53,7 @@
 
 	  memset(&si6, 0, sizeof(si6));
 	  si6.sin6_family = AF_INET6;
-	  rc = inet_pton(AF_INET6, sip->key+5, (void*)&si6);
+	  rc = inet_pton(AF_INET6, sip->key+5, (void*)&si6.sin6_addr);
 	  if (rc < 1)
 	    return NULL;
 	  rc = matchmyaddress((struct sockaddr *)&si6);
@@ -65,7 +65,7 @@
 
 	  memset(&si4, 0, sizeof(si4));
 	  si4.sin_family = AF_INET;
-	  rc = inet_pton(AF_INET, sip->key, (void*)&si4);
+	  rc = inet_pton(AF_INET, sip->key, (void*)&si4.sin_addr);
 	  if (rc < 1)
 	    return NULL;
 	  rc = matchmyaddress((struct sockaddr *)&si4);
-----------------------------------------------------------

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?


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?

-- 
Darryl Miles