diff options
Diffstat (limited to 'lib/libc/resolv')
-rw-r--r-- | lib/libc/resolv/Makefile.inc | 10 | ||||
-rw-r--r-- | lib/libc/resolv/Symbol.map | 107 | ||||
-rw-r--r-- | lib/libc/resolv/h_errno.c | 46 | ||||
-rw-r--r-- | lib/libc/resolv/herror.c | 31 | ||||
-rw-r--r-- | lib/libc/resolv/mtctxres.c | 14 | ||||
-rw-r--r-- | lib/libc/resolv/res_comp.c | 53 | ||||
-rw-r--r-- | lib/libc/resolv/res_data.c | 87 | ||||
-rw-r--r-- | lib/libc/resolv/res_debug.c | 139 | ||||
-rw-r--r-- | lib/libc/resolv/res_findzonecut.c | 50 | ||||
-rw-r--r-- | lib/libc/resolv/res_init.c | 125 | ||||
-rw-r--r-- | lib/libc/resolv/res_mkquery.c | 63 | ||||
-rw-r--r-- | lib/libc/resolv/res_mkupdate.c | 112 | ||||
-rw-r--r-- | lib/libc/resolv/res_query.c | 97 | ||||
-rw-r--r-- | lib/libc/resolv/res_send.c | 194 | ||||
-rw-r--r-- | lib/libc/resolv/res_state.c | 87 | ||||
-rw-r--r-- | lib/libc/resolv/res_update.c | 22 |
16 files changed, 882 insertions, 355 deletions
diff --git a/lib/libc/resolv/Makefile.inc b/lib/libc/resolv/Makefile.inc new file mode 100644 index 0000000..cd023cf --- /dev/null +++ b/lib/libc/resolv/Makefile.inc @@ -0,0 +1,10 @@ +# $FreeBSD$ + +# resolv sources +.PATH: ${.CURDIR}/resolv + +SRCS+= herror.c h_errno.c mtctxres.c res_comp.c res_data.c res_debug.c \ + res_findzonecut.c res_init.c res_mkquery.c res_mkupdate.c \ + res_query.c res_send.c res_state.c res_update.c + +SYM_MAPS+= ${.CURDIR}/resolv/Symbol.map diff --git a/lib/libc/resolv/Symbol.map b/lib/libc/resolv/Symbol.map new file mode 100644 index 0000000..211f2c4 --- /dev/null +++ b/lib/libc/resolv/Symbol.map @@ -0,0 +1,107 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.0 { + /* h_nerr; */ /* Why is this not staticized in net/herror.c? */ + h_errlist; + herror; + hstrerror; + __dn_expand; + __dn_comp; + __dn_skipname; + __res_hnok; + __res_ownok; + __res_mailok; + __res_dnok; + __putlong; + __putshort; + _getlong; + _getshort; + dn_comp; + dn_expand; + __fp_resstat; + __p_query; + __fp_query; + __fp_nquery; + __p_cdnname; + __p_cdname; + __p_fqnname; + __p_fqname; + __p_cert_syms; + __p_class_syms; + __p_key_syms; + __p_rcode_syms; + __p_type_syms; + __sym_ston; + __sym_ntos; + __sym_ntop; + __p_rcode; + __p_sockun; + __p_type; + __p_section; + __p_class; + __p_option; + __p_time; + __loc_aton; + __loc_ntoa; + __dn_count_labels; + __p_secstodate; + fp_resstat; + p_query; + p_fqnname; + sym_ston; + sym_ntos; + sym_ntop; + dn_count_labels; + p_secstodate; + __res_init; + __res_randomid; + __h_errno; + __h_errno_set; + h_errno; + res_init; + __res_findzonecut2; + __res_freeupdrec; + __res_mkquery; + res_mkquery; + __res_mkupdrec; + __res_mkupdate; + __res_opt; + __res_getservers; + __res_hostalias; + __res_nametoclass; + __res_nametotype; + __res_nclose; + __res_ndestroy; + __res_ninit; + __res_nmkquery; + __res_nmkupdate; + __res_nopt; + __res_nquery; + __res_nquerydomain; + __res_nsearch; + __res_nsend; + __res_nupdate; + __res_ourserver_p; + __res_pquery; + __res_query; + __res_search; + __res_querydomain; + __res_setservers; + _res; + __res_state; + __res_vinit; + __hostalias; + res_query; + res_search; + res_querydomain; + __res_isourserver; + __res_nameinquery; + __res_queriesmatch; + __res_send; + __res_close; + _res_close; + res_send; + __res_update; +}; diff --git a/lib/libc/resolv/h_errno.c b/lib/libc/resolv/h_errno.c new file mode 100644 index 0000000..88d15ae --- /dev/null +++ b/lib/libc/resolv/h_errno.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2006 The FreeBSD Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/nameser.h> +#include <resolv.h> + +#undef h_errno +extern int h_errno; + +int * +__h_errno(void) +{ + return (&__res_state()->res_h_errno); +} + +void +__h_errno_set(res_state res, int err) +{ + h_errno = res->res_h_errno = err; +} diff --git a/lib/libc/resolv/herror.c b/lib/libc/resolv/herror.c index 9232426..c09969d 100644 --- a/lib/libc/resolv/herror.c +++ b/lib/libc/resolv/herror.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -50,11 +46,14 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: herror.c,v 1.3.18.1 2005/04/27 05:01:09 sra Exp $"; +static const char rcsid[] = "$Id: herror.c,v 1.2.206.1 2004/03/09 08:33:54 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" +#include "namespace.h" #include <sys/types.h> #include <sys/param.h> #include <sys/uio.h> @@ -66,25 +65,23 @@ static const char rcsid[] = "$Id: herror.c,v 1.3.18.1 2005/04/27 05:01:09 sra Ex #include <resolv.h> #include <string.h> #include <unistd.h> -#include <irs.h> +#include "un-namespace.h" #include "port_after.h" const char *h_errlist[] = { "Resolver Error 0 (no error)", - "Unknown host", /*%< 1 HOST_NOT_FOUND */ - "Host name lookup failure", /*%< 2 TRY_AGAIN */ - "Unknown server error", /*%< 3 NO_RECOVERY */ - "No address associated with name", /*%< 4 NO_ADDRESS */ + "Unknown host", /* 1 HOST_NOT_FOUND */ + "Host name lookup failure", /* 2 TRY_AGAIN */ + "Unknown server error", /* 3 NO_RECOVERY */ + "No address associated with name", /* 4 NO_ADDRESS */ }; -int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] }; +const int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] }; -#if !(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) #undef h_errno int h_errno; -#endif -/*% +/* * herror -- * print the error indicated by the h_errno value. */ @@ -110,10 +107,10 @@ herror(const char *s) { DE_CONST("\n", t); v->iov_base = t; v->iov_len = 1; - writev(STDERR_FILENO, iov, (v - iov) + 1); + _writev(STDERR_FILENO, iov, (v - iov) + 1); } -/*% +/* * hstrerror -- * return the string associated with a given "host" errno value. */ @@ -125,5 +122,3 @@ hstrerror(int err) { return (h_errlist[err]); return ("Unknown resolver error"); } - -/*! \file */ diff --git a/lib/libc/resolv/mtctxres.c b/lib/libc/resolv/mtctxres.c index 635bbd4..f02a7f5 100644 --- a/lib/libc/resolv/mtctxres.c +++ b/lib/libc/resolv/mtctxres.c @@ -1,13 +1,18 @@ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <port_before.h> #ifdef DO_PTHREADS #include <pthread.h> +#ifdef _LIBC +#include <pthread_np.h> +#endif #endif #include <errno.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <resolv_mt.h> -#include <irs.h> #include <port_after.h> #ifdef DO_PTHREADS @@ -40,6 +45,7 @@ _mtctxres_init(void) { } #endif +#ifndef _LIBC /* * To support binaries that used the private MT-safe interface in * Solaris 8, we still need to provide the __res_enable_mt() @@ -54,6 +60,7 @@ int __res_disable_mt(void) { return (0); } +#endif #ifdef DO_PTHREADS static int @@ -99,6 +106,11 @@ ___mtctxres(void) { #ifdef DO_PTHREADS mtctxres_t *mt; +#ifdef _LIBC + if (pthread_main_np() != 0) + return (&sharedctx); +#endif + /* * This if clause should only be executed if we are linking * statically. When linked dynamically _mtctxres_init() should diff --git a/lib/libc/resolv/res_comp.c b/lib/libc/resolv/res_comp.c index 4dc3c2a..076e303 100644 --- a/lib/libc/resolv/res_comp.c +++ b/lib/libc/resolv/res_comp.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -70,8 +66,10 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_comp.c,v 1.3.18.2 2005/07/28 07:38:11 marka Exp $"; +static const char rcsid[] = "$Id: res_comp.c,v 1.1.2.1.4.2 2005/07/28 07:43:22 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" #include <sys/types.h> @@ -85,13 +83,12 @@ static const char rcsid[] = "$Id: res_comp.c,v 1.3.18.2 2005/07/28 07:38:11 mark #include <unistd.h> #include "port_after.h" -/*% +/* * Expand compressed domain name 'src' to full domain name. - * - * \li 'msg' is a pointer to the begining of the message, - * \li 'eom' points to the first location after the message, - * \li 'dst' is a pointer to a buffer of size 'dstsiz' for the result. - * \li Return size of compressed name or -1 if there was an error. + * 'msg' is a pointer to the begining of the message, + * 'eom' points to the first location after the message, + * 'dst' is a pointer to a buffer of size 'dstsiz' for the result. + * Return size of compressed name or -1 if there was an error. */ int dn_expand(const u_char *msg, const u_char *eom, const u_char *src, @@ -104,11 +101,10 @@ dn_expand(const u_char *msg, const u_char *eom, const u_char *src, return (n); } -/*% +/* * Pack domain name 'exp_dn' in presentation form into 'comp_dn'. - * - * \li Return the size of the compressed name or -1. - * \li 'length' is the size of the array pointed to by 'comp_dn'. + * Return the size of the compressed name or -1. + * 'length' is the size of the array pointed to by 'comp_dn'. */ int dn_comp(const char *src, u_char *dst, int dstsiz, @@ -119,7 +115,7 @@ dn_comp(const char *src, u_char *dst, int dstsiz, (const u_char **)lastdnptr)); } -/*% +/* * Skip over a compressed domain name. Return the size or -1. */ int @@ -131,9 +127,11 @@ dn_skipname(const u_char *ptr, const u_char *eom) { return (ptr - saveptr); } -/*% +/* * Verify that a domain name uses an acceptable character set. - * + */ + +/* * Note the conspicuous absence of ctype macros in these definitions. On * non-ASCII hosts, we can't depend on string literals or ctype macros to * tell us anything about network-format data. The rest of the BIND system @@ -176,7 +174,7 @@ res_hnok(const char *dn) { return (1); } -/*% +/* * hostname-like (A, MX, WKS) owners can have "*" as their first label * but must otherwise be as a host name. */ @@ -191,7 +189,7 @@ res_ownok(const char *dn) { return (res_hnok(dn)); } -/*% +/* * SOA RNAMEs and RP RNAMEs can have any printable character in their first * label, but the rest of the name has to look like a host name. */ @@ -219,8 +217,8 @@ res_mailok(const char *dn) { return (0); } -/*% - * This function is quite liberal, since RFC1034's character sets are only +/* + * This function is quite liberal, since RFC 1034's character sets are only * recommendations. */ int @@ -234,7 +232,7 @@ res_dnok(const char *dn) { } #ifdef BIND_4_COMPAT -/*% +/* * This module must export the following externally-visible symbols: * ___putlong * ___putshort @@ -262,4 +260,11 @@ u_int16_t _getshort(const u_char *src) { return (ns_get16(src)); } #endif /*__ultrix__*/ #endif /*BIND_4_COMPAT*/ -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <resolv.h>. + */ +#undef dn_comp +__weak_reference(__dn_comp, dn_comp); +#undef dn_expand +__weak_reference(__dn_expand, dn_expand); diff --git a/lib/libc/resolv/res_data.c b/lib/libc/resolv/res_data.c index e3dcbf0..ab6d575 100644 --- a/lib/libc/resolv/res_data.c +++ b/lib/libc/resolv/res_data.c @@ -16,8 +16,10 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: res_data.c,v 1.3.18.1 2005/04/27 05:01:10 sra Exp $"; +static const char rcsid[] = "$Id: res_data.c,v 1.1.206.2 2004/03/16 12:34:18 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -40,14 +42,13 @@ static const char rcsid[] = "$Id: res_data.c,v 1.3.18.1 2005/04/27 05:01:10 sra #include <unistd.h> #include "port_after.h" -#undef _res const char *_res_opcodes[] = { "QUERY", "IQUERY", "CQUERYM", - "CQUERYU", /*%< experimental */ - "NOTIFY", /*%< experimental */ + "CQUERYU", /* experimental */ + "NOTIFY", /* experimental */ "UPDATE", "6", "7", @@ -71,11 +72,6 @@ const char *_res_sectioncodes[] = { #endif #ifndef __BIND_NOSTATIC -struct __res_state _res -# if defined(__BIND_RES_TEXT) - = { RES_TIMEOUT, } /*%< Motorola, et al. */ -# endif - ; /* Proto. */ @@ -107,7 +103,7 @@ res_init(void) { if (!_res.retrans) _res.retrans = RES_TIMEOUT; if (!_res.retry) - _res.retry = 4; + _res.retry = RES_DFLRETRY; if (!(_res.options & RES_INIT)) _res.options = RES_DEFAULT; @@ -140,14 +136,14 @@ fp_nquery(const u_char *msg, int len, FILE *file) { } int -res_mkquery(int op, /*!< opcode of query */ - const char *dname, /*!< domain name */ - int class, int type, /*!< class and type of query */ - const u_char *data, /*!< resource record data */ - int datalen, /*!< length of data */ - const u_char *newrr_in, /*!< new rr for modify or append */ - u_char *buf, /*!< buffer to put query */ - int buflen) /*!< size of buffer */ +res_mkquery(int op, /* opcode of query */ + const char *dname, /* domain name */ + int class, int type, /* class and type of query */ + const u_char *data, /* resource record data */ + int datalen, /* length of data */ + const u_char *newrr_in, /* new rr for modify or append */ + u_char *buf, /* buffer to put query */ + int buflen) /* size of buffer */ { if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); @@ -169,10 +165,10 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { } int -res_query(const char *name, /*!< domain name */ - int class, int type, /*!< class and type of query */ - u_char *answer, /*!< buffer to put answer */ - int anslen) /*!< size of answer buffer */ +res_query(const char *name, /* domain name */ + int class, int type, /* class and type of query */ + u_char *answer, /* buffer to put answer */ + int anslen) /* size of answer buffer */ { if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); @@ -181,6 +177,7 @@ res_query(const char *name, /*!< domain name */ return (res_nquery(&_res, name, class, type, answer, anslen)); } +#ifndef _LIBC void res_send_setqhook(res_send_qhook hook) { _res.qhook = hook; @@ -190,6 +187,7 @@ void res_send_setrhook(res_send_rhook hook) { _res.rhook = hook; } +#endif int res_isourserver(const struct sockaddr_in *inp) { @@ -206,6 +204,7 @@ res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) { return (res_nsend(&_res, buf, buflen, ans, anssiz)); } +#ifndef _LIBC int res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key, u_char *ans, int anssiz) @@ -217,6 +216,7 @@ res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key, return (res_nsendsigned(&_res, buf, buflen, key, ans, anssiz)); } +#endif void res_close(void) { @@ -234,10 +234,10 @@ res_update(ns_updrec *rrecp_in) { } int -res_search(const char *name, /*!< domain name */ - int class, int type, /*!< class and type of query */ - u_char *answer, /*!< buffer to put answer */ - int anslen) /*!< size of answer */ +res_search(const char *name, /* domain name */ + int class, int type, /* class and type of query */ + u_char *answer, /* buffer to put answer */ + int anslen) /* size of answer */ { if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); @@ -250,9 +250,9 @@ res_search(const char *name, /*!< domain name */ int res_querydomain(const char *name, const char *domain, - int class, int type, /*!< class and type of query */ - u_char *answer, /*!< buffer to put answer */ - int anslen) /*!< size of answer */ + int class, int type, /* class and type of query */ + u_char *answer, /* buffer to put answer */ + int anslen) /* size of answer */ { if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); @@ -264,6 +264,12 @@ res_querydomain(const char *name, answer, anslen)); } +int +res_opt(int n0, u_char *buf, int buflen, int anslen) +{ + return (res_nopt(&_res, n0, buf, buflen, anslen)); +} + const char * hostalias(const char *name) { static char abuf[MAXDNAME]; @@ -288,6 +294,25 @@ local_hostname_length(const char *hostname) { } #endif /*ultrix*/ -#endif +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <resolv.h>. + */ +#undef res_init +__weak_reference(__res_init, res_init); +#undef p_query +__weak_reference(__p_query, p_query); +#undef res_mkquery +__weak_reference(__res_mkquery, res_mkquery); +#undef res_query +__weak_reference(__res_query, res_query); +#undef res_send +__weak_reference(__res_send, res_send); +#undef res_close +__weak_reference(__res_close, _res_close); +#undef res_search +__weak_reference(__res_search, res_search); +#undef res_querydomain +__weak_reference(__res_querydomain, res_querydomain); -/*! \file */ +#endif diff --git a/lib/libc/resolv/res_debug.c b/lib/libc/resolv/res_debug.c index 2ed234e..80b5b94 100644 --- a/lib/libc/resolv/res_debug.c +++ b/lib/libc/resolv/res_debug.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -95,8 +91,10 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_debug.c,v 1.10.18.5 2005/07/28 07:38:11 marka Exp $"; +static const char rcsid[] = "$Id: res_debug.c,v 1.3.2.5.4.6 2005/07/28 07:43:22 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -130,7 +128,7 @@ static const char rcsid[] = "$Id: res_debug.c,v 1.10.18.5 2005/07/28 07:38:11 ma extern const char *_res_opcodes[]; extern const char *_res_sectioncodes[]; -/*% +/* * Print the current options. */ void @@ -223,7 +221,7 @@ do_section(const res_state statp, free(buf); } -/*% +/* * Print the contents of a query. * This is intended to be primarily a debugging routine. */ @@ -318,8 +316,7 @@ p_cdname(const u_char *cp, const u_char *msg, FILE *file) { return (p_cdnname(cp, msg, PACKETSZ, file)); } -/*% - * Return a fully-qualified domain name from a compressed name (with +/* Return a fully-qualified domain name from a compressed name (with length supplied). */ const u_char * @@ -335,7 +332,7 @@ p_fqnname(cp, msg, msglen, name, namelen) return (NULL); newlen = strlen(name); if (newlen == 0 || name[newlen - 1] != '.') { - if (newlen + 1 >= namelen) /*%< Lack space for final dot */ + if (newlen + 1 >= namelen) /* Lack space for final dot */ return (NULL); else strcpy(name + newlen, "."); @@ -357,7 +354,7 @@ p_fqname(const u_char *cp, const u_char *msg, FILE *file) { return (n); } -/*% +/* * Names of RR classes and qclasses. Classes and qclasses are the same, except * that C_ANY is a qclass but not a class. (You can ask for records of class * C_ANY, but you can't have any records of that class in the database.) @@ -373,10 +370,10 @@ const struct res_sym __p_class_syms[] = { {C_IN, (char *)0, (char *)0} }; -/*% +/* * Names of message sections. */ -const struct res_sym __p_default_section_syms[] = { +static const struct res_sym __p_default_section_syms[] = { {ns_s_qd, "QUERY", (char *)0}, {ns_s_an, "ANSWER", (char *)0}, {ns_s_ns, "AUTHORITY", (char *)0}, @@ -384,7 +381,7 @@ const struct res_sym __p_default_section_syms[] = { {0, (char *)0, (char *)0} }; -const struct res_sym __p_update_section_syms[] = { +static const struct res_sym __p_update_section_syms[] = { {S_ZONE, "ZONE", (char *)0}, {S_PREREQ, "PREREQUISITE", (char *)0}, {S_UPDATE, "UPDATE", (char *)0}, @@ -410,7 +407,7 @@ const struct res_sym __p_cert_syms[] = { {0, NULL, NULL} }; -/*% +/* * Names of RR types and qtypes. Types and qtypes are the same, except * that T_ANY is a qtype but not a type. (You can ask for records of type * T_ANY, but you can't have any records of that type in the database.) @@ -468,7 +465,7 @@ const struct res_sym __p_type_syms[] = { {0, NULL, NULL} }; -/*% +/* * Names of DNS rcodes. */ const struct res_sym __p_rcode_syms[] = { @@ -501,7 +498,7 @@ sym_ston(const struct res_sym *syms, const char *name, int *success) { } if (success) *success = 0; - return (syms->number); /*%< The default value. */ + return (syms->number); /* The default value. */ } const char * @@ -516,7 +513,7 @@ sym_ntos(const struct res_sym *syms, int number, int *success) { } } - sprintf(unname, "%d", number); /*%< XXX nonreentrant */ + sprintf(unname, "%d", number); /* XXX nonreentrant */ if (success) *success = 0; return (unname); @@ -533,13 +530,13 @@ sym_ntop(const struct res_sym *syms, int number, int *success) { return (syms->humanname); } } - sprintf(unname, "%d", number); /*%< XXX nonreentrant */ + sprintf(unname, "%d", number); /* XXX nonreentrant */ if (success) *success = 0; return (unname); } -/*% +/* * Return a string for the type. */ const char * @@ -557,7 +554,7 @@ p_type(int type) { return (typebuf); } -/*% +/* * Return a string for the type. */ const char * @@ -575,7 +572,7 @@ p_section(int section, int opcode) { return (sym_ntos(symbols, section, (int *)0)); } -/*% +/* * Return a mnemonic for class. */ const char * @@ -593,7 +590,7 @@ p_class(int class) { return (classbuf); } -/*% +/* * Return a mnemonic for an option */ const char * @@ -615,7 +612,7 @@ p_option(u_long option) { case RES_INSECURE2: return "insecure2"; case RES_NOALIASES: return "noaliases"; case RES_USE_INET6: return "inet6"; -#ifdef RES_USE_EDNS0 /*%< KAME extension */ +#ifdef RES_USE_EDNS0 /* KAME extension */ case RES_USE_EDNS0: return "edns0"; #endif #ifdef RES_USE_DNAME @@ -636,7 +633,7 @@ p_option(u_long option) { } } -/*% +/* * Return a mnemonic for a time to live. */ const char * @@ -648,7 +645,7 @@ p_time(u_int32_t value) { return (nbuf); } -/*% +/* * Return a string for the rcode. */ const char * @@ -656,7 +653,7 @@ p_rcode(int rcode) { return (sym_ntos(__p_rcode_syms, rcode, (int *)0)); } -/*% +/* * Return a string for a res_sockaddr_union. */ const char * @@ -683,7 +680,7 @@ p_sockun(union res_sockaddr_union u, char *buf, size_t size) { return (buf); } -/*% +/* * routines to convert between on-the-wire RR format and zone file format. * Does not contain conversion to/from decimal degrees; divide or multiply * by 60*60*1000 for that. @@ -692,7 +689,7 @@ p_sockun(union res_sockaddr_union u, char *buf, size_t size) { static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000, 1000000,10000000,100000000,1000000000}; -/*% takes an XeY precision/size value, returns a string representation. */ +/* takes an XeY precision/size value, returns a string representation. */ static const char * precsize_ntoa(prec) u_int8_t prec; @@ -710,7 +707,7 @@ precsize_ntoa(prec) return (retbuf); } -/*% converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */ +/* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */ static u_int8_t precsize_aton(const char **strptr) { unsigned int mval = 0, cmval = 0; @@ -724,7 +721,7 @@ precsize_aton(const char **strptr) { while (isdigit((unsigned char)*cp)) mval = mval * 10 + (*cp++ - '0'); - if (*cp == '.') { /*%< centimeters */ + if (*cp == '.') { /* centimeters */ cp++; if (isdigit((unsigned char)*cp)) { cmval = (*cp++ - '0') * 10; @@ -750,7 +747,7 @@ precsize_aton(const char **strptr) { return (retval); } -/*% converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */ +/* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */ static u_int32_t latlon2ul(const char **latlonstrptr, int *which) { const char *cp; @@ -780,7 +777,7 @@ latlon2ul(const char **latlonstrptr, int *which) { while (isdigit((unsigned char)*cp)) secs = secs * 10 + (*cp++ - '0'); - if (*cp == '.') { /*%< decimal seconds */ + if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit((unsigned char)*cp)) { secsfrac = (*cp++ - '0') * 100; @@ -793,7 +790,7 @@ latlon2ul(const char **latlonstrptr, int *which) { } } - while (!isspace((unsigned char)*cp)) /*%< if any trailing garbage */ + while (!isspace((unsigned char)*cp)) /* if any trailing garbage */ cp++; while (isspace((unsigned char)*cp)) @@ -814,29 +811,30 @@ latlon2ul(const char **latlonstrptr, int *which) { - secsfrac; break; default: - retval = 0; /*%< invalid value -- indicates error */ + retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': - *which = 1; /*%< latitude */ + *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': - *which = 2; /*%< longitude */ + *which = 2; /* longitude */ break; default: - *which = 0; /*%< error */ + *which = 0; /* error */ break; } - cp++; /*%< skip the hemisphere */ - while (!isspace((unsigned char)*cp)) /*%< if any trailing garbage */ + cp++; /* skip the hemisphere */ + + while (!isspace((unsigned char)*cp)) /* if any trailing garbage */ cp++; - while (isspace((unsigned char)*cp)) /*%< move to next field */ + while (isspace((unsigned char)*cp)) /* move to next field */ cp++; *latlonstrptr = cp; @@ -844,8 +842,7 @@ latlon2ul(const char **latlonstrptr, int *which) { return (retval); } -/*% - * converts a zone file representation in a string to an RDATA on-the-wire +/* converts a zone file representation in a string to an RDATA on-the-wire * representation. */ int loc_aton(ascii, binary) @@ -858,9 +855,9 @@ loc_aton(ascii, binary) u_int32_t latit = 0, longit = 0, alt = 0; u_int32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; - u_int8_t hp = 0x16; /*%< default = 1e6 cm = 10000.00m = 10km */ - u_int8_t vp = 0x13; /*%< default = 1e3 cm = 10.00m */ - u_int8_t siz = 0x12; /*%< default = 1e2 cm = 1.00m */ + u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ + u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ + u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = ascii; @@ -871,18 +868,18 @@ loc_aton(ascii, binary) lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { - case 3: /*%< 1 + 2, the only valid combination */ - if ((which1 == 1) && (which2 == 2)) { /*%< normal case */ + case 3: /* 1 + 2, the only valid combination */ + if ((which1 == 1) && (which2 == 2)) { /* normal case */ latit = lltemp1; longit = lltemp2; - } else if ((which1 == 2) && (which2 == 1)) { /*%< reversed */ + } else if ((which1 == 2) && (which2 == 1)) { /* reversed */ longit = lltemp1; latit = lltemp2; - } else { /*%< some kind of brokenness */ + } else { /* some kind of brokenness */ return (0); } break; - default: /*%< we didn't get one of each */ + default: /* we didn't get one of each */ return (0); } @@ -898,7 +895,7 @@ loc_aton(ascii, binary) while (isdigit((unsigned char)*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); - if (*cp == '.') { /*%< decimal meters */ + if (*cp == '.') { /* decimal meters */ cp++; if (isdigit((unsigned char)*cp)) { altfrac = (*cp++ - '0') * 10; @@ -910,7 +907,7 @@ loc_aton(ascii, binary) alt = (10000000 + (altsign * (altmeters * 100 + altfrac))); - while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */ + while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace((unsigned char)*cp) && (cp < maxcp)) @@ -921,7 +918,7 @@ loc_aton(ascii, binary) siz = precsize_aton(&cp); - while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */ + while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace((unsigned char)*cp) && (cp < maxcp)) @@ -932,7 +929,7 @@ loc_aton(ascii, binary) hp = precsize_aton(&cp); - while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */ + while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace((unsigned char)*cp) && (cp < maxcp)) @@ -946,7 +943,7 @@ loc_aton(ascii, binary) defaults: bcp = binary; - *bcp++ = (u_int8_t) 0; /*%< version byte */ + *bcp++ = (u_int8_t) 0; /* version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; @@ -954,10 +951,10 @@ loc_aton(ascii, binary) PUTLONG(longit,bcp); PUTLONG(alt,bcp); - return (16); /*%< size of RR in octets */ + return (16); /* size of RR in octets */ } -/*% takes an on-the-wire LOC RR and formats it in a human readable format. */ +/* takes an on-the-wire LOC RR and formats it in a human readable format. */ const char * loc_ntoa(binary, ascii) const u_char *binary; @@ -1004,7 +1001,7 @@ loc_ntoa(binary, ascii) longval = (templ - ((unsigned)1<<31)); GETLONG(templ, cp); - if (templ < referencealt) { /*%< below WGS 84 spheroid */ + if (templ < referencealt) { /* below WGS 84 spheroid */ altval = referencealt - templ; altsign = "-"; } else { @@ -1067,7 +1064,7 @@ loc_ntoa(binary, ascii) } -/*% Return the number of DNS hierarchy levels in the name. */ +/* Return the number of DNS hierarchy levels in the name. */ int dn_count_labels(const char *name) { int i, len, count; @@ -1092,7 +1089,8 @@ dn_count_labels(const char *name) { return (count); } -/*% + +/* * Make dates expressed in seconds-since-Jan-1-1970 easy to read. * SIG records are required to be printed like this, by the Secure DNS RFC. */ @@ -1162,4 +1160,21 @@ res_nametotype(const char *buf, int *successp) { return (result); } -/*! \file */ +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include <resolv.h>. + */ +#undef fp_resstat +__weak_reference(__fp_resstat, fp_resstat); +#undef p_fqnname +__weak_reference(__p_fqnname, p_fqnname); +#undef sym_ston +__weak_reference(__sym_ston, sym_ston); +#undef sym_ntos +__weak_reference(__sym_ntos, sym_ntos); +#undef sym_ntop +__weak_reference(__sym_ntop, sym_ntop); +#undef dn_count_labels +__weak_reference(__dn_count_labels, dn_count_labels); +#undef p_secstodate +__weak_reference(__p_secstodate, p_secstodate); diff --git a/lib/libc/resolv/res_findzonecut.c b/lib/libc/resolv/res_findzonecut.c index 207d66c..c6213b3 100644 --- a/lib/libc/resolv/res_findzonecut.c +++ b/lib/libc/resolv/res_findzonecut.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: res_findzonecut.c,v 1.7.18.3 2005/10/11 00:25:11 marka Exp $"; +static const char rcsid[] = "$Id: res_findzonecut.c,v 1.2.2.3.4.4 2005/10/11 00:48:16 marka Exp $"; #endif /* not lint */ /* @@ -19,6 +19,9 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 1.7.18.3 2005/10/11 00:25: * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + /* Import. */ #include "port_before.h" @@ -96,60 +99,60 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2); /* Public. */ -/*% +/* + * int + * res_findzonecut(res, dname, class, zname, zsize, addrs, naddrs) * find enclosing zone for a <dname,class>, and some server addresses - * * parameters: - *\li res - resolver context to work within (is modified) - *\li dname - domain name whose enclosing zone is desired - *\li class - class of dname (and its enclosing zone) - *\li zname - found zone name - *\li zsize - allocated size of zname - *\li addrs - found server addresses - *\li naddrs - max number of addrs - * + * res - resolver context to work within (is modified) + * dname - domain name whose enclosing zone is desired + * class - class of dname (and its enclosing zone) + * zname - found zone name + * zsize - allocated size of zname + * addrs - found server addresses + * naddrs - max number of addrs * return values: - *\li < 0 - an error occurred (check errno) - *\li = 0 - zname is now valid, but addrs[] wasn't changed - *\li > 0 - zname is now valid, and return value is number of addrs[] found - * + * < 0 - an error occurred (check errno) + * = 0 - zname is now valid, but addrs[] wasn't changed + * > 0 - zname is now valid, and return value is number of addrs[] found * notes: - *\li this function calls res_nsend() which means it depends on correctly + * this function calls res_nsend() which means it depends on correctly * functioning recursive nameservers (usually defined in /etc/resolv.conf * or its local equivilent). * - *\li we start by asking for an SOA<dname,class>. if we get one as an + * we start by asking for an SOA<dname,class>. if we get one as an * answer, that just means <dname,class> is a zone top, which is fine. * more than likely we'll be told to go pound sand, in the form of a * negative answer. * - *\li note that we are not prepared to deal with referrals since that would + * note that we are not prepared to deal with referrals since that would * only come from authority servers and our correctly functioning local * recursive server would have followed the referral and got us something * more definite. * - *\li if the authority section contains an SOA, this SOA should also be the + * if the authority section contains an SOA, this SOA should also be the * closest enclosing zone, since any intermediary zone cuts would've been * returned as referrals and dealt with by our correctly functioning local * recursive name server. but an SOA in the authority section should NOT * match our dname (since that would have been returned in the answer * section). an authority section SOA has to be "above" our dname. * - *\li however, since authority section SOA's were once optional, it's + * however, since authority section SOA's were once optional, it's * possible that we'll have to go hunting for the enclosing SOA by * ripping labels off the front of our dname -- this is known as "doing * it the hard way." * - *\li ultimately we want some server addresses, which are ideally the ones + * ultimately we want some server addresses, which are ideally the ones * pertaining to the SOA.MNAME, but only if there is a matching NS RR. * so the second phase (after we find an SOA) is to go looking for the * NS RRset for that SOA's zone. * - *\li no answer section processed by this code is allowed to contain CNAME + * no answer section processed by this code is allowed to contain CNAME * or DNAME RR's. for the SOA query this means we strip a label and * keep going. for the NS and A queries this means we just give up. */ +#ifndef _LIBC int res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, char *zname, size_t zsize, struct in_addr *addrs, int naddrs) @@ -174,6 +177,7 @@ res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, free(u); return (result); } +#endif int res_findzonecut2(res_state statp, const char *dname, ns_class class, int opts, @@ -718,5 +722,3 @@ res_dprintf(const char *fmt, ...) { fputc('\n', stderr); va_end(ap); } - -/*! \file */ diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c index 013a3ca..f8e4c67 100644 --- a/lib/libc/resolv/res_init.c +++ b/lib/libc/resolv/res_init.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -70,11 +66,15 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; -static const char rcsid[] = "$Id: res_init.c,v 1.16.18.5 2006/08/30 23:23:13 marka Exp $"; +static const char rcsid[] = "$Id: res_init.c,v 1.9.2.5.4.6 2006/08/30 23:23:01 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" +#include "namespace.h" + #include <sys/types.h> #include <sys/param.h> #include <sys/socket.h> @@ -91,6 +91,8 @@ static const char rcsid[] = "$Id: res_init.c,v 1.16.18.5 2006/08/30 23:23:13 mar #include <unistd.h> #include <netdb.h> +#include "un-namespace.h" + #include "port_after.h" /* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */ @@ -98,7 +100,7 @@ static const char rcsid[] = "$Id: res_init.c,v 1.16.18.5 2006/08/30 23:23:13 mar #include "res_private.h" -/*% Options. Should all be left alone. */ +/* Options. Should all be left alone. */ #define RESOLVSORT #define DEBUG @@ -106,15 +108,15 @@ static const char rcsid[] = "$Id: res_init.c,v 1.16.18.5 2006/08/30 23:23:13 mar #include <sys/systeminfo.h> #endif -static void res_setoptions __P((res_state, const char *, const char *)); +static void res_setoptions(res_state, const char *, const char *); #ifdef RESOLVSORT static const char sort_mask[] = "/&"; #define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL) -static u_int32_t net_mask __P((struct in_addr)); +static u_int32_t net_mask(struct in_addr); #endif -#if !defined(isascii) /*%< XXX - could be a function */ +#if !defined(isascii) /* XXX - could be a function */ # define isascii(c) (!(c & 0200)) #endif @@ -122,7 +124,7 @@ static u_int32_t net_mask __P((struct in_addr)); * Resolver state default settings. */ -/*% +/* * Set up default settings. If the configuration file exist, the values * there will have precedence. Otherwise, the server address is set to * INADDR_ANY and the default domain name comes from the gethostname(). @@ -150,14 +152,14 @@ res_ninit(res_state statp) { return (__res_vinit(statp, 0)); } -/*% This function has to be reachable by res_data.c but not publically. */ +/* This function has to be reachable by res_data.c but not publically. */ int __res_vinit(res_state statp, int preinit) { - register FILE *fp; - register char *cp, **pp; - register int n; + FILE *fp; + char *cp, **pp; + int n; char buf[BUFSIZ]; - int nserv = 0; /*%< number of nameserver records read from file */ + int nserv = 0; /* number of nameserver records read from file */ int haveenv = 0; int havesearch = 0; #ifdef RESOLVSORT @@ -246,7 +248,7 @@ __res_vinit(res_state statp, int preinit) { #endif /* SOLARIS2 */ /* Allow user to override the local domain definition */ - if ((cp = getenv("LOCALDOMAIN")) != NULL) { + if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) { (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); statp->defdname[sizeof(statp->defdname) - 1] = '\0'; haveenv++; @@ -262,7 +264,7 @@ __res_vinit(res_state statp, int preinit) { pp = statp->dnsrch; *pp++ = cp; for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) { - if (*cp == '\n') /*%< silly backwards compat */ + if (*cp == '\n') /* silly backwards compat */ break; else if (*cp == ' ' || *cp == '\t') { *cp = 0; @@ -294,7 +296,7 @@ __res_vinit(res_state statp, int preinit) { continue; /* read default domain name */ if (MATCH(buf, "domain")) { - if (haveenv) /*%< skip if have from environ */ + if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; while (*cp == ' ' || *cp == '\t') @@ -310,7 +312,7 @@ __res_vinit(res_state statp, int preinit) { } /* set search list */ if (MATCH(buf, "search")) { - if (haveenv) /*%< skip if have from environ */ + if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("search") - 1; while (*cp == ' ' || *cp == '\t') @@ -383,6 +385,10 @@ __res_vinit(res_state statp, int preinit) { #ifdef RESOLVSORT if (MATCH(buf, "sortlist")) { struct in_addr a; + struct in6_addr a6; + int m, i; + u_char *u; + struct __res_state_ext *ext = statp->_u._ext.ext; cp = buf + sizeof("sortlist") - 1; while (nsort < MAXRESOLVSORT) { @@ -417,6 +423,57 @@ __res_vinit(res_state statp, int preinit) { statp->sort_list[nsort].mask = net_mask(statp->sort_list[nsort].addr); } + ext->sort_list[nsort].af = AF_INET; + ext->sort_list[nsort].addr.ina = + statp->sort_list[nsort].addr; + ext->sort_list[nsort].mask.ina.s_addr = + statp->sort_list[nsort].mask; + nsort++; + } + else if (inet_pton(AF_INET6, net, &a6) == 1) { + + ext->sort_list[nsort].af = AF_INET6; + ext->sort_list[nsort].addr.in6a = a6; + u = (u_char *)&ext->sort_list[nsort].mask.in6a; + *cp++ = n; + net = cp; + while (*cp && *cp != ';' && + isascii(*cp) && !isspace(*cp)) + cp++; + m = n; + n = *cp; + *cp = 0; + switch (m) { + case '/': + m = atoi(net); + break; + case '&': + if (inet_pton(AF_INET6, net, u) == 1) { + m = -1; + break; + } + /*FALLTHROUGH*/ + default: + m = sizeof(struct in6_addr) * CHAR_BIT; + break; + } + if (m >= 0) { + for (i = 0; i < sizeof(struct in6_addr); i++) { + if (m <= 0) { + *u = 0; + } else { + m -= CHAR_BIT; + *u = (u_char)~0; + if (m < 0) + *u <<= -m; + } + u++; + } + } + statp->sort_list[nsort].addr.s_addr = + (u_int32_t)0xffffffff; + statp->sort_list[nsort].mask = + (u_int32_t)0xffffffff; nsort++; } *cp = n; @@ -464,7 +521,7 @@ __res_vinit(res_state statp, int preinit) { while (pp < statp->dnsrch + MAXDFLSRCH) { if (dots < LOCALDOMAINPARTS) break; - cp = strchr(cp, '.') + 1; /*%< we know there is one */ + cp = strchr(cp, '.') + 1; /* we know there is one */ *pp++ = cp; dots--; } @@ -479,7 +536,9 @@ __res_vinit(res_state statp, int preinit) { #endif } - if ((cp = getenv("RES_OPTIONS")) != NULL) + if (issetugid()) + statp->options |= RES_NOALIASES; + else if ((cp = getenv("RES_OPTIONS")) != NULL) res_setoptions(statp, cp, "env"); statp->options |= RES_INIT; return (0); @@ -499,7 +558,9 @@ res_setoptions(res_state statp, const char *options, const char *source) { const char *cp = options; int i; +#ifndef _LIBC struct __res_state_ext *ext = statp->_u._ext.ext; +#endif #ifdef DEBUG if (statp->options & RES_DEBUG) @@ -573,6 +634,10 @@ res_setoptions(res_state statp, const char *options, const char *source) statp->options |= RES_NOTLDQUERY; } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { statp->options |= RES_USE_INET6; + } else if (!strncmp(cp, "insecure1", sizeof("insecure1") - 1)) { + statp->options |= RES_INSECURE1; + } else if (!strncmp(cp, "insecure2", sizeof("insecure2") - 1)) { + statp->options |= RES_INSECURE2; } else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) { statp->options |= RES_ROTATE; } else if (!strncmp(cp, "no-check-names", @@ -584,6 +649,7 @@ res_setoptions(res_state statp, const char *options, const char *source) statp->options |= RES_USE_EDNS0; } #endif +#ifndef _LIBC else if (!strncmp(cp, "dname", sizeof("dname") - 1)) { statp->options |= RES_USE_DNAME; } @@ -613,10 +679,13 @@ res_setoptions(res_state statp, const char *options, const char *source) ~RES_NO_NIBBLE2; } } +#endif else { /* XXX - print a warning here? */ } +#ifndef _LIBC skip: +#endif /* skip to next run of spaces */ while (*cp && *cp != ' ' && *cp != '\t') cp++; @@ -626,10 +695,10 @@ res_setoptions(res_state statp, const char *options, const char *source) #ifdef RESOLVSORT /* XXX - should really support CIDR which means explicit masks always. */ static u_int32_t -net_mask(in) /*!< XXX - should really use system's version of this */ +net_mask(in) /* XXX - should really use system's version of this */ struct in_addr in; { - register u_int32_t i = ntohl(in.s_addr); + u_int32_t i = ntohl(in.s_addr); if (IN_CLASSA(i)) return (htonl(IN_CLASSA_NET)); @@ -647,7 +716,7 @@ res_randomid(void) { return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid())); } -/*% +/* * This routine is for closing the socket if a virtual circuit is used and * the program wants to close it. This provides support for endhostent() * which expects to close the socket. @@ -659,13 +728,13 @@ res_nclose(res_state statp) { int ns; if (statp->_vcsock >= 0) { - (void) close(statp->_vcsock); + (void) _close(statp->_vcsock); statp->_vcsock = -1; statp->_flags &= ~(RES_F_VC | RES_F_CONN); } for (ns = 0; ns < statp->_u._ext.nscount; ns++) { if (statp->_u._ext.nssocks[ns] != -1) { - (void) close(statp->_u._ext.nssocks[ns]); + (void) _close(statp->_u._ext.nssocks[ns]); statp->_u._ext.nssocks[ns] = -1; } } @@ -680,6 +749,7 @@ res_ndestroy(res_state statp) { statp->_u._ext.ext = NULL; } +#ifndef _LIBC const char * res_get_nibblesuffix(res_state statp) { if (statp->_u._ext.ext) @@ -693,6 +763,7 @@ res_get_nibblesuffix2(res_state statp) { return (statp->_u._ext.ext->nsuffix2); return ("ip6.int"); } +#endif void res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) { @@ -790,5 +861,3 @@ res_getservers(res_state statp, union res_sockaddr_union *set, int cnt) { } return (statp->nscount); } - -/*! \file */ diff --git a/lib/libc/resolv/res_mkquery.c b/lib/libc/resolv/res_mkquery.c index 50e4a9e..6c59594 100644 --- a/lib/libc/resolv/res_mkquery.c +++ b/lib/libc/resolv/res_mkquery.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -70,8 +66,10 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_mkquery.c,v 1.5.18.1 2005/04/27 05:01:11 sra Exp $"; +static const char rcsid[] = "$Id: res_mkquery.c,v 1.1.2.2.4.2 2004/03/16 12:34:18 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" #include <sys/types.h> @@ -89,24 +87,24 @@ static const char rcsid[] = "$Id: res_mkquery.c,v 1.5.18.1 2005/04/27 05:01:11 s extern const char *_res_opcodes[]; -/*% +/* * Form all types of queries. * Returns the size of the result or -1. */ int res_nmkquery(res_state statp, - int op, /*!< opcode of query */ - const char *dname, /*!< domain name */ - int class, int type, /*!< class and type of query */ - const u_char *data, /*!< resource record data */ - int datalen, /*!< length of data */ - const u_char *newrr_in, /*!< new rr for modify or append */ - u_char *buf, /*!< buffer to put query */ - int buflen) /*!< size of buffer */ + int op, /* opcode of query */ + const char *dname, /* domain name */ + int class, int type, /* class and type of query */ + const u_char *data, /* resource record data */ + int datalen, /* length of data */ + const u_char *newrr_in, /* new rr for modify or append */ + u_char *buf, /* buffer to put query */ + int buflen) /* size of buffer */ { - register HEADER *hp; - register u_char *cp, *ep; - register int n; + HEADER *hp; + u_char *cp, *ep; + int n; u_char *dnptrs[20], **dpp, **lastdnptr; UNUSED(newrr_in); @@ -179,7 +177,7 @@ res_nmkquery(res_state statp, */ if (ep - cp < 1 + RRFIXEDSZ + datalen) return (-1); - *cp++ = '\0'; /*%< no domain name */ + *cp++ = '\0'; /* no domain name */ ns_put16(type, cp); cp += INT16SZ; ns_put16(class, cp); @@ -209,13 +207,13 @@ res_nmkquery(res_state statp, int res_nopt(res_state statp, - int n0, /*%< current offset in buffer */ - u_char *buf, /*%< buffer to put query */ - int buflen, /*%< size of buffer */ - int anslen) /*%< UDP answer buffer size */ + int n0, /* current offset in buffer */ + u_char *buf, /* buffer to put query */ + int buflen, /* size of buffer */ + int anslen) /* UDP answer buffer size */ { - register HEADER *hp; - register u_char *cp, *ep; + HEADER *hp; + u_char *cp, *ep; u_int16_t flags = 0; #ifdef DEBUG @@ -230,13 +228,16 @@ res_nopt(res_state statp, if ((ep - cp) < 1 + RRFIXEDSZ) return (-1); - *cp++ = 0; /*%< "." */ - ns_put16(T_OPT, cp); /*%< TYPE */ + *cp++ = 0; /* "." */ + + ns_put16(T_OPT, cp); /* TYPE */ cp += INT16SZ; - ns_put16(anslen & 0xffff, cp); /*%< CLASS = UDP payload size */ + if (anslen > 0xffff) + anslen = 0xffff; /* limit to 16bit value */ + ns_put16(anslen & 0xffff, cp); /* CLASS = UDP payload size */ cp += INT16SZ; - *cp++ = NOERROR; /*%< extended RCODE */ - *cp++ = 0; /*%< EDNS version */ + *cp++ = NOERROR; /* extended RCODE */ + *cp++ = 0; /* EDNS version */ if (statp->options & RES_USE_DNSSEC) { #ifdef DEBUG if (statp->options & RES_DEBUG) @@ -246,12 +247,10 @@ res_nopt(res_state statp, } ns_put16(flags, cp); cp += INT16SZ; - ns_put16(0, cp); /*%< RDLEN */ + ns_put16(0, cp); /* RDLEN */ cp += INT16SZ; hp->arcount = htons(ntohs(hp->arcount) + 1); return (cp - buf); } #endif - -/*! \file */ diff --git a/lib/libc/resolv/res_mkupdate.c b/lib/libc/resolv/res_mkupdate.c index 4299275..0e800e3 100644 --- a/lib/libc/resolv/res_mkupdate.c +++ b/lib/libc/resolv/res_mkupdate.c @@ -15,15 +15,16 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/*! \file - * \brief +/* * Based on the Dynamic DNS reference implementation by Viraj Bais - * <viraj_bais@ccm.fm.intel.com> + * <viraj_bais@ccm.fm.intel.com> */ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: res_mkupdate.c,v 1.4.18.4 2005/10/14 05:44:12 marka Exp $"; +static const char rcsid[] = "$Id: res_mkupdate.c,v 1.1.2.1.4.5 2005/10/14 05:43:47 marka Exp $"; #endif /* not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" @@ -45,6 +46,10 @@ static const char rcsid[] = "$Id: res_mkupdate.c,v 1.4.18.4 2005/10/14 05:44:12 #include <unistd.h> #include <ctype.h> +#ifdef _LIBC +#include <isc/list.h> +#endif + #include "port_after.h" /* Options. Leave them on. */ @@ -60,22 +65,26 @@ static int getstr_str(char *, int, u_char **, u_char *); /* Forward. */ +#ifdef _LIBC +static +#endif int res_protocolnumber(const char *); +#ifdef _LIBC +static +#endif int res_servicenumber(const char *); -/*% +/* * Form update packets. * Returns the size of the resulting packet if no error - * * On error, - * returns - *\li -1 if error in reading a word/number in rdata + * returns -1 if error in reading a word/number in rdata * portion for update packets - *\li -2 if length of buffer passed is insufficient - *\li -3 if zone section is not the first section in + * -2 if length of buffer passed is insufficient + * -3 if zone section is not the first section in * the linked list, or section order has a problem - *\li -4 on a number overflow - *\li -5 unknown operation or no records + * -4 on a number overflow + * -5 unknown operation or no records */ int res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { @@ -92,7 +101,10 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { u_int16_t rtype, rclass; u_int32_t n1, rttl; u_char *dnptrs[20], **dpp, **lastdnptr; - int siglen, keylen, certlen; +#ifndef _LIBC + int siglen; +#endif + int keylen, certlen; /* * Initialize header fields. @@ -192,7 +204,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { } ShrinkBuffer(INT32SZ + INT16SZ); PUTLONG(rttl, cp); - sp2 = cp; /*%< save pointer to length byte */ + sp2 = cp; /* save pointer to length byte */ cp += INT16SZ; if (rrecp->r_size == 0) { if (section == S_UPDATE && rclass != C_ANY) @@ -398,7 +410,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { } break; case T_X25: - /* RFC1183 */ + /* RFC 1183 */ if ((n = getstr_str(buf2, sizeof buf2, &startp, endp)) < 0) return (-1); @@ -410,7 +422,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { cp += n; break; case T_ISDN: - /* RFC1183 */ + /* RFC 1183 */ if ((n = getstr_str(buf2, sizeof buf2, &startp, endp)) < 0) return (-1); @@ -448,6 +460,9 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { return (-1); break; case ns_t_sig: +#ifdef _LIBC + return (-1); +#else { int sig_type, success, dateerror; u_int32_t exptime, timesigned; @@ -538,6 +553,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { cp += siglen; break; } +#endif case ns_t_key: /* flags */ n = gethexnum_str(&startp, endp); @@ -711,7 +727,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { return (cp - buf); } -/*% +/* * Get a whitespace delimited word from a string (not file) * into buf. modify the start pointer to point after the * word in the string. @@ -724,9 +740,9 @@ getword_str(char *buf, int size, u_char **startpp, u_char *endp) { for (cp = buf; *startpp <= endp; ) { c = **startpp; if (isspace(c) || c == '\0') { - if (cp != buf) /*%< trailing whitespace */ + if (cp != buf) /* trailing whitespace */ break; - else { /*%< leading whitespace */ + else { /* leading whitespace */ (*startpp)++; continue; } @@ -740,9 +756,9 @@ getword_str(char *buf, int size, u_char **startpp, u_char *endp) { return (cp != buf); } -/*% +/* * get a white spae delimited string from memory. Process quoted strings - * and \\DDD escapes. Return length or -1 on error. Returned string may + * and \DDD escapes. Return length or -1 on error. Returned string may * contain nulls. */ static char digits[] = "0123456789"; @@ -819,8 +835,7 @@ getstr_str(char *buf, int size, u_char **startpp, u_char *endp) { *cp = '\0'; return ((cp == buf)? (seen_quote? 0: -1): (cp - buf)); } - -/*% +/* * Get a whitespace delimited base 16 number from a string (not file) into buf * update the start pointer to point after the number in the string. */ @@ -836,9 +851,9 @@ gethexnum_str(u_char **startpp, u_char *endp) { for (n = 0; *startpp <= endp; ) { c = **startpp; if (isspace(c) || c == '\0') { - if (seendigit) /*%< trailing whitespace */ + if (seendigit) /* trailing whitespace */ break; - else { /*%< leading whitespace */ + else { /* leading whitespace */ (*startpp)++; continue; } @@ -868,7 +883,7 @@ gethexnum_str(u_char **startpp, u_char *endp) { return (n + m); } -/*% +/* * Get a whitespace delimited base 10 number from a string (not file) into buf * update the start pointer to point after the number in the string. */ @@ -881,9 +896,9 @@ getnum_str(u_char **startpp, u_char *endp) { for (n = 0; *startpp <= endp; ) { c = **startpp; if (isspace(c) || c == '\0') { - if (seendigit) /*%< trailing whitespace */ + if (seendigit) /* trailing whitespace */ break; - else { /*%< leading whitespace */ + else { /* leading whitespace */ (*startpp)++; continue; } @@ -910,7 +925,7 @@ getnum_str(u_char **startpp, u_char *endp) { return (n + m); } -/*% +/* * Allocate a resource record buffer & save rr info. */ ns_updrec * @@ -932,7 +947,7 @@ res_mkupdrec(int section, const char *dname, return (rrecp); } -/*% +/* * Free a resource record buffer created by res_mkupdrec. */ void @@ -974,7 +989,7 @@ res_buildservicelist() { free(slp); break; } - slp->port = ntohs((u_int16_t)sp->s_port); /*%< host byt order */ + slp->port = ntohs((u_int16_t)sp->s_port); /* host byt order */ slp->next = servicelist; slp->prev = NULL; if (servicelist) @@ -984,6 +999,7 @@ res_buildservicelist() { endservent(); } +#ifndef _LIBC void res_destroyservicelist() { struct valuelist *slp, *slp_next; @@ -996,7 +1012,11 @@ res_destroyservicelist() { } servicelist = (struct valuelist *)0; } +#endif +#ifdef _LIBC +static +#endif void res_buildprotolist(void) { struct protoent *pp; @@ -1016,7 +1036,7 @@ res_buildprotolist(void) { free(slp); break; } - slp->port = pp->p_proto; /*%< host byte order */ + slp->port = pp->p_proto; /* host byte order */ slp->next = protolist; slp->prev = NULL; if (protolist) @@ -1026,6 +1046,7 @@ res_buildprotolist(void) { endprotoent(); } +#ifndef _LIBC void res_destroyprotolist(void) { struct valuelist *plp, *plp_next; @@ -1037,6 +1058,7 @@ res_destroyprotolist(void) { } protolist = (struct valuelist *)0; } +#endif static int findservice(const char *s, struct valuelist **list) { @@ -1053,16 +1075,19 @@ findservice(const char *s, struct valuelist **list) { lp->next = *list; *list = lp; } - return (lp->port); /*%< host byte order */ + return (lp->port); /* host byte order */ } if (sscanf(s, "%d", &n) != 1 || n <= 0) n = -1; return (n); } -/*% +/* * Convert service name or (ascii) number to int. */ +#ifdef _LIBC +static +#endif int res_servicenumber(const char *p) { if (servicelist == (struct valuelist *)0) @@ -1070,9 +1095,12 @@ res_servicenumber(const char *p) { return (findservice(p, &servicelist)); } -/*% +/* * Convert protocol name or (ascii) number to int. */ +#ifdef _LIBC +static +#endif int res_protocolnumber(const char *p) { if (protolist == (struct valuelist *)0) @@ -1080,15 +1108,16 @@ res_protocolnumber(const char *p) { return (findservice(p, &protolist)); } +#ifndef _LIBC static struct servent * -cgetservbyport(u_int16_t port, const char *proto) { /*%< Host byte order. */ +cgetservbyport(u_int16_t port, const char *proto) { /* Host byte order. */ struct valuelist **list = &servicelist; struct valuelist *lp = *list; static struct servent serv; port = ntohs(port); for (; lp != NULL; lp = lp->next) { - if (port != (u_int16_t)lp->port) /*%< Host byte order. */ + if (port != (u_int16_t)lp->port) /* Host byte order. */ continue; if (strcasecmp(lp->proto, proto) == 0) { if (lp != *list) { @@ -1109,13 +1138,13 @@ cgetservbyport(u_int16_t port, const char *proto) { /*%< Host byte order. */ } static struct protoent * -cgetprotobynumber(int proto) { /*%< Host byte order. */ +cgetprotobynumber(int proto) { /* Host byte order. */ struct valuelist **list = &protolist; struct valuelist *lp = *list; static struct protoent prot; for (; lp != NULL; lp = lp->next) - if (lp->port == proto) { /*%< Host byte order. */ + if (lp->port == proto) { /* Host byte order. */ if (lp != *list) { lp->prev->next = lp->next; if (lp->next) @@ -1125,7 +1154,7 @@ cgetprotobynumber(int proto) { /*%< Host byte order. */ *list = lp; } prot.p_name = lp->name; - prot.p_proto = lp->port; /*%< Host byte order. */ + prot.p_proto = lp->port; /* Host byte order. */ return (&prot); } return (0); @@ -1147,7 +1176,7 @@ res_protocolname(int num) { } const char * -res_servicename(u_int16_t port, const char *proto) { /*%< Host byte order. */ +res_servicename(u_int16_t port, const char *proto) { /* Host byte order. */ static char number[8]; struct servent *ss; @@ -1160,3 +1189,4 @@ res_servicename(u_int16_t port, const char *proto) { /*%< Host byte order. */ } return (ss->s_name); } +#endif diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c index c160e93..c0cf003 100644 --- a/lib/libc/resolv/res_query.c +++ b/lib/libc/resolv/res_query.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -70,8 +66,10 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_query.c,v 1.7.18.1 2005/04/27 05:01:11 sra Exp $"; +static const char rcsid[] = "$Id: res_query.c,v 1.2.2.3.4.2 2004/03/16 12:34:19 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include "port_before.h" #include <sys/types.h> @@ -86,6 +84,7 @@ static const char rcsid[] = "$Id: res_query.c,v 1.7.18.1 2005/04/27 05:01:11 sra #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "port_after.h" /* Options. Leave them on. */ @@ -97,7 +96,7 @@ static const char rcsid[] = "$Id: res_query.c,v 1.7.18.1 2005/04/27 05:01:11 sra #define MAXPACKET 1024 #endif -/*% +/* * Formulate a normal query, send, and await answer. * Returned answer is placed in supplied buffer "answer". * Perform preliminary check of answer, returning success only @@ -109,10 +108,10 @@ static const char rcsid[] = "$Id: res_query.c,v 1.7.18.1 2005/04/27 05:01:11 sra */ int res_nquery(res_state statp, - const char *name, /*%< domain name */ - int class, int type, /*%< class and type of query */ - u_char *answer, /*%< buffer to put answer */ - int anslen) /*%< size of answer buffer */ + const char *name, /* domain name */ + int class, int type, /* class and type of query */ + u_char *answer, /* buffer to put answer */ + int anslen) /* size of answer buffer */ { u_char buf[MAXPACKET]; HEADER *hp = (HEADER *) answer; @@ -122,7 +121,8 @@ res_nquery(res_state statp, oflags = statp->_flags; again: - hp->rcode = NOERROR; /*%< default */ + hp->rcode = NOERROR; /* default */ + #ifdef DEBUG if (statp->options & RES_DEBUG) printf(";; res_query(%s, %d, %d)\n", name, class, type); @@ -194,7 +194,7 @@ again: return (n); } -/*% +/* * Formulate a normal query, send, and retrieve answer in supplied buffer. * Return the size of the response on success, -1 on error. * If enabled, implement search rules until answer or unrecoverable failure @@ -202,10 +202,10 @@ again: */ int res_nsearch(res_state statp, - const char *name, /*%< domain name */ - int class, int type, /*%< class and type of query */ - u_char *answer, /*%< buffer to put answer */ - int anslen) /*%< size of answer */ + const char *name, /* domain name */ + int class, int type, /* class and type of query */ + u_char *answer, /* buffer to put answer */ + int anslen) /* size of answer */ { const char *cp, * const *domain; HEADER *hp = (HEADER *) answer; @@ -217,7 +217,8 @@ res_nsearch(res_state statp, int searched = 0; errno = 0; - RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /*%< True if we never query. */ + RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */ + dots = 0; for (cp = name; *cp != '\0'; cp++) dots += (*cp == '.'); @@ -240,6 +241,21 @@ res_nsearch(res_state statp, answer, anslen); if (ret > 0 || trailing_dot) return (ret); + if (errno == ECONNREFUSED) { + RES_SET_H_ERRNO(statp, TRY_AGAIN); + return (-1); + } + switch (statp->res_h_errno) { + case NO_DATA: + case HOST_NOT_FOUND: + break; + case TRY_AGAIN: + if (hp->rcode == SERVFAIL) + break; + /* FALLTHROUGH */ + default: + return (-1); + } saved_herrno = statp->res_h_errno; tried_as_is++; } @@ -263,6 +279,9 @@ res_nsearch(res_state statp, (domain[0][0] == '.' && domain[0][1] == '\0')) root_on_list++; + if (root_on_list && tried_as_is) + continue; + ret = res_nquerydomain(statp, name, *domain, class, type, answer, anslen); @@ -295,9 +314,26 @@ res_nsearch(res_state statp, /* keep trying */ break; case TRY_AGAIN: + /* + * This can occur due to a server failure + * (that is, all listed servers have failed), + * or all listed servers have timed out. + * ((HEADER *)answer)->rcode may not be set + * to SERVFAIL in the case of a timeout. + * + * Either way we must return TRY_AGAIN in + * order to avoid non-deterministic + * return codes. + * For example, loaded name servers or races + * against network startup/validation (dhcp, + * ppp, etc) can cause the search to timeout + * on one search element, e.g. 'fu.bar.com', + * and return a definitive failure on the + * next search element, e.g. 'fu.'. + */ + got_servfail++; if (hp->rcode == SERVFAIL) { /* try next search element, if any */ - got_servfail++; break; } /* FALLTHROUGH */ @@ -314,6 +350,18 @@ res_nsearch(res_state statp, } } + switch (statp->res_h_errno) { + case NO_DATA: + case HOST_NOT_FOUND: + break; + case TRY_AGAIN: + if (hp->rcode == SERVFAIL) + break; + /* FALLTHROUGH */ + default: + goto giveup; + } + /* * If the query has not already been tried as is then try it * unless RES_NOTLDQUERY is set and there were no dots. @@ -333,6 +381,7 @@ res_nsearch(res_state statp, * else send back meaningless H_ERRNO, that being the one from * the last DNSRCH we did. */ +giveup: if (saved_herrno != -1) RES_SET_H_ERRNO(statp, saved_herrno); else if (got_nodata) @@ -342,7 +391,7 @@ res_nsearch(res_state statp, return (-1); } -/*% +/* * Perform a call on res_query on the concatenation of name and domain, * removing a trailing dot from name if domain is NULL. */ @@ -350,9 +399,9 @@ int res_nquerydomain(res_state statp, const char *name, const char *domain, - int class, int type, /*%< class and type of query */ - u_char *answer, /*%< buffer to put answer */ - int anslen) /*%< size of answer */ + int class, int type, /* class and type of query */ + u_char *answer, /* buffer to put answer */ + int anslen) /* size of answer */ { char nbuf[MAXDNAME]; const char *longname = nbuf; @@ -399,6 +448,8 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) { if (statp->options & RES_NOALIASES) return (NULL); + if (issetugid()) + return (NULL); file = getenv("HOSTALIASES"); if (file == NULL || (fp = fopen(file, "r")) == NULL) return (NULL); @@ -428,5 +479,3 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) { fclose(fp); return (NULL); } - -/*! \file */ diff --git a/lib/libc/resolv/res_send.c b/lib/libc/resolv/res_send.c index 39dc998..455599e 100644 --- a/lib/libc/resolv/res_send.c +++ b/lib/libc/resolv/res_send.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -70,17 +66,21 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_send.c,v 1.9.18.8 2006/10/16 23:00:58 marka Exp $"; +static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.9 2006/10/16 23:00:50 marka Exp $"; #endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); -/*! \file - * \brief +/* * Send query to name server and wait for reply. */ #include "port_before.h" +#ifndef USE_KQUEUE #include "fd_setsize.h" +#endif +#include "namespace.h" #include <sys/types.h> #include <sys/param.h> #include <sys/time.h> @@ -104,12 +104,18 @@ static const char rcsid[] = "$Id: res_send.c,v 1.9.18.8 2006/10/16 23:00:58 mark #include "port_after.h" +#ifdef USE_KQUEUE +#include <sys/event.h> +#else #ifdef USE_POLL #ifdef HAVE_STROPTS_H #include <stropts.h> #endif #include <poll.h> #endif /* USE_POLL */ +#endif + +#include "un-namespace.h" /* Options. Leave them on. */ #define DEBUG @@ -118,26 +124,28 @@ static const char rcsid[] = "$Id: res_send.c,v 1.9.18.8 2006/10/16 23:00:58 mark #define EXT(res) ((res)->_u._ext) -#ifndef USE_POLL +#if !defined(USE_POLL) && !defined(USE_KQUEUE) static const int highestFD = FD_SETSIZE - 1; -#else -static int highestFD = 0; #endif /* Forward. */ -static int get_salen __P((const struct sockaddr *)); -static struct sockaddr * get_nsaddr __P((res_state, size_t)); +static int get_salen(const struct sockaddr *); +static struct sockaddr * get_nsaddr(res_state, size_t); static int send_vc(res_state, const u_char *, int, u_char *, int, int *, int); -static int send_dg(res_state, const u_char *, int, +static int send_dg(res_state, +#ifdef USE_KQUEUE + int kq, +#endif + const u_char *, int, u_char *, int, int *, int, int, int *, int *); static void Aerror(const res_state, FILE *, const char *, int, const struct sockaddr *, int); static void Perror(const res_state, FILE *, const char *, int); static int sock_eq(struct sockaddr *, struct sockaddr *); -#if defined(NEED_PSELECT) && !defined(USE_POLL) +#if defined(NEED_PSELECT) && !defined(USE_POLL) && !defined(USE_KQUEUE) static int pselect(int, void *, void *, void *, struct timespec *, const sigset_t *); @@ -148,15 +156,14 @@ static const int niflags = NI_NUMERICHOST | NI_NUMERICSERV; /* Public. */ -/*% +/* int + * res_isourserver(ina) * looks up "ina" in _res.ns_addr_list[] - * * returns: - *\li 0 : not found - *\li >0 : found - * + * 0 : not found + * >0 : found * author: - *\li paul vixie, 29may94 + * paul vixie, 29may94 */ int res_ourserver_p(const res_state statp, const struct sockaddr *sa) { @@ -199,19 +206,17 @@ res_ourserver_p(const res_state statp, const struct sockaddr *sa) { return (0); } -/*% +/* int + * res_nameinquery(name, type, class, buf, eom) * look for (name,type,class) in the query section of packet (buf,eom) - * * requires: - *\li buf + HFIXEDSZ <= eom - * + * buf + HFIXEDSZ <= eom * returns: - *\li -1 : format error - *\li 0 : not found - *\li >0 : found - * + * -1 : format error + * 0 : not found + * >0 : found * author: - *\li paul vixie, 29may94 + * paul vixie, 29may94 */ int res_nameinquery(const char *name, int type, int class, @@ -239,17 +244,16 @@ res_nameinquery(const char *name, int type, int class, return (0); } -/*% +/* int + * res_queriesmatch(buf1, eom1, buf2, eom2) * is there a 1:1 mapping of (name,type,class) * in (buf1,eom1) and (buf2,eom2)? - * * returns: - *\li -1 : format error - *\li 0 : not a 1:1 mapping - *\li >0 : is a 1:1 mapping - * + * -1 : format error + * 0 : not a 1:1 mapping + * >0 : is a 1:1 mapping * author: - *\li paul vixie, 29may94 + * paul vixie, 29may94 */ int res_queriesmatch(const u_char *buf1, const u_char *eom1, @@ -294,11 +298,10 @@ res_nsend(res_state statp, const u_char *buf, int buflen, u_char *ans, int anssiz) { int gotsomewhere, terrno, try, v_circuit, resplen, ns, n; - char abuf[NI_MAXHOST]; - -#ifdef USE_POLL - highestFD = sysconf(_SC_OPEN_MAX) - 1; +#ifdef USE_KQUEUE + int kq; #endif + char abuf[NI_MAXHOST]; /* No name servers or res_init() failure */ if (statp->nscount == 0 || EXT(statp).ext == NULL) { @@ -315,6 +318,13 @@ res_nsend(res_state statp, gotsomewhere = 0; terrno = ETIMEDOUT; +#ifdef USE_KQUEUE + if ((kq = kqueue()) < 0) { + Perror(statp, stderr, "kqueue", errno); + return (-1); + } +#endif + /* * If the ns_addr_list in the resolver context has changed, then * invalidate our cached copy and the associated timing data. @@ -338,7 +348,7 @@ res_nsend(res_state statp, if (EXT(statp).nssocks[ns] == -1) continue; peerlen = sizeof(peer); - if (getsockname(EXT(statp).nssocks[ns], + if (_getsockname(EXT(statp).nssocks[ns], (struct sockaddr *)&peer, &peerlen) < 0) { needclose++; break; @@ -430,6 +440,9 @@ res_nsend(res_state statp, res_nclose(statp); goto next_ns; case res_done: +#ifdef USE_KQUEUE + _close(kq); +#endif return (resplen); case res_modified: /* give the hook another try */ @@ -463,7 +476,11 @@ res_nsend(res_state statp, resplen = n; } else { /* Use datagrams. */ - n = send_dg(statp, buf, buflen, ans, anssiz, &terrno, + n = send_dg(statp, +#ifdef USE_KQUEUE + kq, +#endif + buf, buflen, ans, anssiz, &terrno, ns, try, &v_circuit, &gotsomewhere); if (n < 0) goto fail; @@ -522,21 +539,30 @@ res_nsend(res_state statp, } while (!done); } +#ifdef USE_KQUEUE + _close(kq); +#endif return (resplen); next_ns: ; } /*foreach ns*/ } /*foreach retry*/ res_nclose(statp); +#ifdef USE_KQUEUE + _close(kq); +#endif if (!v_circuit) { if (!gotsomewhere) - errno = ECONNREFUSED; /*%< no nameservers found */ + errno = ECONNREFUSED; /* no nameservers found */ else - errno = ETIMEDOUT; /*%< no answer obtained */ + errno = ETIMEDOUT; /* no answer obtained */ } else errno = terrno; return (-1); fail: res_nclose(statp); +#ifdef USE_KQUEUE + _close(kq); +#endif return (-1); } @@ -558,10 +584,10 @@ get_salen(sa) else if (sa->sa_family == AF_INET6) return (sizeof(struct sockaddr_in6)); else - return (0); /*%< unknown, die on connect */ + return (0); /* unknown, die on connect */ } -/*% +/* * pick appropriate nsaddr_list for use. see res_init() for initialization. */ static struct sockaddr * @@ -614,7 +640,7 @@ send_vc(res_state statp, struct sockaddr_storage peer; ISC_SOCKLEN_T size = sizeof peer; - if (getpeername(statp->_vcsock, + if (_getpeername(statp->_vcsock, (struct sockaddr *)&peer, &size) < 0 || !sock_eq((struct sockaddr *)&peer, nsap)) { res_nclose(statp); @@ -626,11 +652,13 @@ send_vc(res_state statp, if (statp->_vcsock >= 0) res_nclose(statp); - statp->_vcsock = socket(nsap->sa_family, SOCK_STREAM, 0); + statp->_vcsock = _socket(nsap->sa_family, SOCK_STREAM, 0); +#if !defined(USE_POLL) && !defined(USE_KQUEUE) if (statp->_vcsock > highestFD) { res_nclose(statp); errno = ENOTSOCK; } +#endif if (statp->_vcsock < 0) { switch (errno) { case EPROTONOSUPPORT: @@ -647,7 +675,7 @@ send_vc(res_state statp, } } errno = 0; - if (connect(statp->_vcsock, nsap, nsaplen) < 0) { + if (_connect(statp->_vcsock, nsap, nsaplen) < 0) { *terrno = errno; Aerror(statp, stderr, "connect/vc", errno, nsap, nsaplen); @@ -664,7 +692,7 @@ send_vc(res_state statp, iov[0] = evConsIovec(&len, INT16SZ); DE_CONST(buf, tmp); iov[1] = evConsIovec(tmp, buflen); - if (writev(statp->_vcsock, iov, 2) != (INT16SZ + buflen)) { + if (_writev(statp->_vcsock, iov, 2) != (INT16SZ + buflen)) { *terrno = errno; Perror(statp, stderr, "write failed", errno); res_nclose(statp); @@ -676,7 +704,7 @@ send_vc(res_state statp, read_len: cp = ans; len = INT16SZ; - while ((n = read(statp->_vcsock, (char *)cp, (int)len)) > 0) { + while ((n = _read(statp->_vcsock, (char *)cp, (int)len)) > 0) { cp += n; if ((len -= n) == 0) break; @@ -722,7 +750,8 @@ send_vc(res_state statp, return (0); } cp = ans; - while (len != 0 && (n = read(statp->_vcsock, (char *)cp, (int)len)) > 0){ + while (len != 0 && + (n = _read(statp->_vcsock, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } @@ -741,8 +770,8 @@ send_vc(res_state statp, while (len != 0) { char junk[PACKETSZ]; - n = read(statp->_vcsock, junk, - (len > sizeof junk) ? sizeof junk : len); + n = _read(statp->_vcsock, junk, + (len > sizeof junk) ? sizeof junk : len); if (n > 0) len -= n; else @@ -772,7 +801,11 @@ send_vc(res_state statp, } static int -send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, +send_dg(res_state statp, +#ifdef USE_KQUEUE + int kq, +#endif + const u_char *buf, int buflen, u_char *ans, int anssiz, int *terrno, int ns, int try, int *v_circuit, int *gotsomewhere) { @@ -784,21 +817,28 @@ send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, struct sockaddr_storage from; ISC_SOCKLEN_T fromlen; int resplen, seconds, n, s; +#ifdef USE_KQUEUE + struct kevent kv; +#else #ifdef USE_POLL int polltimeout; struct pollfd pollfd; #else fd_set dsmask; #endif +#endif nsap = get_nsaddr(statp, ns); nsaplen = get_salen(nsap); if (EXT(statp).nssocks[ns] == -1) { - EXT(statp).nssocks[ns] = socket(nsap->sa_family, SOCK_DGRAM, 0); + EXT(statp).nssocks[ns] = _socket(nsap->sa_family, + SOCK_DGRAM, 0); +#if !defined(USE_POLL) && !defined(USE_KQUEUE) if (EXT(statp).nssocks[ns] > highestFD) { res_nclose(statp); errno = ENOTSOCK; } +#endif if (EXT(statp).nssocks[ns] < 0) { switch (errno) { case EPROTONOSUPPORT: @@ -825,8 +865,16 @@ send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, * socket operation, and select returns if the * error message is received. We can thus detect * the absence of a nameserver without timing out. + * + * When the option "insecure1" is specified, we'd + * rather expect to see responses from an "unknown" + * address. In order to let the kernel accept such + * responses, do not connect the socket here. + * XXX: or do we need an explicit option to disable + * connecting? */ - if (connect(EXT(statp).nssocks[ns], nsap, nsaplen) < 0) { + if (!(statp->options & RES_INSECURE1) && + _connect(EXT(statp).nssocks[ns], nsap, nsaplen) < 0) { Aerror(statp, stderr, "connect(dg)", errno, nsap, nsaplen); res_nclose(statp); @@ -838,13 +886,20 @@ send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, } s = EXT(statp).nssocks[ns]; #ifndef CANNOT_CONNECT_DGRAM - if (send(s, (const char*)buf, buflen, 0) != buflen) { + if (statp->options & RES_INSECURE1) { + if (_sendto(s, + (const char*)buf, buflen, 0, nsap, nsaplen) != buflen) { + Aerror(statp, stderr, "sendto", errno, nsap, nsaplen); + res_nclose(statp); + return (0); + } + } else if (send(s, (const char*)buf, buflen, 0) != buflen) { Perror(statp, stderr, "send", errno); res_nclose(statp); return (0); } #else /* !CANNOT_CONNECT_DGRAM */ - if (sendto(s, (const char*)buf, buflen, 0, nsap, nsaplen) != buflen) + if (_sendto(s, (const char*)buf, buflen, 0, nsap, nsaplen) != buflen) { Aerror(statp, stderr, "sendto", errno, nsap, nsaplen); res_nclose(statp); @@ -868,13 +923,18 @@ send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, now = evNowTime(); nonow: #ifndef USE_POLL - FD_ZERO(&dsmask); - FD_SET(s, &dsmask); if (evCmpTime(finish, now) > 0) timeout = evSubTime(finish, now); else timeout = evConsTime(0, 0); +#ifdef USE_KQUEUE + EV_SET(&kv, s, EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, 0); + n = _kevent(kq, &kv, 1, &kv, 1, &timeout); +#else + FD_ZERO(&dsmask); + FD_SET(s, &dsmask); n = pselect(s + 1, &dsmask, NULL, NULL, &timeout, NULL); +#endif #else timeout = evSubTime(finish, now); if (timeout.tv_sec < 0) @@ -894,17 +954,25 @@ send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, if (n < 0) { if (errno == EINTR) goto wait; +#ifdef USE_KQUEUE + Perror(statp, stderr, "kevent", errno); +#else #ifndef USE_POLL Perror(statp, stderr, "select", errno); #else Perror(statp, stderr, "poll", errno); #endif /* USE_POLL */ +#endif res_nclose(statp); return (0); } +#ifdef USE_KQUEUE + if (kv.ident != s) + goto wait; +#endif errno = 0; fromlen = sizeof(from); - resplen = recvfrom(s, (char*)ans, anssiz,0, + resplen = _recvfrom(s, (char*)ans, anssiz,0, (struct sockaddr *)&from, &fromlen); if (resplen <= 0) { Perror(statp, stderr, "recvfrom", errno); @@ -1067,7 +1135,7 @@ sock_eq(struct sockaddr *a, struct sockaddr *b) { } } -#if defined(NEED_PSELECT) && !defined(USE_POLL) +#if defined(NEED_PSELECT) && !defined(USE_POLL) && !defined(USE_KQUEUE) /* XXX needs to move to the porting library. */ static int pselect(int nfds, void *rfds, void *wfds, void *efds, diff --git a/lib/libc/resolv/res_state.c b/lib/libc/resolv/res_state.c new file mode 100644 index 0000000..59c9430 --- /dev/null +++ b/lib/libc/resolv/res_state.c @@ -0,0 +1,87 @@ +/*- + * Copyright (c) 2006 The FreeBSD Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/nameser.h> +#include <resolv.h> +#include <stdlib.h> + +#include "namespace.h" +#include "reentrant.h" +#include "un-namespace.h" + +#undef _res + +struct __res_state _res; + +static thread_key_t res_key; +static once_t res_init_once = ONCE_INITIALIZER; +static int res_thr_keycreated = 0; + +static void +free_res(void *ptr) +{ + res_state statp = ptr; + + if (statp->_u._ext.ext != NULL) + res_ndestroy(statp); + free(statp); +} + +static void +res_keycreate(void) +{ + res_thr_keycreated = thr_keycreate(&res_key, free_res) == 0; +} + +res_state +__res_state(void) +{ + res_state statp; + + if (thr_main() != 0) + return (&_res); + + if (thr_once(&res_init_once, res_keycreate) != 0 || + !res_thr_keycreated) + return (&_res); + + statp = thr_getspecific(res_key); + if (statp != NULL) + return (statp); + statp = calloc(1, sizeof(*statp)); + if (statp == NULL) + return (&_res); +#ifdef __BIND_RES_TEXT + statp->options = RES_TIMEOUT; /* Motorola, et al. */ +#endif + if (thr_setspecific(res_key, statp) == 0) + return (statp); + free(statp); + return (&_res); +} diff --git a/lib/libc/resolv/res_update.c b/lib/libc/resolv/res_update.c index 483e19d..174cdac 100644 --- a/lib/libc/resolv/res_update.c +++ b/lib/libc/resolv/res_update.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: res_update.c,v 1.12.18.1 2005/04/27 05:01:12 sra Exp $"; +static const char rcsid[] = "$Id: res_update.c,v 1.6.2.4.4.2 2004/03/16 12:34:20 marka Exp $"; #endif /* not lint */ /* @@ -19,12 +19,14 @@ static const char rcsid[] = "$Id: res_update.c,v 1.12.18.1 2005/04/27 05:01:12 s * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/*! \file - * \brief +/* * Based on the Dynamic DNS reference implementation by Viraj Bais - * <viraj_bais@ccm.fm.intel.com> + * <viraj_bais@ccm.fm.intel.com> */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include "port_before.h" #include <sys/param.h> @@ -50,7 +52,7 @@ static const char rcsid[] = "$Id: res_update.c,v 1.12.18.1 2005/04/27 05:01:12 s #include "port_after.h" #include "res_private.h" -/*% +/* * Separate a linked list of records into groups so that all records * in a group will belong to a single zone on the nameserver. * Create a dynamic update packet for each zone and send it to the @@ -167,10 +169,16 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { res_setservers(statp, zptr->z_nsaddrs, zptr->z_nscount); /* Send the update and remember the result. */ - if (key != NULL) + if (key != NULL) { +#ifdef _LIBC + DPRINTF(("TSIG is not supported\n")); + RES_SET_H_ERRNO(statp, NO_RECOVERY); + goto done; +#else n = res_nsendsigned(statp, packet, n, key, answer, sizeof answer); - else +#endif + } else n = res_nsend(statp, packet, n, answer, sizeof answer); if (n < 0) { DPRINTF(("res_nsend: send error, n=%d (%s)\n", |