|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Subject: Re: A question on explicit forwarding without DNS query
From: bert hubert (ahu
ds9a.nl)Date: Sat Jun 10 2000 - 16:14:59 CDT
- Next message: Dylan Griffiths: "Re: Master can't spawn smtp properly."
- Previous message: Wietse Venema: "Re: A question on explicit forwarding without DNS query"
- In reply to: Wietse Venema: "Re: A question on explicit forwarding without DNS query"
- Reply: bert hubert: "Re: A question on explicit forwarding without DNS query"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jun 10, 2000 at 02:22:00PM -0400, Wietse Venema wrote:
> user
domain support in the transport or routing map will eventually
> fix this. Until then, the more flexible sendmail has an edge in
> this respect, since it can rewrite (transport, nexthop, recipient)
> independently.
Ok,
I have implemented the following extension to the transport map:
bar
foo.org :[gateway.foo.org]
Or whatever you want on the RHS.
This is done by removing the stripping everything before the last '
' in
resolve.c when calling transport_lookup(), and doing so again there, but
only after a lookup on the full address was attempted.
Initial rough cut at a patch is attached at the end of this message. Wietse,
if you want me to polish this up, and document it in transport.5, or if you
have further hints, please let me know.
Regards,
Bert Hubert
diff -u -r snapshot-20000514.orig/trivial-rewrite/resolve.c snapshot-20000514/trivial-rewrite/resolve.c
--- snapshot-20000514.orig/trivial-rewrite/resolve.c Thu May 11 03:28:33 2000
+++ snapshot-20000514/trivial-rewrite/resolve.c Sat Jun 10 21:26:00 2000

-194,7 +194,7 
* transport maps cannot return zero-length hostnames.
*/
if (*var_transport_maps
- && transport_lookup(strrchr(STR(nextrcpt), '
') + 1, channel, nexthop)) {
+ && transport_lookup(STR(nextrcpt), channel, nexthop)) {
/* void */ ;
}
diff -u -r snapshot-20000514.orig/trivial-rewrite/transport.c snapshot-20000514/trivial-rewrite/transport.c
--- snapshot-20000514.orig/trivial-rewrite/transport.c Wed Nov 17 01:15:41 1999
+++ snapshot-20000514/trivial-rewrite/transport.c Sat Jun 10 23:07:37 2000

-14,7 +14,7 
/* VSTRING *nexthop;
/* DESCRIPTION
/* This module implements access to the table that maps transport
-/* domains to (channel, nexthop) tuples.
+/* domains, or full addresses, to (channel, nexthop) tuples.
/*
/* transport_init() performs initializations that should be
/* done before the process enters the chroot jail, and

-79,14 +79,15 
DICT_FLAG_LOCK);
}
-/* transport_lookup - map a transport domain */
+/* transport_lookup - map a transport domain, possibly including a username */
-int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop)
+int transport_lookup(const char *address, VSTRING *channel, VSTRING *nexthop)
{
- char *low_domain = lowercase(mystrdup(domain));
+ char *low_address = lowercase(mystrdup(address));
const char *name;
const char *value;
const char *host;
+ const char *low_domain;
char *saved_value;
char *transport;
int found = 0;

-99,37 +100,63 
if (transport_path == 0)
msg_panic("transport_lookup: missing initialization");
- /*
- * Keep stripping domain components until nothing is left or until a
- * matching entry is found.
- *
- * After checking the full name, check for .upper.domain, to distinguish
- * between the upper domain and it's decendants, ala sendmail and tcp
- * wrappers.
- *
- * Before changing the DB lookup result, make a copy first, in order to
- * avoid DB cache corruption.
- *
- * Specify if a key is partial or full, to avoid matching partial keys with
- * regular expressions.
- */
- for (name = low_domain; name != 0; name = strchr(name + 1, '.')) {
+
+ if((low_domain=strrchr(low_address,'
'))!=0){
+ low_domain++; /* skip the
*/
+ /* first try if we have a transport entry for the entire address */
+
+ msg_warn("was asked to lookup '%s'",address);
+
+
+ if ((value = maps_find(transport_path, low_address, maps_flag)) != 0) {
+ msg_warn("maps_find returned '%s' for complete address '%s'",value,low_address);
+ found=1;
+ } else if (dict_errno != 0) {
+ msg_fatal("transport table lookup problem");
+ }
+ }
+ else low_domain=low_address;
+
+ /* no luck resolving the entire address, try with just the domain */
+ if(!found){
+
+ /*
+ * Keep stripping domain components until nothing is left or until a
+ * matching entry is found.
+ *
+ * After checking the full name, check for .upper.domain, to distinguish
+ * between the upper domain and it's decendants, ala sendmail and tcp
+ * wrappers.
+ *
+ * Before changing the DB lookup result, make a copy first, in order to
+ * avoid DB cache corruption.
+ *
+ * Specify if a key is partial or full, to avoid matching partial keys with
+ * regular expressions.
+ */
+ for (name = low_domain; name != 0; name = strchr(name + 1, '.')) {
if ((value = maps_find(transport_path, name, maps_flag)) != 0) {
- saved_value = mystrdup(value);
- if ((host = split_at(saved_value, ':')) == 0 || *host == 0)
- host = domain;
- if (*(transport = saved_value) == 0)
- transport = var_def_transport;
- vstring_strcpy(channel, transport);
- vstring_strcpy(nexthop, host);
- myfree(saved_value);
- found = 1;
- break;
+
+ found = 1;
+ break;
} else if (dict_errno != 0) {
- msg_fatal("transport table lookup problem");
+ msg_fatal("transport table lookup problem");
}
maps_flag = PARTIAL;
+ }
}
- myfree(low_domain);
+
+ if(found){
+ saved_value = mystrdup(value);
+ if ((host = split_at(saved_value, ':')) == 0 || *host == 0)
+ host = low_domain;
+ if (*(transport = saved_value) == 0)
+ transport = var_def_transport;
+ vstring_strcpy(channel, transport);
+ vstring_strcpy(nexthop, host);
+ myfree(saved_value);
+ }
+
+ myfree(low_address);
return (found);
}
--
| http://www.rent-a-nerd.nl
| - U N I X -
| Inspice et cautus eris - D11T'95
- Next message: Dylan Griffiths: "Re: Master can't spawn smtp properly."
- Previous message: Wietse Venema: "Re: A question on explicit forwarding without DNS query"
- In reply to: Wietse Venema: "Re: A question on explicit forwarding without DNS query"
- Reply: bert hubert: "Re: A question on explicit forwarding without DNS query"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]