nsupdate.c revision c110d61b173a68420d19858abb80285be0dc1120
/*
* Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*! \file */
#include <config.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <isc/commandline.h>
#include <isc/parseint.h>
#include <isc/sockaddr.h>
#include <isccfg/namedconf.h>
#include <dns/callbacks.h>
#include <dns/dispatch.h>
#include <dns/fixedname.h>
#include <dns/masterdump.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
#ifdef GSSAPI
#ifdef WIN32
#else
#include ISC_PLATFORM_KRB5HEADER
#endif
#endif
#include <bind9/getaddresses.h>
#if defined(HAVE_READLINE)
#include <readline/readline.h>
#endif
#ifdef HAVE_ADDRINFO
#ifdef HAVE_GETADDRINFO
#ifdef HAVE_GAISTRERROR
#define USE_GETADDRINFO
#endif
#endif
#endif
#ifndef USE_GETADDRINFO
#ifndef ISC_PLATFORM_NONSTDHERRNO
extern int h_errno;
#endif
#endif
#define FIND_TIMEOUT 5
#define DNSDEFAULTPORT 53
/* Number of addresses to request from bind9_getaddresses() */
#define MAX_SERVERADDRS 4
#ifndef RESOLV_CONF
#define RESOLV_CONF "/etc/resolv.conf"
#endif
static dns_fixedname_t fuserzone;
static dns_name_t tmpzonename;
static dns_name_t restart_master;
static lwres_conf_t *lwconf;
static int ns_inuse = 0;
static int master_inuse = 0;
static int ns_total = 0;
static int master_total = 0;
static const dns_master_style_t *style;
static int requests = 0;
static unsigned int logdebuglevel = 0;
static unsigned int timeout = 300;
static unsigned int udp_timeout = 3;
static unsigned int udp_retries = 3;
static isc_uint32_t default_ttl = 0;
typedef struct nsu_requestinfo {
static void
dns_request_t **request);
static void
ISC_PLATFORM_NORETURN_PRE static void
static void
static void
#ifdef GSSAPI
static dns_fixedname_t fkname;
static char servicename[DNS_NAME_FORMATSIZE];
static dns_name_t *keyname;
typedef struct nsu_gssinfo {
static void
static void
static void
#endif /* GSSAPI */
static void
#define STATUS_MORE (isc_uint16_t)0
typedef struct entropysource entropysource_t;
struct entropysource {
};
static void
if (result != ISC_R_SUCCESS)
fatal("could not create entropy object");
}
randomfile = NULL;
}
if (result != ISC_R_SUCCESS)
fatal("could not initialize entropy source: %s",
fatal("out of memory");
}
}
static void
while (!ISC_LIST_EMPTY(sources)) {
}
}
static void
master_from_servers(void) {
master_total * sizeof(isc_sockaddr_t));
}
static dns_rdataclass_t
getzoneclass(void) {
if (zoneclass == dns_rdataclass_none)
return (zoneclass);
}
static isc_boolean_t
if (zoneclass == dns_rdataclass_none ||
return (ISC_FALSE);
return (ISC_TRUE);
}
static void
exit(1);
}
static void
}
static void
if (debugging) {
}
}
static void
if (ddebugging) {
}
}
static inline void
if (result != ISC_R_SUCCESS)
}
static void *
}
static void
}
static char *
char *s;
const char *d;
return (NULL);
break;
}
if (dc == 0)
break;
}
for (s = string; *s != '\0'; s++) {
sc = *s;
*s++ = '\0';
*stringp = s;
return (string);
}
}
}
return (string);
}
static void
reset_system(void) {
ddebug("reset_system()");
/* If the update message is still around, destroy it */
else {
&updatemsg);
}
if (usegsstsig) {
}
}
static isc_uint16_t
isc_uint16_t digestbits = 0;
char buf[20];
fatal("digest-bits out of range [0..128]");
fatal("digest-bits out of range [0..160]");
fatal("digest-bits out of range [0..224]");
fatal("digest-bits out of range [0..256]");
fatal("digest-bits out of range [0..384]");
fatal("digest-bits out of range [0..512]");
} else
return (digestbits);
}
static int
basenamelen(const char *file) {
len -= 1;
len -= 8;
len -= 4;
return (len);
}
static void
setup_keystr(void) {
int secretlen;
char *secretstr;
char *s, *n;
char *name;
isc_uint16_t digestbits = 0;
debug("Creating key...");
fatal("key option must specify [hmac:]keyname:secret");
secretstr = s + 1;
if (n != NULL) {
if (n == secretstr || n[1] == 0)
fatal("key option must specify [hmac:]keyname:secret");
secretstr = n + 1;
} else {
n = s;
}
debug("namefromtext");
NULL);
fatal("out of memory");
if (result != ISC_R_SUCCESS) {
goto failure;
}
debug("keycreate");
&tsigkey);
if (result != ISC_R_SUCCESS)
else
}
/*
* Get a key from a named.conf format keyfile
*/
static isc_result_t
const char *mykeyname;
const char *secretstr;
const char *algorithm;
int len;
if (! isc_file_exists(keyfile))
return (ISC_R_FILENOTFOUND);
if (result != ISC_R_SUCCESS)
goto cleanup;
&sessionkey);
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
fatal("key must have algorithm and secret");
setup_keystr();
if (sessionkey != NULL)
}
return (result);
}
static void
debug("Creating key...");
/* Try reading the key from a K* pair */
&dstkey);
/* If that didn't work, try reading it as a session.key keyfile */
if (result != ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS)
return;
}
if (result != ISC_R_SUCCESS) {
return;
}
switch (dst_key_alg(dstkey)) {
case DST_ALG_HMACMD5:
break;
case DST_ALG_HMACSHA1:
break;
case DST_ALG_HMACSHA224:
break;
case DST_ALG_HMACSHA256:
break;
case DST_ALG_HMACSHA384:
break;
case DST_ALG_HMACSHA512:
break;
}
&tsigkey);
if (result != ISC_R_SUCCESS) {
return;
}
} else {
}
}
static void
doshutdown(void) {
/*
* The isc_mem_put of master_servers must be before the
* isc_mem_put of servers as it sets the servers pointer
* to NULL.
*/
master_total * sizeof(isc_sockaddr_t));
if (localaddr4 != NULL)
if (localaddr6 != NULL)
ddebug("Freeing TSIG key");
}
ddebug("Freeing SIG(0) key");
}
if (is_dst_up) {
ddebug("Destroy DST lib");
}
ddebug("Destroying request manager");
ddebug("Freeing the dispatchers");
if (have_ipv4)
if (have_ipv6)
ddebug("Shutting down dispatch manager");
}
static void
maybeshutdown(void) {
ddebug("Shutting down request manager");
if (requests != 0)
return;
doshutdown();
}
static void
ddebug("shutdown_program()");
}
static void
setup_system(void) {
int i;
ddebug("setup_system()");
result = isc_net_probeipv4();
if (result == ISC_R_SUCCESS)
result = isc_net_probeipv6();
if (result == ISC_R_SUCCESS)
fatal("could not find either IPv4 or IPv6");
if (lwresult != LWRES_R_SUCCESS)
fatal("lwres_context_create failed");
if (master_servers == servers)
}
ns_inuse = 0;
fatal("out of memory");
if (have_ipv4) {
}
if (have_ipv6) {
}
} else {
fatal("out of memory");
for (i = 0; i < ns_total; i++) {
{
} else {
}
}
}
if (have_ipv6) {
4, 2, 3, 5,
}
if (have_ipv4) {
4, 2, 3, 5,
}
setup_keystr();
else if (local_only) {
if (result != ISC_R_SUCCESS)
fatal("can't read key from %s: %s\n",
}
static void
{
int count;
if (result != ISC_R_SUCCESS)
fatal("couldn't get address for '%s': %s",
}
static void
version(void) {
}
#define PARSE_ARGS_FMT "dDML:y:ghlovk:p:Pr:R::t:Tu:V"
static void
int ch;
char buf[100];
switch (ch) {
case 'M': /* was -dm */
break;
case '?':
case 'h':
if (isc_commandline_option != '?')
argv[0], isc_commandline_option);
"[-g | -o | -y keyname:secret | -k keyfile] "
"[-v] [-V] [filename]\n");
exit(1);
case 'P':
for (t = 0xff00; t <= 0xfffe; t++) {
if (dns_rdatatype_ismeta(t))
continue;
}
break;
case 'T':
for (t = 1; t <= 0xfeff; t++) {
if (dns_rdatatype_ismeta(t))
continue;
}
break;
case 'V':
version();
break;
default:
break;
}
}
if (doexit)
exit(0);
}
static void
int ch;
isc_uint32_t i;
debug("parse_args");
switch (ch) {
case 'd':
break;
case 'D': /* was -dd */
break;
case 'M':
break;
case 'l':
break;
case 'L':
10);
if (result != ISC_R_SUCCESS) {
"'%s'\n", isc_commandline_argument);
exit(1);
}
logdebuglevel = i;
break;
case 'y':
break;
case 'v':
break;
case 'k':
break;
case 'g':
break;
case 'o':
break;
case 'p':
isc_commandline_argument, 10);
if (result != ISC_R_SUCCESS) {
"'%s'\n", isc_commandline_argument);
exit(1);
}
break;
case 't':
isc_commandline_argument, 10);
if (result != ISC_R_SUCCESS) {
exit(1);
}
if (timeout == 0)
break;
case 'u':
isc_commandline_argument, 10);
if (result != ISC_R_SUCCESS) {
exit(1);
}
if (udp_timeout == 0)
break;
case 'r':
isc_commandline_argument, 10);
if (result != ISC_R_SUCCESS) {
exit(1);
}
break;
case 'R':
break;
default:
argv[0], isc_commandline_option);
exit(1);
}
}
argv[0]);
exit(1);
}
#ifdef GSSAPI
argv[0]);
exit(1);
}
#else
if (usegsstsig) {
"program not linked with GSS API Library\n",
argv[0]);
exit(1);
}
#endif
} else {
"r", &input);
if (result != ISC_R_SUCCESS) {
exit(1);
}
}
}
}
static isc_uint16_t
char *word;
return (STATUS_SYNTAX);
}
return (STATUS_MORE);
}
static isc_uint16_t
{
isc_region_t r;
return (STATUS_MORE);
}
cmdline++;
if (*cmdline != 0) {
&callbacks);
if (result == ISC_R_SUCCESS) {
isc_buffer_usedregion(buf, &r);
isc_buffer_usedregion(newbuf, &r);
} else {
return (STATUS_SYNTAX);
}
} else {
}
return (STATUS_MORE);
}
static isc_uint16_t
char *word;
ddebug("make_prereq()");
/*
* Read the owner name
*/
if (retval != STATUS_MORE)
return (retval);
/*
* If this is an rrset prereq, read the class or type.
*/
if (isrrset) {
goto failure;
}
if (result == ISC_R_SUCCESS) {
if (!setzoneclass(rdataclass)) {
goto failure;
}
/*
* Now read the type.
*/
goto failure;
}
if (result != ISC_R_SUCCESS) {
goto failure;
}
} else {
rdataclass = getzoneclass();
if (result != ISC_R_SUCCESS) {
goto failure;
}
}
} else
if (isrrset && ispositive) {
if (retval != STATUS_MORE)
goto failure;
} else
if (ispositive) {
else
} else
return (STATUS_MORE);
return (STATUS_SYNTAX);
}
static isc_uint16_t
evaluate_prereq(char *cmdline) {
char *word;
ddebug("evaluate_prereq()");
return (STATUS_SYNTAX);
}
} else {
return (STATUS_SYNTAX);
}
}
static isc_uint16_t
evaluate_server(char *cmdline) {
long port;
if (local_only) {
return (STATUS_SYNTAX);
}
return (STATUS_SYNTAX);
}
else {
char *endp;
if (*endp != 0) {
return (STATUS_SYNTAX);
"(1 to 65535)\n", word);
return (STATUS_SYNTAX);
}
}
if (master_servers == servers)
}
ns_inuse = 0;
fatal("out of memory");
return (STATUS_MORE);
}
static isc_uint16_t
evaluate_local(char *cmdline) {
long port;
return (STATUS_SYNTAX);
}
port = 0;
else {
char *endp;
if (*endp != 0) {
return (STATUS_SYNTAX);
"(1 to 65535)\n", word);
return (STATUS_SYNTAX);
}
}
if (localaddr6 == NULL)
if (localaddr6 == NULL)
fatal("out of memory");
if (localaddr4 == NULL)
if (localaddr4 == NULL)
fatal("out of memory");
} else {
return (STATUS_SYNTAX);
}
return (STATUS_MORE);
}
static isc_uint16_t
evaluate_key(char *cmdline) {
char *namestr;
char *secretstr;
isc_buffer_t b;
int secretlen;
isc_uint16_t digestbits = 0;
char *n;
return (STATUS_SYNTAX);
}
if (n != NULL) {
namestr = n + 1;
} else
if (result != ISC_R_SUCCESS) {
return (STATUS_SYNTAX);
}
return (STATUS_SYNTAX);
}
fatal("out of memory");
if (result != ISC_R_SUCCESS) {
return (STATUS_SYNTAX);
}
&tsigkey);
if (result != ISC_R_SUCCESS) {
return (STATUS_SYNTAX);
}
return (STATUS_MORE);
}
static isc_uint16_t
evaluate_zone(char *cmdline) {
char *word;
isc_buffer_t b;
return (STATUS_SYNTAX);
}
if (result != ISC_R_SUCCESS) {
return (STATUS_SYNTAX);
}
return (STATUS_MORE);
}
static isc_uint16_t
evaluate_realm(char *cmdline) {
#ifdef GSSAPI
char *word;
char buf[1024];
int n;
}
return (STATUS_MORE);
fatal("realm is too long");
fatal("out of memory");
return (STATUS_MORE);
#else
return (STATUS_SYNTAX);
#endif
}
static isc_uint16_t
evaluate_ttl(char *cmdline) {
char *word;
return (STATUS_SYNTAX);
}
default_ttl = 0;
return (STATUS_MORE);
}
if (result != ISC_R_SUCCESS)
return (STATUS_SYNTAX);
return (STATUS_SYNTAX);
}
default_ttl = ttl;
return (STATUS_MORE);
}
static isc_uint16_t
evaluate_class(char *cmdline) {
char *word;
return (STATUS_SYNTAX);
}
if (result != ISC_R_SUCCESS) {
return (STATUS_SYNTAX);
}
switch (rdclass) {
case dns_rdataclass_none:
case dns_rdataclass_any:
case dns_rdataclass_reserved0:
return (STATUS_SYNTAX);
default:
}
return (STATUS_MORE);
}
static isc_uint16_t
char *word;
ddebug("update_addordelete()");
/*
* Read the owner name.
*/
if (retval != STATUS_MORE)
return (retval);
/*
* If this is an add, read the TTL and verify that it's in range.
* If it's a delete, ignore a TTL if present (for compatibility).
*/
if (!isdelete) {
goto failure;
}
else {
ttl = 0;
goto doneparsing;
}
}
if (result != ISC_R_SUCCESS) {
if (isdelete) {
ttl = 0;
goto parseclass;
} else if (default_ttl_set) {
ttl = default_ttl;
goto parseclass;
} else {
goto failure;
}
}
if (isdelete)
ttl = 0;
goto failure;
}
/*
* Read the class or type.
*/
if (isdelete) {
goto doneparsing;
} else {
goto failure;
}
}
if (!setzoneclass(rdataclass)) {
goto failure;
}
/*
* Now read the type.
*/
if (isdelete) {
goto doneparsing;
} else {
goto failure;
}
}
if (result != ISC_R_SUCCESS) {
goto failure;
}
} else {
rdataclass = getzoneclass();
if (result != ISC_R_SUCCESS) {
goto failure;
}
}
rdata);
if (retval != STATUS_MORE)
goto failure;
if (isdelete) {
else
} else {
goto failure;
}
}
if (!isdelete && checknames) {
ISC_TRUE))
{
char namebuf[DNS_NAME_FORMATSIZE];
namebuf);
goto failure;
}
char namebuf[DNS_NAME_FORMATSIZE];
namebuf);
goto failure;
}
}
return (STATUS_MORE);
return (STATUS_SYNTAX);
}
static isc_uint16_t
evaluate_update(char *cmdline) {
char *word;
ddebug("evaluate_update()");
return (STATUS_SYNTAX);
}
else {
return (STATUS_SYNTAX);
}
}
static isc_uint16_t
evaluate_checknames(char *cmdline) {
char *word;
ddebug("evaluate_checknames()");
return (STATUS_SYNTAX);
}
} else {
return (STATUS_SYNTAX);
}
return (STATUS_MORE);
}
static void
if (result == ISC_R_SUCCESS) {
}
}
}
}
static void
int bufsz;
ddebug("show_message()");
do {
"buffer to display message\n");
exit(1);
}
bufsz *= 2;
} while (result == ISC_R_NOSPACE);
if (result != ISC_R_SUCCESS) {
return;
}
}
static isc_uint16_t
do_next_command(char *cmdline) {
char *word;
ddebug("do_next_command()");
return (STATUS_SEND);
if (word[0] == ';')
return (STATUS_MORE);
return (STATUS_QUIT);
return (evaluate_prereq(cmdline));
return (evaluate_update(cmdline));
return (evaluate_server(cmdline));
return (evaluate_local(cmdline));
return (evaluate_zone(cmdline));
return (evaluate_class(cmdline));
return (STATUS_SEND);
if (debugging)
else
return (STATUS_MORE);
}
return (evaluate_ttl(cmdline));
return (STATUS_MORE);
}
return (STATUS_MORE);
}
return (evaluate_key(cmdline));
}
return (evaluate_realm(cmdline));
return (evaluate_checknames(cmdline));
#ifdef GSSAPI
#else
#endif
return (STATUS_MORE);
}
#ifdef GSSAPI
#else
#endif
return (STATUS_MORE);
}
"local address [port] (set local resolver)\n"
"server address [port] (set master server for zone)\n"
"send (send the update request)\n"
"show (show the update request)\n"
"answer (show the answer to the last request)\n"
"quit (quit, any pending update is not sent\n"
"help (display this message_\n"
"key [hmac:]keyname secret (use TSIG to sign the request)\n"
"gsstsig (use GSS_TSIG to sign the request)\n"
"oldgsstsig (use Microsoft's GSS_TSIG to sign the request)\n"
"zone name (set the zone to be updated)\n"
"class CLASS (set the zone's DNS class, e.g. IN (default), CH)\n"
"check-names { on | off } (enable / disable check-names)\n"
"[prereq] nxdomain name (does this name not exist)\n"
"[prereq] yxdomain name (does this name exist)\n"
"[prereq] nxrrset .... (does this RRset exist)\n"
"[prereq] yxrrset .... (does this RRset not exist)\n"
"[update] add .... (add the given record to the zone)\n"
"[update] del[ete] .... (remove the given record(s) from the zone)\n");
return (STATUS_MORE);
}
return (STATUS_MORE);
}
return (STATUS_SYNTAX);
}
static isc_uint16_t
get_next_command(void) {
char cmdlinebuf[MAXCMD];
char *cmdline;
if (interactive) {
#ifdef HAVE_READLINE
#else
#endif
} else
/*
* Normalize input by removing any eol as readline()
* removes eol but fgets doesn't.
*/
}
#ifdef HAVE_READLINE
if (interactive)
#endif
return (result);
}
static isc_boolean_t
user_interaction(void) {
ddebug("user_interaction()");
result = get_next_command();
fatal("syntax error");
}
if (result == STATUS_SEND)
return (ISC_TRUE);
return (ISC_FALSE);
}
static void
done_update(void) {
ddebug("done_update()");
}
static void
if (isc_buffer_remaininglength(b) < 1)
if (isc_buffer_remaininglength(b) < 1)
}
}
static isc_boolean_t
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
if (++master_inuse >= master_total)
return (ISC_FALSE);
return (ISC_TRUE);
}
static void
ddebug("update_completed()");
requests--;
if (shuttingdown) {
return;
}
goto done;
}
return;
}
switch (result) {
case ISC_R_SUCCESS:
if (answer->verify_attempted)
ddebug("tsig verification successful");
break;
case DNS_R_CLOCKSKEW:
case DNS_R_EXPECTEDTSIG:
case DNS_R_TSIGERRORSET:
case DNS_R_TSIGVERIFYFAILURE:
case DNS_R_UNEXPECTEDTSIG:
case ISC_R_FAILURE:
#if 0
/*
* For MS DNS that violates RFC 2845, section 4.2
*/
break;
}
#endif
break;
default:
}
if (!debugging) {
char buf[64];
isc_buffer_t b;
check_tsig_error(rds, &b);
(int)isc_buffer_usedlength(&b), buf);
}
}
if (debugging)
done:
if (usegsstsig) {
}
done_update();
}
static void
unsigned int options = DNS_REQUESTOPT_CASE;
ddebug("send_update()");
if (usevc)
}
if (debugging) {
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
}
else
/* Windows doesn't like the tsig name to be compressed. */
if (debugging)
requests++;
}
static void
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
fatal("could not reach any name server");
else
}
static void
int pass = 0;
unsigned int nlabels;
ddebug("recvsoa()");
requests--;
if (shuttingdown) {
return;
}
if (eresult != ISC_R_SUCCESS) {
return;
}
ddebug("About to create rcvmsg");
fatal("out of memory");
ddebug("retrying soa request without TSIG");
else
FIND_TIMEOUT * 20,
FIND_TIMEOUT, 3,
&request);
requests++;
return;
}
if (debugging)
fatal("response to SOA query was unsuccessful");
char namebuf[DNS_NAME_FORMATSIZE];
error("specified zone '%s' does not exist (NXDOMAIN)",
namebuf);
ddebug("Out of recvsoa");
done_update();
return;
}
if (pass == 0)
else if (pass == 1)
else
goto droplabel;
if (result != ISC_R_SUCCESS) {
pass++;
goto lookforsoa;
}
while (result == ISC_R_SUCCESS) {
&soaset);
if (result == ISC_R_SUCCESS)
break;
if (section == DNS_SECTION_ANSWER) {
&tset) == ISC_R_SUCCESS ||
&tset) == ISC_R_SUCCESS ) {
break;
}
}
}
pass++;
goto lookforsoa;
}
if (seencname)
goto droplabel;
if (debugging) {
char namestr[DNS_NAME_FORMATSIZE];
}
else
if (debugging) {
char namestr[DNS_NAME_FORMATSIZE];
}
if (default_servers) {
master_total * sizeof(isc_sockaddr_t));
if (master_servers == NULL)
fatal("out of memory");
master_inuse = 0;
} else
#ifdef GSSAPI
if (usegsstsig) {
} else {
}
#else
#endif
out:
ddebug("Out of recvsoa");
return;
if (nlabels == 1)
fatal("could not find enclosing zone");
goto out;
}
static void
{
fatal("out of memory");
else
requests++;
}
#ifdef GSSAPI
/*
* Get the realm from the users kerberos ticket if possible
*/
static void
char *name, *ticket_realm;
if (rc != 0)
return;
if (rc != 0) {
return;
}
if (rc != 0) {
return;
}
if (rc != 0) {
return;
}
if (ticket_realm != NULL) {
}
}
static void
isc_uint32_t val = 0;
char namestr[DNS_NAME_FORMATSIZE];
char mykeystr[DNS_NAME_FORMATSIZE];
char *err_message = NULL;
debug("start_gssrequest");
if (result != ISC_R_SUCCESS)
fatal("dns_tsigkeyring_create failed: %s",
fatal("out of memory");
}
else
if (result != ISC_R_SUCCESS)
fatal("isc_string_printf(servicename) failed: %s",
if (result != ISC_R_SUCCESS)
fatal("dns_name_fromtext(servname) failed: %s",
if (result != ISC_R_SUCCESS)
fatal("isc_string_printf(mykeystr) failed: %s",
if (result != ISC_R_SUCCESS)
fatal("dns_name_fromtext(keyname) failed: %s",
/* Windows doesn't recognize name compression in the key name. */
if (result != ISC_R_SUCCESS)
fatal("dns_message_create failed: %s",
/* Build first request. */
gmctx, &err_message);
if (result == ISC_R_FAILURE)
fatal("tkey query failed: %s",
if (result != ISC_R_SUCCESS)
fatal("dns_tkey_buildgssquery failed: %s",
}
static void
{
unsigned int options = 0;
debug("send_gssrequest");
fatal("out of memory");
else
if (debugging)
requests++;
}
static void
char *err_message = NULL;
ddebug("recvgss()");
requests--;
if (shuttingdown) {
return;
}
if (eresult != ISC_R_SUCCESS) {
return;
}
ddebug("recvgss creating rcvmsg");
if (debugging)
"recvmsg reply from GSS-TSIG query");
ddebug("recvgss trying %s GSS-TSIG",
if (use_win2k_gsstsig)
else
goto done;
}
fatal("response to GSS-TSIG query was unsuccessful");
&err_message);
switch (result) {
case DNS_R_CONTINUE:
break;
case ISC_R_SUCCESS:
/*
* XXXSRA Waaay too much fun here. There's no good
* reason why we need a TSIG here (the people who put
* it into the spec admitted at the time that it was
* not a security issue), and Windows clients don't
* seem to work if named complies with the spec and
* includes the gratuitous TSIG. So we're in the
* bizarre situation of having to choose between
* complying with a useless requirement in the spec
* and interoperating. This is nuts. If we can
* confirm this behavior, we should ask the WG to
* consider removing the requirement for the
* gratuitous TSIG here. For the moment, we ignore
* the TSIG -- this too is a spec violation, but it's
* the least insane thing to do.
*/
#if 0
/*
* Verify the signature.
*/
#endif /* 0 */
break;
default:
fatal("dns_tkey_negotiategss: %s %s",
}
done:
ddebug("Out of recvgss");
}
#endif
static void
start_update(void) {
ddebug("start_update()");
/*
* If we have both the zone and the servers we have enough information
* to send the update straight away otherwise we need to discover
* the zone and / or the master server.
*/
return;
}
&soaquery);
if (default_servers)
} else {
if (result == ISC_R_NOMORE) {
}
if (result != ISC_R_SUCCESS) {
done_update();
return;
}
/*
* Looks to see if the first name references a DS record
* and if that name is not the root remove a label as DS
* records live in the parent zone so we need to start our
* search one label up.
*/
if (section == DNS_SECTION_UPDATE &&
}
}
ns_inuse = 0;
}
static void
cleanup(void) {
ddebug("cleanup()");
#ifdef GSSAPI
}
ddebug("Detaching GSS-TSIG keyring");
}
}
}
#endif
ddebug("Shutting down task manager");
ddebug("Destroying event");
ddebug("Shutting down socket manager");
ddebug("Shutting down timer manager");
ddebug("Destroying hash context");
ddebug("Destroying name state");
ddebug("Removing log context");
ddebug("Destroying memory context");
if (memdebugging)
}
static void
if (shuttingdown) {
return;
}
if (global_event == NULL)
reset_system();
more = user_interaction();
if (!more) {
return;
}
start_update();
return;
}
int
setup_system();
(void)isc_app_run();
cleanup();
if (seenerror)
return (2);
else
return (0);
}