diff options
author | ume <ume@FreeBSD.org> | 2006-03-30 20:15:53 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2006-03-30 20:15:53 +0000 |
commit | 3a893e11a7a11a71f7c387d15943b98cb1d40797 (patch) | |
tree | 301a2d20516db1ef585fb63207881444f480edae /lib/libc | |
parent | 19c7a1894198c99124d609f45f5c4fb3e5262143 (diff) | |
download | FreeBSD-src-3a893e11a7a11a71f7c387d15943b98cb1d40797.zip FreeBSD-src-3a893e11a7a11a71f7c387d15943b98cb1d40797.tar.gz |
Expose res_update and friends again. At least, ports/mail/spamilter
uses them.
Now, we have res_nupdate and res_nmkupdate as well, but they are
still based on our old resolver for binary backward compatibility.
So, they don't provide new features such as TSIG support.
Reported by: pointyhat via kris
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/Symbol.map | 8 | ||||
-rw-r--r-- | lib/libc/net/res_mkupdate.c | 15 | ||||
-rw-r--r-- | lib/libc/net/res_update.c | 44 | ||||
-rw-r--r-- | lib/libc/net/res_update.h | 75 | ||||
-rw-r--r-- | lib/libc/resolv/Symbol.map | 2 | ||||
-rw-r--r-- | lib/libc/resolv/res_data.c | 6 |
6 files changed, 33 insertions, 117 deletions
diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map index 1568907..c5e4866 100644 --- a/lib/libc/net/Symbol.map +++ b/lib/libc/net/Symbol.map @@ -90,10 +90,10 @@ FBSD_1.0 { iruserok_sa; rcmdsh; recv; - #__res_mkupdate; # Obsoleted - #__res_mkupdrec; # Obsoleted - #__res_freeupdrec; # Obsoleted - #res_update; # Obsoleted Why is this not __res_update? + __res_freeupdrec; + __res_mkupdrec; + __res_nmkupdate; + __res_nupdate; inet6_rthdr_space; inet6_rthdr_init; inet6_rthdr_add; diff --git a/lib/libc/net/res_mkupdate.c b/lib/libc/net/res_mkupdate.c index 29cb95a..ebcaba2 100644 --- a/lib/libc/net/res_mkupdate.c +++ b/lib/libc/net/res_mkupdate.c @@ -33,13 +33,13 @@ __FBSDID("$FreeBSD$"); #include <limits.h> #include <netdb.h> #include <resolv.h> +#include <res_update.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <ctype.h> -#include "res_update.h" #include "res_config.h" static int getnum_str(u_char **, u_char *); @@ -60,7 +60,7 @@ static int getword_str(char *, int, u_char **, u_char *); * -5 unknown operation or no records */ int -res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { +res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { ns_updrec *rrecp_start = rrecp_in; HEADER *hp; u_char *cp, *sp2, *startp, *endp; @@ -73,11 +73,6 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { u_int32_t n1, rttl; u_char *dnptrs[20], **dpp, **lastdnptr; - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); - return (-1); - } - /* * Initialize header fields. */ @@ -85,7 +80,7 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { return (-1); memset(buf, 0, HFIXEDSZ); hp = (HEADER *) buf; - hp->id = htons(++_res.id); + hp->id = htons(++statp->id); hp->opcode = ns_o_update; hp->rcode = NOERROR; cp = buf + HFIXEDSZ; @@ -137,7 +132,7 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { break; default: fprintf(stderr, - "res_mkupdate: incorrect opcode: %d\n", + "res_nmkupdate: incorrect opcode: %d\n", rrecp->r_opcode); fflush(stderr); return (-1); @@ -151,7 +146,7 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { break; default: fprintf(stderr, - "res_mkupdate: incorrect opcode: %d\n", + "res_nmkupdate: incorrect opcode: %d\n", rrecp->r_opcode); fflush(stderr); return (-1); diff --git a/lib/libc/net/res_update.c b/lib/libc/net/res_update.c index d78ca70..46f1efa 100644 --- a/lib/libc/net/res_update.c +++ b/lib/libc/net/res_update.c @@ -32,12 +32,11 @@ __FBSDID("$FreeBSD$"); #include <limits.h> #include <netdb.h> #include <resolv.h> +#include <res_update.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "res_update.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. @@ -71,7 +70,7 @@ struct zonegrp { int -res_update(ns_updrec *rrecp_in) { +res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { ns_updrec *rrecp, *tmprrecp; u_char buf[PACKETSZ], answer[PACKETSZ], packet[2*PACKETSZ]; char name[MAXDNAME], zname[MAXDNAME], primary[MAXDNAME], @@ -86,8 +85,9 @@ res_update(ns_updrec *rrecp_in) { u_int16_t dlen, class, qclass, type, qtype; u_int32_t ttl; - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { - RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); + if (key != NULL) { + /* TSIG is not supported. */ + RES_SET_H_ERRNO(statp, NO_RECOVERY); return (-1); } @@ -150,19 +150,19 @@ res_update(ns_updrec *rrecp_in) { } if (done) break; - n = res_mkquery(QUERY, dname, qclass, qtype, NULL, + n = res_nmkquery(statp, QUERY, dname, qclass, qtype, NULL, 0, NULL, buf, sizeof buf); if (n <= 0) { - fprintf(stderr, "res_update: mkquery failed\n"); + fprintf(stderr, "res_nupdate: mkquery failed\n"); return (n); } - n = res_send(buf, n, answer, sizeof answer); + n = res_nsend(statp, buf, n, answer, sizeof answer); if (n < 0) { - fprintf(stderr, "res_update: send error for %s\n", + fprintf(stderr, "res_nupdate: send error for %s\n", rrecp->r_dname); return (n); } else if (n > sizeof(answer)) { - fprintf(stderr, "res_update: buffer too small\n"); + fprintf(stderr, "res_nupdate: buffer too small\n"); return (-1); } if (n < HFIXEDSZ) @@ -447,7 +447,7 @@ ans=%d, auth=%d, add=%d, rcode=%d\n", } /* while */ } - _res.options |= RES_DEBUG; + statp->options |= RES_DEBUG; for (zptr = zgrp_start; zptr; zptr = zptr->z_next) { /* append zone section */ @@ -461,16 +461,16 @@ ans=%d, auth=%d, add=%d, rcode=%d\n", rrecp->r_grpnext = zptr->z_rr; zptr->z_rr = rrecp; - n = res_mkupdate(zptr->z_rr, packet, sizeof packet); + n = res_nmkupdate(statp, zptr->z_rr, packet, sizeof packet); if (n < 0) { - fprintf(stderr, "res_mkupdate error\n"); + fprintf(stderr, "res_nmkupdate error\n"); fflush(stderr); return (-1); } else - fprintf(stdout, "res_mkupdate: packet size = %d\n", n); + fprintf(stdout, "res_nmkupdate: packet size = %d\n", n); /* - * Override the list of NS records from res_init() with + * Override the list of NS records from res_ninit() with * the authoritative nameservers for the zone being updated. * Sort primary to be the first in the list of nameservers. */ @@ -493,18 +493,18 @@ ans=%d, auth=%d, add=%d, rcode=%d\n", } } for (i = 0; i < MAXNS; i++) { - _res.nsaddr_list[i].sin_addr = zptr->z_ns[i].nsaddr1; - _res.nsaddr_list[i].sin_family = AF_INET; - _res.nsaddr_list[i].sin_port = htons(NAMESERVER_PORT); + statp->nsaddr_list[i].sin_addr = zptr->z_ns[i].nsaddr1; + statp->nsaddr_list[i].sin_family = AF_INET; + statp->nsaddr_list[i].sin_port = htons(NAMESERVER_PORT); } - _res.nscount = (zptr->z_nscount < MAXNS) ? + statp->nscount = (zptr->z_nscount < MAXNS) ? zptr->z_nscount : MAXNS; - n = res_send(packet, n, answer, sizeof(answer)); + n = res_nsend(statp, packet, n, answer, sizeof(answer)); if (n < 0) { - fprintf(stderr, "res_send: send error, n=%d\n", n); + fprintf(stderr, "res_nsend: send error, n=%d\n", n); break; } else if (n > sizeof(answer)) { - fprintf(stderr, "res_send: buffer too small\n"); + fprintf(stderr, "res_nsend: buffer too small\n"); break; } numzones++; diff --git a/lib/libc/net/res_update.h b/lib/libc/net/res_update.h deleted file mode 100644 index a9528c0..0000000 --- a/lib/libc/net/res_update.h +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 1983, 1987, 1989, 1993 - * The Regents of the University of California. 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. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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$ */ - -#ifndef _RES_UPDATE_H_ -#define _RES_UPDATE_H_ - -/* - * This RR-like structure is particular to UPDATE. - */ -struct ns_updrec { - struct ns_updrec *r_prev; /* prev record */ - struct ns_updrec *r_next; /* next record */ - u_int8_t r_section; /* ZONE/PREREQUISITE/UPDATE */ - char * r_dname; /* owner of the RR */ - u_int16_t r_class; /* class number */ - u_int16_t r_type; /* type number */ - u_int32_t r_ttl; /* time to live */ - u_char * r_data; /* rdata fields as text string */ - u_int16_t r_size; /* size of r_data field */ - int r_opcode; /* type of operation */ - /* following fields for private use by the resolver/server routines */ - struct ns_updrec *r_grpnext; /* next record when grouped */ - struct databuf *r_dp; /* databuf to process */ - struct databuf *r_deldp; /* databuf's deleted/overwritten */ - u_int16_t r_zone; /* zone number on server */ -}; -typedef struct ns_updrec ns_updrec; - -#define res_freeupdrec __res_freeupdrec -#define res_mkupdate __res_mkupdate -#define res_mkupdrec __res_mkupdrec -#if 0 -#define res_update __res_update -#endif - -__BEGIN_DECLS -void res_freeupdrec(ns_updrec *); -int res_mkupdate(ns_updrec *, u_char *, int); -ns_updrec * res_mkupdrec(int, const char *, u_int, u_int, u_long); -int res_update(ns_updrec *); -__END_DECLS - -#endif /* _RES_UPDATE_H_ */ diff --git a/lib/libc/resolv/Symbol.map b/lib/libc/resolv/Symbol.map index 6e1de65..7aa2256 100644 --- a/lib/libc/resolv/Symbol.map +++ b/lib/libc/resolv/Symbol.map @@ -100,4 +100,6 @@ FBSD_1.0 { __res_close; _res_close; res_send; + __res_mkupdate; + res_update; # Why is this not __res_update? }; diff --git a/lib/libc/resolv/res_data.c b/lib/libc/resolv/res_data.c index a864b60..ab6d575 100644 --- a/lib/libc/resolv/res_data.c +++ b/lib/libc/resolv/res_data.c @@ -35,9 +35,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <netdb.h> #include <resolv.h> -#ifndef _LIBC #include <res_update.h> -#endif #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -156,7 +154,6 @@ res_mkquery(int op, /* opcode of query */ newrr_in, buf, buflen)); } -#ifndef _LIBC int res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { if ((_res.options & RES_INIT) == 0U && res_init() == -1) { @@ -166,7 +163,6 @@ res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { return (res_nmkupdate(&_res, rrecp_in, buf, buflen)); } -#endif int res_query(const char *name, /* domain name */ @@ -227,7 +223,6 @@ res_close(void) { res_nclose(&_res); } -#ifndef _LIBC int res_update(ns_updrec *rrecp_in) { if ((_res.options & RES_INIT) == 0U && res_init() == -1) { @@ -237,7 +232,6 @@ res_update(ns_updrec *rrecp_in) { return (res_nupdate(&_res, rrecp_in, NULL)); } -#endif int res_search(const char *name, /* domain name */ |