rndc.c revision 1d92d8a2456b23842a649b6104c60a9d6ea25333
/*
* Copyright (C) 2000, 2001 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM 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.
*/
/* $Id: rndc.c,v 1.44 2001/03/27 00:44:42 bwelling Exp $ */
/*
* Principal Author: DCL
*/
#include <config.h>
#include <stdlib.h>
#include <netdb.h>
#include <isc/commandline.h>
#ifdef HAVE_ADDRINFO
#ifdef HAVE_GETADDRINFO
#ifdef HAVE_GAISTRERROR
#define USE_GETADDRINFO
#endif
#endif
#endif
#ifndef USE_GETADDRINFO
extern int h_errno;
#endif
static const char *progname;
static unsigned int remoteport = NS_CONTROL_PORT;
static const char *servername = NULL;
static unsigned char databuf[2048];
static isccc_ccmsg_t ccmsg;
static char *args;
static isccc_region_t secret;
static isc_boolean_t verbose;
char *command;
static void
if (verbose) {
}
}
static void
usage(void) {
Usage: %s [-c config] [-s server] [-p port] [-y key] [-z zone] [-v view]\n\
command [command ...]\n\
\n\
command is one of the following:\n\
\n\
reload Reload configuration file and zones.\n\
reload zone [class [view]]\n\
Reload a single zone.\n\
refresh zone [class [view]]\n\
Schedule immediate maintenance for a zone.\n\
stats Write server statistics to the statistics file.\n\
querylog Toggle query logging.\n\
dumpdb Dump cache(s) to the dump file (named_dump.db).\n\
stop Save pending updates to master files and stop the server.\n\
halt Stop the server without saving pending updates.\n\
trace Increment debugging level by one.\n\
trace level Change the debugging level.\n\
notrace Set debugging level to 0.\n\
*status Display ps(1) status of named.\n\
*restart Restart the server.\n\
\n\
* == not yet implemented\n\
Version: %s\n",
}
static void
exit(1);
}
do { \
if (result != ISC_R_SUCCESS) { \
exit(1); \
} else \
} while (0)
static void
#ifdef USE_GETADDRINFO
int result;
#else
#endif
/*
* Assume we have v4 if we don't have v6, since setup_libs
* fatal()'s out if we don't have either.
*/
else {
#ifdef USE_GETADDRINFO
if (!have_ipv6)
else if (!have_ipv4)
else
if (result != 0)
fatal("Couldn't find server '%s': %s",
#else
fatal("Couldn't find server '%s' (h_errno=%d)",
port);
#endif
}
}
static void
}
static void
progname);
"This may indicate that the remote server is using "
"an older version of the\n"
"command protocol or this host is not authorized "
"to connect.\n");
exit(1);
}
fatal("no data section in response");
if (result == ISC_R_SUCCESS) {
}
else if (result != ISC_R_NOTFOUND)
}
static void
isc_region_t r;
isc_buffer_t b;
fatal("_data section missing");
fatal("out of memory");
rndc_recvdone, NULL));
NULL));
}
static void
isc_sockettype_tcp, &sock));
NULL));
}
int
const char *secretstr;
const char *algorithm;
char secretarray[1024];
char *p;
int ch;
int i;
progname++;
else
!= -1) {
switch (ch) {
case 'c':
break;
case 'M':
isc_mem_debugging = 1;
break;
case 'm':
break;
case 'p':
if (remoteport > 65535) {
progname);
exit(1);
}
break;
case 's':
break;
case 'V':
break;
case 'y':
break;
case '?':
usage();
exit(1);
break;
default:
exit(1);
break;
}
}
if (argc < 1) {
usage();
exit(1);
}
DO("creating log channel",
if (result != ISC_R_SUCCESS)
exit(1);
if (defserverobj != NULL)
}
if (servername == NULL) {
progname);
exit(1);
}
{
const char *name;
break;
}
}
/*
* Look for the name of the key to use.
*/
; /* Was set on command line, do nothing. */
&defkey));
} else {
progname);
exit(1);
}
/*
* Get the key's definition.
*/
{
keyname) == 0)
break;
}
progname);
exit(1);
}
exit(1);
}
/*
* similar to what the user might enter in interactive mode
* (if that were implemented).
*/
argslen = 0;
for (i = 0; i < argc; i++)
p = args;
for (i = 0; i < argc; i++) {
p += len;
*p++ = ' ';
}
p--;
*p++ = '\0';
isc_app_run();
if (show_final_mem)
if (failed)
return (1);
return (0);
}