diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2015-05-09 19:21:15 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2015-05-09 22:27:51 +0100 |
commit | d2a2c69b7b97d080d63dfb434584d98eb3228332 (patch) | |
tree | 8971ce7578fdce33f6a55eabb4dff4b594b1719b /test | |
parent | fd7f7910649e935c3bf5d48fe2742320dedfd82d (diff) |
Support SOA lookup in dnsdb lookups. Bug 286
Diffstat (limited to 'test')
-rw-r--r-- | test/dnszones-src/db.test.ex | 3 | ||||
-rw-r--r-- | test/scripts/2200-dnsdb/2200 | 3 | ||||
-rw-r--r-- | test/src/fakens.c | 143 | ||||
-rw-r--r-- | test/stdout/2200 | 3 |
4 files changed, 93 insertions, 59 deletions
diff --git a/test/dnszones-src/db.test.ex b/test/dnszones-src/db.test.ex index 1339981c8..c9b004c76 100644 --- a/test/dnszones-src/db.test.ex +++ b/test/dnszones-src/db.test.ex @@ -1,5 +1,5 @@ ; This is a testing zone file for use when testing DNS handling in Exim. This -; is a fake zone of no real use - hence no SOA record. The zone name is +; is a fake zone of no real use. The zone name is ; test.ex. This file is passed through the substitution mechanism before being ; used by the fakens auxiliary program. This inserts the actual IP addresses ; of the local host into the zone. @@ -17,6 +17,7 @@ ; host ever uses them. test.ex. NS exim.test.ex. +test.ex. SOA exim.test.ex. hostmaster.exim.test.ex 1430683638 1200 120 604800 3600 test.ex. TXT "A TXT record for test.ex." s/lash TXT "A TXT record for s/lash.test.ex." diff --git a/test/scripts/2200-dnsdb/2200 b/test/scripts/2200-dnsdb/2200 index 837c85a1c..40837dbd0 100644 --- a/test/scripts/2200-dnsdb/2200 +++ b/test/scripts/2200-dnsdb/2200 @@ -21,6 +21,9 @@ srv=_smtp._tcp.nosmtp.test.ex ${lookup dnsdb{srv=_smtp._tcp.nosmtp.test.ex}{$ csa=csa1.test.ex ${lookup dnsdb{csa=csa1.test.ex}} csa=csa2.test.ex ${lookup dnsdb{csa=csa2.test.ex}} +soa=test.ex ${lookup dnsdb{soa=test.ex}{$value}{fail}} +soa=a.test.ex ${lookup dnsdb{>:, soa=test.ex}{$value}{fail}} + # DNS lookups with multiple items ten-1:ten2 ${lookup dnsdb{a=ten-1.test.ex:ten-2.test.ex}} diff --git a/test/src/fakens.c b/test/src/fakens.c index 31b6471fa..fc7848e77 100644 --- a/test/src/fakens.c +++ b/test/src/fakens.c @@ -130,7 +130,7 @@ static tlist type_list[] = { { US"A", ns_t_a }, { US"NS", ns_t_ns }, { US"CNAME", ns_t_cname }, -/* { US"SOA", ns_t_soa }, Not currently in use */ + { US"SOA", ns_t_soa }, { US"PTR", ns_t_ptr }, { US"MX", ns_t_mx }, { US"TXT", ns_t_txt }, @@ -227,6 +227,22 @@ while (isspace(*p)) p++; return pk; } +uschar * +longfield(uschar ** pp, uschar * pk) +{ +unsigned long value = 0; +uschar * p = *pp; + +while (isdigit(*p)) value = value*10 + *p++ - '0'; +while (isspace(*p)) p++; +*pp = p; +*pk++ = (value >> 24) & 255; +*pk++ = (value >> 16) & 255; +*pk++ = (value >> 8) & 255; +*pk++ = value & 255; +return pk; +} + /*************************************************/ @@ -316,7 +332,7 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL) uschar *rdlptr; uschar *p, *ep, *pp; BOOL found_cname = FALSE; - int i, plen, value; + int i, value; int tvalue = typeptr->value; int qtlen = qtypelen; BOOL rr_sec = FALSE; @@ -436,60 +452,72 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL) switch (tvalue) { - case ns_t_soa: /* Not currently used */ - break; + case ns_t_soa: + p = strtok(p, " "); + ep = p + strlen(p); + if (ep[-1] != '.') sprintf(CS ep, "%s.", zone); + pk = packname(p, pk); /* primary ns */ + p = strtok(NULL, " "); + pk = packname(p , pk); /* responsible mailbox */ + *(p += strlen(p)) = ' '; + while (isspace(*p)) p++; + pk = longfield(&p, pk); /* serial */ + pk = longfield(&p, pk); /* refresh */ + pk = longfield(&p, pk); /* retry */ + pk = longfield(&p, pk); /* expire */ + pk = longfield(&p, pk); /* minimum */ + break; case ns_t_a: - for (i = 0; i < 4; i++) - { - value = 0; - while (isdigit(*p)) value = value*10 + *p++ - '0'; - *pk++ = value; - p++; - } - break; + for (i = 0; i < 4; i++) + { + value = 0; + while (isdigit(*p)) value = value*10 + *p++ - '0'; + *pk++ = value; + p++; + } + break; /* The only occurrence of a double colon is for ::1 */ case ns_t_aaaa: - if (Ustrcmp(p, "::1") == 0) - { - memset(pk, 0, 15); - pk += 15; - *pk++ = 1; - } - else for (i = 0; i < 8; i++) - { - value = 0; - while (isxdigit(*p)) - { - value = value * 16 + toupper(*p) - (isdigit(*p)? '0' : '7'); - p++; - } - *pk++ = (value >> 8) & 255; - *pk++ = value & 255; - p++; - } - break; + if (Ustrcmp(p, "::1") == 0) + { + memset(pk, 0, 15); + pk += 15; + *pk++ = 1; + } + else for (i = 0; i < 8; i++) + { + value = 0; + while (isxdigit(*p)) + { + value = value * 16 + toupper(*p) - (isdigit(*p)? '0' : '7'); + p++; + } + *pk++ = (value >> 8) & 255; + *pk++ = value & 255; + p++; + } + break; case ns_t_mx: - pk = shortfield(&p, pk); - if (ep[-1] != '.') sprintf(CS ep, "%s.", zone); - pk = packname(p, pk); - plen = Ustrlen(p); - break; + pk = shortfield(&p, pk); + if (ep[-1] != '.') sprintf(CS ep, "%s.", zone); + pk = packname(p, pk); + break; case ns_t_txt: - pp = pk++; - if (*p == '"') p++; /* Should always be the case */ - while (*p != 0 && *p != '"') *pk++ = *p++; - *pp = pk - pp - 1; - break; + pp = pk++; + if (*p == '"') p++; /* Should always be the case */ + while (*p != 0 && *p != '"') *pk++ = *p++; + *pp = pk - pp - 1; + break; case ns_t_tlsa: - pk = bytefield(&p, pk); /* usage */ - pk = bytefield(&p, pk); /* selector */ - pk = bytefield(&p, pk); /* match type */ - while (isxdigit(*p)) + pk = bytefield(&p, pk); /* usage */ + pk = bytefield(&p, pk); /* selector */ + pk = bytefield(&p, pk); /* match type */ + while (isxdigit(*p)) { value = toupper(*p) - (isdigit(*p) ? '0' : '7') << 4; if (isxdigit(*++p)) @@ -500,27 +528,26 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL) *pk++ = value & 255; } - break; + break; case ns_t_srv: - for (i = 0; i < 3; i++) - { - value = 0; - while (isdigit(*p)) value = value*10 + *p++ - '0'; - while (isspace(*p)) p++; - *pk++ = (value >> 8) & 255; - *pk++ = value & 255; - } + for (i = 0; i < 3; i++) + { + value = 0; + while (isdigit(*p)) value = value*10 + *p++ - '0'; + while (isspace(*p)) p++; + *pk++ = (value >> 8) & 255; + *pk++ = value & 255; + } /* Fall through */ case ns_t_cname: case ns_t_ns: case ns_t_ptr: - if (ep[-1] != '.') sprintf(CS ep, "%s.", zone); - pk = packname(p, pk); - plen = Ustrlen(p); - break; + if (ep[-1] != '.') sprintf(CS ep, "%s.", zone); + pk = packname(p, pk); + break; } /* Fill in the length, and we are done with this RR */ diff --git a/test/stdout/2200 b/test/stdout/2200 index 3d7d0db88..b77594803 100644 --- a/test/stdout/2200 +++ b/test/stdout/2200 @@ -19,6 +19,9 @@ > csa=csa1.test.ex Y csa1.test.ex > csa=csa2.test.ex N csa2.test.ex > +> soa=test.ex exim.test.ex +> soa=a.test.ex exim.test.ex hostmaster.exim.test.ex 1430683638 1200 120 604800 3600 +> > # DNS lookups with multiple items > > ten-1:ten2 V4NET.0.0.1 |