diff options
Diffstat (limited to 'usr.sbin/bind/bin/rndc')
-rw-r--r-- | usr.sbin/bind/bin/rndc/rndc-confgen.8 | 2 | ||||
-rw-r--r-- | usr.sbin/bind/bin/rndc/rndc-confgen.c | 12 | ||||
-rw-r--r-- | usr.sbin/bind/bin/rndc/rndc-confgen.docbook | 2 | ||||
-rw-r--r-- | usr.sbin/bind/bin/rndc/rndc-confgen.html | 2 | ||||
-rw-r--r-- | usr.sbin/bind/bin/rndc/rndc.c | 109 |
5 files changed, 107 insertions, 20 deletions
diff --git a/usr.sbin/bind/bin/rndc/rndc-confgen.8 b/usr.sbin/bind/bin/rndc/rndc-confgen.8 index df1fb0d5f18..113708ba3be 100644 --- a/usr.sbin/bind/bin/rndc/rndc-confgen.8 +++ b/usr.sbin/bind/bin/rndc/rndc-confgen.8 @@ -13,7 +13,7 @@ .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION .\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.\" $ISC: rndc-confgen.8,v 1.3.2.2.4.2 2003/02/17 07:05:06 marka Exp $ +.\" $ISC: rndc-confgen.8,v 1.3.2.6 2003/10/09 07:32:35 marka Exp $ .TH "RNDC-CONFGEN" "8" "Aug 27, 2001" "BIND9" "" .SH NAME diff --git a/usr.sbin/bind/bin/rndc/rndc-confgen.c b/usr.sbin/bind/bin/rndc/rndc-confgen.c index 5ac27f03d13..383414009d3 100644 --- a/usr.sbin/bind/bin/rndc/rndc-confgen.c +++ b/usr.sbin/bind/bin/rndc/rndc-confgen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 Internet Software Consortium. + * Copyright (C) 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $ISC: rndc-confgen.c,v 1.9.2.4 2001/11/30 01:10:09 gson Exp $ */ +/* $ISC: rndc-confgen.c,v 1.9.2.6 2003/07/22 04:03:37 marka Exp $ */ #include <config.h> @@ -269,11 +269,8 @@ main(int argc, char **argv) { char *buf; len = strlen(chrootdir) + strlen(keyfile) + 2; buf = isc_mem_get(mctx, len); - if (buf == NULL) { - fprintf(stderr, "isc_mem_get(%d) failed\n", - len); - goto cleanup; - } + if (buf == NULL) + fatal("isc_mem_get(%d) failed\n", len); snprintf(buf, len, "%s/%s", chrootdir, keyfile); write_key_file(buf, user, keyname, &key_txtbuffer); @@ -315,7 +312,6 @@ options {\n\ serveraddr, port, serveraddr, keyname); } - cleanup: if (show_final_mem) isc_mem_stats(mctx, stderr); diff --git a/usr.sbin/bind/bin/rndc/rndc-confgen.docbook b/usr.sbin/bind/bin/rndc/rndc-confgen.docbook index c7a057006d3..5c9e7971198 100644 --- a/usr.sbin/bind/bin/rndc/rndc-confgen.docbook +++ b/usr.sbin/bind/bin/rndc/rndc-confgen.docbook @@ -16,7 +16,7 @@ - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --> -<!-- $ISC: rndc-confgen.docbook,v 1.3.8.1 2003/02/17 01:29:29 marka Exp $ --> +<!-- $ISC: rndc-confgen.docbook,v 1.3.2.1 2003/02/07 02:39:01 marka Exp $ --> <refentry> <refentryinfo> diff --git a/usr.sbin/bind/bin/rndc/rndc-confgen.html b/usr.sbin/bind/bin/rndc/rndc-confgen.html index e4278c48260..8c8c2762f22 100644 --- a/usr.sbin/bind/bin/rndc/rndc-confgen.html +++ b/usr.sbin/bind/bin/rndc/rndc-confgen.html @@ -15,7 +15,7 @@ - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --> -<!-- $ISC: rndc-confgen.html,v 1.3.2.2.4.2 2003/02/17 07:05:06 marka Exp $ --> +<!-- $ISC: rndc-confgen.html,v 1.3.2.6 2003/10/09 07:32:35 marka Exp $ --> <HTML ><HEAD diff --git a/usr.sbin/bind/bin/rndc/rndc.c b/usr.sbin/bind/bin/rndc/rndc.c index 212e2fae85f..d75d20e53c6 100644 --- a/usr.sbin/bind/bin/rndc/rndc.c +++ b/usr.sbin/bind/bin/rndc/rndc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001 Internet Software Consortium. + * Copyright (C) 2000, 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $ISC: rndc.c,v 1.77.2.2 2001/11/28 23:37:50 gson Exp $ */ +/* $ISC: rndc.c,v 1.77.2.5 2003/07/22 04:03:37 marka Exp $ */ /* * Principal Author: DCL @@ -86,6 +86,7 @@ static char *command; static char *args; static char program[256]; static isc_socket_t *sock = NULL; +static isc_uint32_t serial; static void usage(int status) { @@ -150,11 +151,25 @@ get_address(const char *host, in_port_t port, isc_sockaddr_t *sockaddr) { hints.ai_family = PF_INET; else if (isc_net_probeipv4() != ISC_R_SUCCESS) hints.ai_family = PF_INET6; - else + else { hints.ai_family = PF_UNSPEC; +#ifdef AI_ADDRCONFIG + hints.ai_flags = AI_ADDRCONFIG; +#endif + } hints.ai_socktype = SOCK_STREAM; isc_app_block(); +#ifdef AI_ADDRCONFIG + again: +#endif result = getaddrinfo(host, NULL, &hints, &res); +#ifdef AI_ADDRCONFIG + if (result == EAI_BADFLAGS && + (hints.ai_flags & AI_ADDRCONFIG) != 0) { + hints.ai_flags &= ~AI_ADDRCONFIG; + goto again; + } +#endif isc_app_unblock(); if (result != 0) fatal("Couldn't find server '%s': %s", @@ -244,6 +259,83 @@ rndc_recvdone(isc_task_t *task, isc_event_t *event) { } static void +rndc_recvnonce(isc_task_t *task, isc_event_t *event) { + isccc_sexpr_t *response = NULL; + isccc_sexpr_t *_ctrl; + isccc_region_t source; + isc_result_t result; + isc_uint32_t nonce; + isccc_sexpr_t *request = NULL; + isccc_time_t now; + isc_region_t r; + isccc_sexpr_t *data; + isccc_region_t message; + isc_uint32_t len; + isc_buffer_t b; + + recvs--; + + if (ccmsg.result == ISC_R_EOF) + fatal("connection to remote host closed\n" + "This may indicate that the remote server is using " + "an older version of \n" + "the command protocol, this host is not authorized " + "to connect,\nor the key is invalid."); + + if (ccmsg.result != ISC_R_SUCCESS) + fatal("recv failed: %s", isc_result_totext(ccmsg.result)); + + source.rstart = isc_buffer_base(&ccmsg.buffer); + source.rend = isc_buffer_used(&ccmsg.buffer); + + DO("parse message", isccc_cc_fromwire(&source, &response, &secret)); + + _ctrl = isccc_alist_lookup(response, "_ctrl"); + if (_ctrl == NULL) + fatal("_ctrl section missing"); + nonce = 0; + if (isccc_cc_lookupuint32(_ctrl, "_nonce", &nonce) != ISC_R_SUCCESS) + nonce = 0; + + isc_stdtime_get(&now); + + DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial, + now, now + 60, &request)); + data = isccc_alist_lookup(request, "_data"); + if (data == NULL) + fatal("_data section missing"); + if (isccc_cc_definestring(data, "type", args) == NULL) + fatal("out of memory"); + if (nonce != 0) { + _ctrl = isccc_alist_lookup(request, "_ctrl"); + if (_ctrl == NULL) + fatal("_ctrl section missing"); + if (isccc_cc_defineuint32(_ctrl, "_nonce", nonce) == NULL) + fatal("out of memory"); + } + message.rstart = databuf + 4; + message.rend = databuf + sizeof(databuf); + DO("render message", isccc_cc_towire(request, &message, &secret)); + len = sizeof(databuf) - REGION_SIZE(message); + isc_buffer_init(&b, databuf, 4); + isc_buffer_putuint32(&b, len - 4); + r.length = len; + r.base = databuf; + + isccc_ccmsg_cancelread(&ccmsg); + DO("schedule recv", isccc_ccmsg_readmessage(&ccmsg, task, + rndc_recvdone, NULL)); + recvs++; + DO("send message", isc_socket_send(sock, &r, task, rndc_senddone, + NULL)); + sends++; + + isc_event_free(&event); + isccc_sexpr_free(&response); + return; +} + +static void rndc_connected(isc_task_t *task, isc_event_t *event) { isc_socketevent_t *sevent = (isc_socketevent_t *)event; isccc_sexpr_t *request = NULL; @@ -252,7 +344,6 @@ rndc_connected(isc_task_t *task, isc_event_t *event) { isccc_region_t message; isc_region_t r; isc_uint32_t len; - isc_uint32_t serial; isc_buffer_t b; isc_result_t result; @@ -262,13 +353,12 @@ rndc_connected(isc_task_t *task, isc_event_t *event) { fatal("connect failed: %s", isc_result_totext(sevent->result)); isc_stdtime_get(&now); - isc_random_get(&serial); - DO("create message", isccc_cc_createmessage(1, NULL, NULL, serial, + DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial, now, now + 60, &request)); data = isccc_alist_lookup(request, "_data"); if (data == NULL) fatal("_data section missing"); - if (isccc_cc_definestring(data, "type", args) == NULL) + if (isccc_cc_definestring(data, "type", "null") == NULL) fatal("out of memory"); message.rstart = databuf + 4; message.rend = databuf + sizeof(databuf); @@ -283,13 +373,12 @@ rndc_connected(isc_task_t *task, isc_event_t *event) { isccc_ccmsg_setmaxsize(&ccmsg, 1024); DO("schedule recv", isccc_ccmsg_readmessage(&ccmsg, task, - rndc_recvdone, NULL)); + rndc_recvnonce, NULL)); recvs++; DO("send message", isc_socket_send(sock, &r, task, rndc_senddone, NULL)); sends++; isc_event_free(&event); - } static void @@ -538,6 +627,8 @@ main(int argc, char **argv) { if (argc < 1) usage(1); + isc_random_get(&serial); + DO("create memory context", isc_mem_create(0, 0, &mctx)); DO("create socket manager", isc_socketmgr_create(mctx, &socketmgr)); DO("create task manager", isc_taskmgr_create(mctx, 1, 0, &taskmgr)); |