X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=checkalias.c;h=2e50ea09222d3cd61b469b953839e41a6665c027;hb=f3efb867a6c3b539e8ab946584f3ed00e5f31a43;hp=687b5478571c44859619be87ac1f78d69e802b93;hpb=4680b0f8c728a69a24e7089b777f03899bab6c9f;p=~andy%2Ffetchmail diff --git a/checkalias.c b/checkalias.c index 687b5478..2e50ea09 100644 --- a/checkalias.c +++ b/checkalias.c @@ -28,15 +28,16 @@ typedef unsigned char address_t[sizeof (struct in_addr)]; +#ifdef HAVE_RES_SEARCH static int getaddresses(struct addrinfo **result, const char *name) { - struct addrinfo hints, *res; + struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_socktype=SOCK_STREAM; hints.ai_protocol=PF_UNSPEC; hints.ai_family=AF_UNSPEC; - return getaddrinfo(name, NULL, &hints, result); + return fm_getaddrinfo(name, NULL, &hints, result); } /* XXX FIXME: doesn't detect if an IPv6-mapped IPv4 address @@ -57,8 +58,6 @@ static int is_ip_alias(const char *name1,const char *name2) */ { int rc = FALSE; - struct hostent *hp; - char **p; struct addrinfo *res1 = NULL, *res2 = NULL, *ii, *ij; @@ -79,19 +78,23 @@ static int is_ip_alias(const char *name1,const char *name2) found: if (res2) - freeaddrinfo(res2); + fm_freeaddrinfo(res2); if (res1) - freeaddrinfo(res1); + fm_freeaddrinfo(res1); return rc; } +#endif -int is_host_alias(const char *name, struct query *ctl) +int is_host_alias(const char *name, struct query *ctl, struct addrinfo **res) /* determine whether name is a DNS alias of the mailserver for this query */ { +#ifdef HAVE_RES_SEARCH struct mxentry *mxp, *mxrecords; + int e; + struct addrinfo hints, *res_st; +#endif struct idlist *idl; - int namelen, e; - struct addrinfo hints, *res, *res_st; + size_t namelen; struct hostdata *lead_server = ctl->server.lead_server ? ctl->server.lead_server : &ctl->server; @@ -126,7 +129,7 @@ int is_host_alias(const char *name, struct query *ctl) namelen = strlen(name); for (idl = lead_server->akalist; idl; idl = idl->next) { - char *ep; + const char *ep; /* * Test is >= here because str_in_list() should have caught the @@ -135,7 +138,7 @@ int is_host_alias(const char *name, struct query *ctl) */ if (strlen(idl->id) >= namelen) continue; - ep = (char *)name + (namelen - strlen(idl->id)); + ep = name + (namelen - strlen(idl->id)); /* a suffix led by . must match */ if (ep[-1] == '.' && !strcasecmp(ep, idl->id)) return(TRUE); @@ -144,6 +147,7 @@ int is_host_alias(const char *name, struct query *ctl) if (!ctl->server.dns) return(FALSE); #ifndef HAVE_RES_SEARCH + (void)res; return(FALSE); #else /* @@ -159,17 +163,18 @@ int is_host_alias(const char *name, struct query *ctl) hints.ai_family=AF_UNSPEC; hints.ai_protocol=PF_UNSPEC; hints.ai_socktype=SOCK_STREAM; + hints.ai_flags=AI_CANONNAME; - e = getaddrinfo(name, NULL, &hints, &res); + e = fm_getaddrinfo(name, NULL, &hints, res); if (e == 0) { - int rr = (strcasecmp(ctl->server.truename, res->ai_canonname) == 0); - freeaddrinfo(res); + int rr = (strcasecmp(ctl->server.truename, (*res)->ai_canonname) == 0); + fm_freeaddrinfo(*res); *res = NULL; if (rr) goto match; - else if (ctl->server.checkalias && 0 == getaddrinfo(ctl->server.truename, NULL, &hints, &res_st)) + else if (ctl->server.checkalias && 0 == fm_getaddrinfo(ctl->server.truename, NULL, &hints, &res_st)) { - freeaddrinfo(res_st); + fm_freeaddrinfo(res_st); if (outlevel >= O_DEBUG) report(stdout, GT_("Checking if %s is really the same node as %s\n"),ctl->server.truename,name); if (is_ip_alias(ctl->server.truename,name) == TRUE)