Date: Mon, 5 Apr 2004 19:34:24 +0200 From: Pierre Beyssac <pb@FreeBSD.org> To: audit@FreeBSD.org Cc: green@FreeBSD.org Subject: fix for getipnodebyname(3) Message-ID: <20040405173424.GA2440@bofh.enst.fr> In-Reply-To: <20040217161920.GB712@straylight.m.ringlet.net> References: <20040217161920.GB712@straylight.m.ringlet.net>
next in thread | previous in thread | raw e-mail | index | archive | help
getipnodebyname(3) as it stands in FreeBSD 4 and 5 has a problem with nameserver timeouts or misconfiguration. Symptom: getipnodebyname(3) lookups in unreachable/unconfigured zones return h_errno=HOST_NOT_FOUND instead of h_errno=TRY_AGAIN. It causes email to bounce at least with sendmail, which is quite annoying. Unless someone objects to it, I'd like to commit the following fix to current later today. Since FreeBSD 4 is impacted too, the patch will have to be adapted and MFC'd some day. The only potential problem I see with my patch is that it accesses h_errno, which is possibly not thread-safe. Could someone please shed some light on this for me? Pierre --- name6.c.old Wed Feb 25 23:27:17 2004 +++ name6.c Mon Apr 5 14:19:31 2004 @@ -1565,7 +1565,8 @@ continue; hp = _hpcopy(&hpbuf, errp); hp0 = _hpmerge(hp0, hp, errp); - } + } else + *errp = h_errno; } if (hp0 != NULL) { free(buf); @@ -1604,7 +1605,8 @@ continue; hp = _hpcopy(&hpbuf, errp); hp0 = _hpmerge(hp0, hp, errp); - } + } else + *errp = h_errno; } if (hp0 != NULL) { free(buf); @@ -1677,7 +1679,8 @@ continue; hp = _hpcopy(&hpbuf, errp); hp0 = _hpmerge(hp0, hp, errp); - } + } else + *errp = h_errno; } if (hp0 != NULL) { free(buf); @@ -1739,7 +1742,12 @@ rtl = &rtl4; #endif *(struct hostent **)rval = _res_search_multi(name, rtl, errp); - return (*(struct hostent **)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND; + if (*(struct hostent **)rval != NULL) + return NS_SUCCESS; + else if (*errp == TRY_AGAIN) + return NS_TRYAGAIN; + else + return NS_NOTFOUND; } static int -- Pierre Beyssac pb@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040405173424.GA2440>