[exim-cvs] cvs commit: exim/exim-doc/doc-txt ChangeLog NewSt…

Góra strony
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
Dla: exim-cvs
Temat: [exim-cvs] cvs commit: exim/exim-doc/doc-txt ChangeLog NewStuff exim/exim-src/src dns.c exim.h functions.h exim/exim-src/src/lookups dnsdb.c exim/exim-test-orig/AutoTest/scripts 082 exim/exim-test-
ph10 2004/11/19 09:45:54 GMT

  Modified files:
    exim-doc/doc-txt     ChangeLog NewStuff 
    exim-src/src         dns.c exim.h functions.h 
    exim-src/src/lookups dnsdb.c 
    exim-test-orig/AutoTest/scripts 082 
    exim-test-orig/AutoTest/stdout 082 353 
  Log:
  Implement the pseudo dns lookup type "zns" for ${dnsdb lookups.


  Revision  Changes    Path
  1.34      +10 -0     exim/exim-doc/doc-txt/ChangeLog
  1.12      +21 -0     exim/exim-doc/doc-txt/NewStuff
  1.2       +64 -8     exim/exim-src/src/dns.c
  1.2       +5 -0      exim/exim-src/src/exim.h
  1.5       +1 -0      exim/exim-src/src/functions.h
  1.2       +11 -3     exim/exim-src/src/lookups/dnsdb.c
  1.5       +1 -0      exim/exim-test-orig/AutoTest/scripts/082
  1.5       +1 -0      exim/exim-test-orig/AutoTest/stdout/082
  1.2       +2 -2      exim/exim-test-orig/AutoTest/stdout/353


  Index: ChangeLog
  ===================================================================
  RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ChangeLog    18 Nov 2004 11:17:33 -0000    1.33
  +++ ChangeLog    19 Nov 2004 09:45:54 -0000    1.34
  @@ -1,4 +1,4 @@
  -$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.33 2004/11/18 11:17:33 ph10 Exp $
  +$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.34 2004/11/19 09:45:54 ph10 Exp $


   Change log file for Exim from version 4.21
   -------------------------------------------
  @@ -141,6 +141,16 @@
   35. If an IPv6 address is given for -bh or -bhc, it is now converted to the
       canonical form (fully expanded) before being placed in
       $sender_host_address.
  +
  +36. The table in the code that translates DNS record types into text (T_A to
  +    "A" for instance) was missing entries for NS and CNAME. It is just possible
  +    that this could have caused confusion if both these types were looked up
  +    for the same domain, because the text type is used as part of Exim's
  +    per-process caching. But the chance of anyone hitting this buglet seems
  +    very small.
  +
  +37. The dnsdb lookup has a new type, "zns", which walks up the domain tree
  +    until it finds some nameserver records. It should be used with care.



Exim version 4.43

  Index: NewStuff
  ===================================================================
  RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- NewStuff    17 Nov 2004 16:12:26 -0000    1.11
  +++ NewStuff    19 Nov 2004 09:45:54 -0000    1.12
  @@ -1,4 +1,4 @@
  -$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.11 2004/11/17 16:12:26 ph10 Exp $
  +$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.12 2004/11/19 09:45:54 ph10 Exp $


   New Features in Exim
   --------------------
  @@ -107,6 +107,27 @@
         condition = ${if eq {$acl_m4}{1}}


       Previously this was a syntax error.
  +
  +12. There is now a new "record type" that can be specified in dnsdb lookups. It
  +    is "zns" (for "zone NS"). It performs a lookup for NS records on the given
  +    domain, but if none are found, it removes the first component of the domain
  +    name, and tries again. This process continues until NS records are found
  +    or there are no more components left (or there's a DNS error). In other
  +    words, it may return the name servers for a top-level domain, but it never
  +    returns the root name servers. If there are no NS records for the top-level
  +    domain, the lookup fails.
  +
  +    For example, ${lookup dnsdb{zns=xxx.quercite.com}} returns the name
  +    servers for quercite.com, whereas ${lookup dnsdb{zns=xxx.edu}} returns
  +    the name servers for edu, assuming in each case that there are no NS
  +    records for the full domain name.
  +
  +    You should be careful about how you use this lookup because, unless the
  +    top-level domain does not exist, the lookup will always return some host
  +    names. The sort of use to which this might be put is for seeing if the name
  +    servers for a given domain are on a blacklist. You can probably assume that
  +    the name servers for the high-level domains such as .com or .co.uk are not
  +    going to be on such a list.



Version 4.43

  Index: dns.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/dns.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- dns.c    7 Oct 2004 10:39:01 -0000    1.1
  +++ dns.c    19 Nov 2004 09:45:54 -0000    1.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/dns.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/dns.c,v 1.2 2004/11/19 09:45:54 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -258,14 +258,16 @@
   {
   switch(t)
     {
  -  case T_A:    return US"A";
  -  case T_MX:   return US"MX";
  -  case T_AAAA: return US"AAAA";
  -  case T_A6:   return US"A6";
  -  case T_TXT:  return US"TXT";
  -  case T_PTR:  return US"PTR";
  -  case T_SRV:  return US"SRV";
  -  default:     return US"?";
  +  case T_A:     return US"A";
  +  case T_MX:    return US"MX";
  +  case T_AAAA:  return US"AAAA";
  +  case T_A6:    return US"A6";
  +  case T_TXT:   return US"TXT";
  +  case T_PTR:   return US"PTR";
  +  case T_SRV:   return US"SRV";
  +  case T_NS:    return US"NS";
  +  case T_CNAME: return US"CNAME";  
  +  default:      return US"?";
     }
   }


@@ -612,6 +614,60 @@
right... */

   log_write(0, LOG_MAIN, "CNAME loop for %s encountered", orig_name);
  +return DNS_FAIL;
  +}
  +
  +
  +
  +
  +
  +
  +/************************************************
  +*    Do a DNS lookup and handle virtual types   *
  +************************************************/
  +
  +/* This function handles some invented "lookup types" that synthesize feature 
  +not available in the basic types. The special types all have negative values. 
  +Positive type values are passed straight on to dns_lookup().
  +
  +Arguments:
  +  dnsa                  pointer to dns_answer structure
  +  name                  domain name to look up
  +  type                  DNS record type (T_A, T_MX, etc or a "special")
  +  fully_qualified_name  if not NULL, return the returned name here if its
  +                          contents are different (i.e. it must be preset)
  +
  +Returns:                DNS_SUCCEED   successful lookup
  +                        DNS_NOMATCH   name not found
  +                        DNS_NODATA    no data found
  +                        DNS_AGAIN     soft failure, try again later
  +                        DNS_FAIL      DNS failure
  +*/
  +
  +int
  +dns_special_lookup(dns_answer *dnsa, uschar *name, int type, 
  +  uschar **fully_qualified_name)
  +{
  +if (type >= 0) return dns_lookup(dnsa, name, type, fully_qualified_name);
  +
  +/* Find nameservers for the domain or the nearest enclosing zone, excluding the 
  +root servers. */
  +
  +if (type == T_ZNS)
  +  {
  +  uschar *d = name;
  +  while (d != 0)
  +    {
  +    int rc = dns_lookup(dnsa, d, T_NS, fully_qualified_name);
  +    if (rc != DNS_NOMATCH && rc != DNS_NODATA) return rc;
  +    while (*d != 0 && *d != '.') d++;
  +    if (*d++ == 0) break; 
  +    }
  +  return DNS_NOMATCH;     
  +  } 
  +
  +/* Control should never reach here */
  +
   return DNS_FAIL;
   }



  Index: exim.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/exim.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- exim.h    7 Oct 2004 10:39:01 -0000    1.1
  +++ exim.h    19 Nov 2004 09:45:54 -0000    1.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/exim.h,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/exim.h,v 1.2 2004/11/19 09:45:54 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -277,6 +277,11 @@
   #ifndef T_SRV
   #define T_SRV 33
   #endif
  +
  +/* We use the private type T_ZNS for retrieving the nameservers for the
  +enclosing zone of a domain. */
  +
  +#define T_ZNS (-1)


/* The resolv.h header defines __P(x) on some Solaris 2.5.1 systems (without
checking that it is already defined, in fact). This conflicts with other

  Index: functions.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/functions.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- functions.h    18 Nov 2004 11:17:33 -0000    1.4
  +++ functions.h    19 Nov 2004 09:45:54 -0000    1.5
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/functions.h,v 1.4 2004/11/18 11:17:33 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/functions.h,v 1.5 2004/11/19 09:45:54 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -74,6 +74,7 @@
   extern void    dns_init(BOOL, BOOL);
   extern int     dns_basic_lookup(dns_answer *, uschar *, int);
   extern int     dns_lookup(dns_answer *, uschar *, int, uschar **);
  +extern int     dns_special_lookup(dns_answer *, uschar *, int, uschar **);
   extern dns_record *dns_next_rr(dns_answer *, dns_scan *, int);
   extern uschar *dns_text_type(int);



  Index: dnsdb.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/lookups/dnsdb.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- dnsdb.c    7 Oct 2004 13:10:01 -0000    1.1
  +++ dnsdb.c    19 Nov 2004 09:45:54 -0000    1.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/lookups/dnsdb.c,v 1.1 2004/10/07 13:10:01 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/lookups/dnsdb.c,v 1.2 2004/11/19 09:45:54 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -35,7 +35,9 @@
     "ns",
     "ptr",
     "srv",
  -  "txt" };
  +  "txt",
  +  "zns" 
  +};


   static int type_values[] = {
     T_A,
  @@ -50,7 +52,9 @@
     T_NS,
     T_PTR,
     T_SRV,
  -  T_TXT };
  +  T_TXT,
  +  T_ZNS      /* Private type for "zone nameservers" */
  +};



/*************************************************
@@ -139,11 +143,15 @@
in this run. Then do the lookup and sort out the result. */

dns_init(FALSE, FALSE);
-rc = dns_lookup(&dnsa, keystring, type, NULL);
+rc = dns_special_lookup(&dnsa, keystring, type, NULL);

if (rc == DNS_NOMATCH || rc == DNS_NODATA) return FAIL;
if (rc != DNS_SUCCEED) return DEFER;

  +/* If the lookup was a pseudo-type, change it to the correct type for searching 
  +the returned records; then search for them. */
  +
  +if (type == T_ZNS) type = T_NS;
   for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
        rr != NULL;
        rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT))


  Index: 082
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/scripts/082,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- 082    17 Nov 2004 16:12:26 -0000    1.4
  +++ 082    19 Nov 2004 09:45:54 -0000    1.5
  @@ -436,6 +436,7 @@
   a=localhost.test.ex        ${lookup dnsdb{a=localhost.test.ex}{$value}fail}
   cname=alias-xoanon.test.ex ${lookup dnsdb{cname=alias-xoanon.test.ex}{$value}fail}
   ns=test.ex                 ${lookup dnsdb{ns=test.ex}{$value}fail}
  +zns=x.y.z.test.ex          ${lookup dnsdb{zns=x.y.z.test.ex}{$value}fail}
   mx=mxt1.test.ex            ${lookup dnsdb{mx=mxt1.test.ex}{$value}fail}
   ptr=131.111.10.206         ${lookup dnsdb{ptr=131.111.10.206}{$value}fail}
   a6=xoanon.ipv6.test.ex     ${lookup dnsdb {a6=xoanon.ipv6.test.ex}{$value}{fail}}


  Index: 082
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/stdout/082,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- 082    17 Nov 2004 16:12:26 -0000    1.4
  +++ 082    19 Nov 2004 09:45:54 -0000    1.5
  @@ -432,6 +432,7 @@
   > a=localhost.test.ex        127.0.0.1
   > cname=alias-xoanon.test.ex xoanon.test.ex
   > ns=test.ex                 xoanon.csi.cam.ac.uk
  +> zns=x.y.z.test.ex          xoanon.csi.cam.ac.uk
   > mx=mxt1.test.ex            5 xoanon.csi.cam.ac.uk
   > ptr=131.111.10.206         xoanon.csi.cam.ac.uk
   > Failed: lookup of "a6=xoanon.ipv6.test.ex" gave DEFER: unsupported DNS record type


  Index: 353
  ===================================================================
  RCS file: /home/cvs/exim/exim-test-orig/AutoTest/stdout/353,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- 353    8 Oct 2004 14:50:13 -0000    1.1
  +++ 353    19 Nov 2004 09:45:54 -0000    1.2
  @@ -26,12 +26,12 @@
   250 myhost.test.ex Hello rhubarb.custard [10.0.0.1]
   221 myhost.test.ex closing connection


-**** SMTP testing session as if from host 2002:c1ed:8229:10:202:2dff:fe07:a42a
+**** SMTP testing session as if from host 2002:c1ed:8229:0010:0202:2dff:fe07:a42a
**** but without any ident (RFC 1413) callback.
**** This is not for real!

220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
-250-myhost.test.ex Hello [IPV6:2002:c1ed:8229:10:202:2dff:fe07:a42a] [2002:c1ed:8229:10:202:2dff:fe07:a42a]
+250-myhost.test.ex Hello [IPV6:2002:c1ed:8229:10:202:2dff:fe07:a42a] [2002:c1ed:8229:0010:0202:2dff:fe07:a42a]
250-SIZE 52428800
250-PIPELINING
250 HELP