diff options
Diffstat (limited to 'src/domain.c')
-rw-r--r-- | src/domain.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/domain.c b/src/domain.c index 2031726..13e4afa 100644 --- a/src/domain.c +++ b/src/domain.c @@ -481,6 +481,52 @@ bestmx_map_lookup(map, name, av, statp) return map_rewrite(map, mxhosts[0], strlen(mxhosts[0]), av); } /* +** ISMX -- find if we are the MX for a certain host. +** +** This is really a hack, but I don't see any obvious way +** to generalize it at the moment. +*/ + +char * +ismx_map_lookup(map, name, av, statp) + MAP *map; + char *name; + char **av; + int *statp; +{ + int nmx, i, len; + auto int rcode; + int saveopts = _res.options; + char *mxhosts[MAXMXHOSTS + 1]; + char *mymx = NULL; + + _res.options &= ~(RES_DNSRCH|RES_DEFNAMES); + nmx = getmxrr(name, mxhosts, FALSE, &rcode); + _res.options = saveopts; + if (rcode != EX_TEMPFAIL) { + if (nmx <= 0) + return NULL; + for(i = 0; i < nmx; i++) { + len = strlen(mxhosts[i]); + if (len && mxhosts[i][len - 1] == '.') + mxhosts[i][len - 1] = 0; + if (wordinclass(mxhosts[i], 'w')) { + mymx = mxhosts[i]; + break; + } + } + if (mymx == NULL) + return NULL; + } else + mymx = "TEMPFAIL"; + + if (bitset(MF_MATCHONLY, map->map_mflags)) + return map_rewrite(map, name, strlen(name), NULL); + else + return map_rewrite(map, mymx, strlen(mymx), av); +} + +/* ** DNS_GETCANONNAME -- get the canonical name for named host using DNS ** ** This algorithm tries to be smart about wildcard MX records. |