From patchwork Sat Dec 1 20:13:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 30512 Received: (qmail 111870 invoked by alias); 1 Dec 2018 20:14:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 110543 invoked by uid 89); 1 Dec 2018 20:14:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Things, prints X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] resolv: Remove pfcode field in resolver state Date: Sat, 01 Dec 2018 21:13:55 +0100 Message-ID: <875zwdm2d8.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This was only ever used by dig, and dig never used libresolv from glibc. fp_nquery, fp_query, and p_query are removed from . Their compatibility implementation only prints an error message. 2018-12-01 Florian Weimer * resolv/resolv.h (RES_PRF_STATS, RES_PRF_UPDATE, RES_PRF_CLASS) (RES_PRF_CMD, RES_PRF_QUES, RES_PRF_ANS, RES_PRF_AUTH) (RES_PRF_ADD, RES_PRF_HEAD1, RES_PRF_HEAD2, RES_PRF_TTLID) (RES_PRF_HEADX, RES_PRF_QUERY, RES_PRF_REPLY, RES_PRF_INIT): Remove definition. (fp_nquery, fp_query, p_query): Remove declarations. * include/resolv.h (__fp_nquery, __fp_query): Remove hidden declaration. * resolv/bits/types/res_state.h (struct __res_state): Rename pfcode field to __glibc_reserved1. * resolv/res_debug.c (res_opcodes): Only define for compatibility purposes. (p_section, fp_nquery, fp_query, p_query): Remove. (fp_query_not_implemented): New function. (__fp_nquery, __fp_query, __p_query): New compatibility functions. * resolv/res_send.c (send_dg): Do not examine pfcode field. * resolv/resolv_conf.c (update_from_conf): Clear __glibc_reserved1 instead of pfcode field. diff --git a/NEWS b/NEWS index 8483dcf492..30b9d8975a 100644 --- a/NEWS +++ b/NEWS @@ -57,6 +57,10 @@ Deprecated and removed features, and other changes affecting compatibility: used by the Linux kernel. This affects the size and layout of those structures. +* The pfcode field of struct res_state and the functions fp_nquery, + fp_query, and p_query have been removed. Printing of DNS queries is no + longer support. + Changes to build and runtime requirements: * Python 3.4 or later is required to build the GNU C Library. diff --git a/include/resolv.h b/include/resolv.h index daf4a74777..801357dcb3 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -59,8 +59,6 @@ libresolv_hidden_proto (__p_rcode) libresolv_hidden_proto (__p_class) libresolv_hidden_proto (__p_type) libresolv_hidden_proto (__loc_ntoa) -libresolv_hidden_proto (__fp_nquery) -libresolv_hidden_proto (__fp_query) libresolv_hidden_proto (__res_nameinquery) libresolv_hidden_proto (__res_queriesmatch) libresolv_hidden_proto (__b64_ntop) diff --git a/resolv/bits/types/res_state.h b/resolv/bits/types/res_state.h index 2544a627f6..061c98d72e 100644 --- a/resolv/bits/types/res_state.h +++ b/resolv/bits/types/res_state.h @@ -21,7 +21,7 @@ struct __res_state { /* 2 byte hole here. */ char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ char defdname[256]; /* default domain (deprecated) */ - unsigned long pfcode; /* RES_PRF_ flags - see below. */ + unsigned long int __glibc_reserved1; unsigned ndots:4; /* threshold for initial abs. query */ unsigned nsort:4; /* number of elements in sort_list[] */ unsigned ipv6_unavail:1; /* connecting to IPv6 server failed */ diff --git a/resolv/res_debug.c b/resolv/res_debug.c index 7681ad4639..0c8056a679 100644 --- a/resolv/res_debug.c +++ b/resolv/res_debug.c @@ -120,9 +120,6 @@ extern const char *_res_sectioncodes[] attribute_hidden; /* _res_opcodes was exported by accident as a variable. */ #if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_26) static const char *res_opcodes[] = -#else -static const char res_opcodes[][9] = -#endif { "QUERY", "IQUERY", @@ -141,12 +138,9 @@ static const char res_opcodes[][9] = "ZONEINIT", "ZONEREF", }; -#if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_26) strong_alias (res_opcodes, _res_opcodes) #endif -static const char *p_section(int section, int opcode); - /* * Print the current options. */ @@ -161,174 +155,34 @@ fp_resstat(const res_state statp, FILE *file) { putc('\n', file); } +#if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_29) static void -do_section (int pfcode, ns_msg *handle, ns_sect section, int pflag, FILE *file) +fp_query_not_implemented (FILE *file) { - int n, sflag, rrnum; - static int buflen = 2048; - char *buf; - ns_opcode opcode; - ns_rr rr; - - /* - * Print answer records. - */ - sflag = (pfcode & pflag); - if (pfcode && !sflag) - return; - - buf = malloc(buflen); - if (buf == NULL) { - fprintf(file, ";; memory allocation failure\n"); - return; - } - - opcode = (ns_opcode) ns_msg_getflag(*handle, ns_f_opcode); - rrnum = 0; - for (;;) { - if (ns_parserr(handle, section, rrnum, &rr)) { - if (errno != ENODEV) - fprintf(file, ";; ns_parserr: %s\n", - strerror(errno)); - else if (rrnum > 0 && sflag != 0 && - (pfcode & RES_PRF_HEAD1)) - putc('\n', file); - goto cleanup; - } - if (rrnum == 0 && sflag != 0 && (pfcode & RES_PRF_HEAD1)) - fprintf(file, ";; %s SECTION:\n", - p_section(section, opcode)); - if (section == ns_s_qd) - fprintf(file, ";;\t%s, type = %s, class = %s\n", - ns_rr_name(rr), - p_type(ns_rr_type(rr)), - p_class(ns_rr_class(rr))); - else { - n = ns_sprintrr(handle, &rr, NULL, NULL, - buf, buflen); - if (n < 0) { - if (errno == ENOSPC) { - free(buf); - buf = NULL; - if (buflen < 131072) - buf = malloc(buflen += 1024); - if (buf == NULL) { - fprintf(file, - ";; memory allocation failure\n"); - return; - } - continue; - } - fprintf(file, ";; ns_sprintrr: %s\n", - strerror(errno)); - goto cleanup; - } - fputs(buf, file); - fputc('\n', file); - } - rrnum++; - } - cleanup: - free(buf); + fputs (";; DNS query printing: not implemented\n", file); } -/* - * Print the contents of a query. - * This is intended to be primarily a debugging routine. - */ void -fp_nquery (const unsigned char *msg, int len, FILE *file) +__fp_nquery (const unsigned char *msg, int len, FILE *file) { - ns_msg handle; - int qdcount, ancount, nscount, arcount; - u_int opcode, rcode, id; - - /* There is no need to initialize _res: If _res is not yet - initialized, _res.pfcode is zero. But initialization will - leave it at zero, too. _res.pfcode is an unsigned long, - but the code here assumes that the flags fit into an int, - so use that. */ - int pfcode = _res.pfcode; - - if (ns_initparse(msg, len, &handle) < 0) { - fprintf(file, ";; ns_initparse: %s\n", strerror(errno)); - return; - } - opcode = ns_msg_getflag(handle, ns_f_opcode); - rcode = ns_msg_getflag(handle, ns_f_rcode); - id = ns_msg_id(handle); - qdcount = ns_msg_count(handle, ns_s_qd); - ancount = ns_msg_count(handle, ns_s_an); - nscount = ns_msg_count(handle, ns_s_ns); - arcount = ns_msg_count(handle, ns_s_ar); - - /* - * Print header fields. - */ - if ((!pfcode) || (pfcode & RES_PRF_HEADX) || rcode) - fprintf(file, - ";; ->>HEADER<<- opcode: %s, status: %s, id: %d\n", - res_opcodes[opcode], p_rcode(rcode), id); - if ((!pfcode) || (pfcode & RES_PRF_HEADX)) - putc(';', file); - if ((!pfcode) || (pfcode & RES_PRF_HEAD2)) { - fprintf(file, "; flags:"); - if (ns_msg_getflag(handle, ns_f_qr)) - fprintf(file, " qr"); - if (ns_msg_getflag(handle, ns_f_aa)) - fprintf(file, " aa"); - if (ns_msg_getflag(handle, ns_f_tc)) - fprintf(file, " tc"); - if (ns_msg_getflag(handle, ns_f_rd)) - fprintf(file, " rd"); - if (ns_msg_getflag(handle, ns_f_ra)) - fprintf(file, " ra"); - if (ns_msg_getflag(handle, ns_f_z)) - fprintf(file, " ??"); - if (ns_msg_getflag(handle, ns_f_ad)) - fprintf(file, " ad"); - if (ns_msg_getflag(handle, ns_f_cd)) - fprintf(file, " cd"); - } - if ((!pfcode) || (pfcode & RES_PRF_HEAD1)) { - fprintf(file, "; %s: %d", - p_section(ns_s_qd, opcode), qdcount); - fprintf(file, ", %s: %d", - p_section(ns_s_an, opcode), ancount); - fprintf(file, ", %s: %d", - p_section(ns_s_ns, opcode), nscount); - fprintf(file, ", %s: %d", - p_section(ns_s_ar, opcode), arcount); - } - if ((!pfcode) || (pfcode & - (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) { - putc('\n',file); - } - /* - * Print the various sections. - */ - do_section (pfcode, &handle, ns_s_qd, RES_PRF_QUES, file); - do_section (pfcode, &handle, ns_s_an, RES_PRF_ANS, file); - do_section (pfcode, &handle, ns_s_ns, RES_PRF_AUTH, file); - do_section (pfcode, &handle, ns_s_ar, RES_PRF_ADD, file); - if (qdcount == 0 && ancount == 0 && - nscount == 0 && arcount == 0) - putc('\n', file); + fp_query_not_implemented (file); } -libresolv_hidden_def (fp_nquery) +compat_symbol (libresolv, __fp_nquery, __fp_nquery, GLIBC_2_0); void -fp_query (const unsigned char *msg, FILE *file) +__fp_query (const unsigned char *msg, FILE *file) { - fp_nquery (msg, PACKETSZ, file); + fp_query_not_implemented (file); } -libresolv_hidden_def (fp_query) +compat_symbol (libresolv, __fp_query, __fp_query, GLIBC_2_0); void -p_query (const unsigned char *msg) +__p_query (const unsigned char *msg) { - fp_query (msg, stdout); + fp_query_not_implemented (stdout); } +compat_symbol (libresolv, __p_query, __p_query, GLIBC_2_0); +#endif const u_char * p_cdnname(const u_char *cp, const u_char *msg, int len, FILE *file) { @@ -561,24 +415,6 @@ p_type(int type) { } libresolv_hidden_def (p_type) -/* - * Return a string for the type. - */ -static const char * -p_section(int section, int opcode) { - const struct res_sym *symbols; - - switch (opcode) { - case ns_o_update: - symbols = __p_update_section_syms; - break; - default: - symbols = __p_default_section_syms; - break; - } - return (sym_ntos(symbols, section, (int *)0)); -} - /* * Return a mnemonic for class. */ diff --git a/resolv/res_send.c b/resolv/res_send.c index 947ebf5212..47e9de1f5b 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -1358,10 +1358,7 @@ send_dg(res_state statp, goto wait; } - /* don't retry if called from dig */ - if (!statp->pfcode) - return close_and_return_error (statp, resplen2); - __res_iclose(statp, false); + return close_and_return_error (statp, resplen2); } if (anhp->rcode == NOERROR && anhp->ancount == 0 && anhp->aa == 0 && anhp->ra == 0 && anhp->arcount == 0) { diff --git a/resolv/resolv.h b/resolv/resolv.h index 80a523e5e4..eff86cd456 100644 --- a/resolv/resolv.h +++ b/resolv/resolv.h @@ -138,36 +138,13 @@ struct res_sym { #define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH) -/* - * Resolver "pfcode" values. Used by dig. - */ -#define RES_PRF_STATS 0x00000001 -#define RES_PRF_UPDATE 0x00000002 -#define RES_PRF_CLASS 0x00000004 -#define RES_PRF_CMD 0x00000008 -#define RES_PRF_QUES 0x00000010 -#define RES_PRF_ANS 0x00000020 -#define RES_PRF_AUTH 0x00000040 -#define RES_PRF_ADD 0x00000080 -#define RES_PRF_HEAD1 0x00000100 -#define RES_PRF_HEAD2 0x00000200 -#define RES_PRF_TTLID 0x00000400 -#define RES_PRF_HEADX 0x00000800 -#define RES_PRF_QUERY 0x00001000 -#define RES_PRF_REPLY 0x00002000 -#define RES_PRF_INIT 0x00004000 -/* 0x00008000 */ - /* Things involving an internal (static) resolver context. */ __BEGIN_DECLS extern struct __res_state *__res_state(void) __attribute__ ((__const__)); __END_DECLS #define _res (*__res_state()) -#define fp_nquery __fp_nquery -#define fp_query __fp_query #define hostalias __hostalias -#define p_query __p_query #define res_close __res_close #define res_init __res_init #define res_isourserver __res_isourserver @@ -178,10 +155,7 @@ __END_DECLS #define res_send __res_send __BEGIN_DECLS -void fp_nquery (const unsigned char *, int, FILE *) __THROW; -void fp_query (const unsigned char *, FILE *) __THROW; const char * hostalias (const char *) __THROW; -void p_query (const unsigned char *) __THROW; void res_close (void) __THROW; int res_init (void) __THROW; int res_isourserver (const struct sockaddr_in *) __THROW; diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c index 2f0ffbc524..6fb3dc76fa 100644 --- a/resolv/resolv_conf.c +++ b/resolv/resolv_conf.c @@ -486,7 +486,7 @@ static __attribute__ ((nonnull (1, 2), warn_unused_result)) bool update_from_conf (struct __res_state *resp, const struct resolv_conf *conf) { resp->defdname[0] = '\0'; - resp->pfcode = 0; + resp->__glibc_reserved1 = 0; resp->_vcsock = -1; resp->_flags = 0; resp->ipv6_unavail = false;