rndc.c revision 6dc32b43da2c7af5bf460a45a17d03226c162c91
/*
* Copyright (C) 2000 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.29 2000/11/25 03:27:54 mws Exp $ */
/*
* Principal Author: DCL
*/
#include <config.h>
#include <stdlib.h>
#include <isc/commandline.h>
static const char *progname;
static isc_boolean_t verbose;
typedef struct ndc_object {
} ndc_object_t;
static ndc_object_t ndc_g_ndc;
static omapi_objecttype_t *ndc_type;
static void
if (verbose) {
}
}
/*
* Send a control command to the server.
*/
static isc_result_t
/*
* Create a new message object to store the information that will
* be sent to the server.
*/
if (result != ISC_R_SUCCESS)
return (result);
/*
* Specify the OPEN operation, with the UPDATE option if requested.
*/
if (result == ISC_R_SUCCESS)
/*
* Tell the server the type of the object being opened; it needs
* to know this so that it can apply the proper object methods
*/
if (result == ISC_R_SUCCESS)
/*
* Associate the ndc object with the message, so that it will have its
* values stuffed in the message. Without it, the OPEN operation will
* up the desired object at the server; this is true even though the
* particular object being accessed on the server does not need a key
* to be found.
*
* This object will also have its signal handler called with a
* "status" signal that sends the result of the operation on the
* server.
*/
if (result == ISC_R_SUCCESS)
(omapi_object_t *)&ndc_g_ndc);
/*
* Create a generic object to be the outer object for ndc_g_ndc, to
* handle the job of storing the command and stuffing it into the
* message.
*
* XXXDCL provide API so client does not need to refer to the
* outer member -- does not even need to know about how the whole
*/
if (result == ISC_R_SUCCESS)
/*
* Set the command being sent.
*/
if (result == ISC_R_SUCCESS) {
/*
* Add the new message to the list of known messages. When the
* server's response comes back, the client will verify that
* the response was for a message it really sent.
*/
/*
* Deliver the message to the server and await its
* response.
*/
}
/*
* Free the generic object and the message.
*/
return (result);
}
/*
* The signal handler gets the "status" signals when the server's response
* is processed. It also gets the "updated" signal after all the values
* from the server have been incorporated via ndc_setvalue.
*/
static isc_result_t
/*
* "status" is signalled with the result of the message's
* operation.
*/
}
}
/*
* Even if the waitresult was not ISC_R_SUCCESS, the processing
* by the function still was.
*/
/*
* Nothing to do, really.
*/
} else {
/*
* Pass any unknown signal any internal object.
* (This normally does not happen; there is no
* inner object, nor anything else being signalled.)
*/
}
return (result);
}
static isc_result_t
{
/*
isc_result_t result;
char *message;
*/
return (ISC_R_SUCCESS);
}
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 for named:\n\
\n\
*status Display ps(1) status of named.\n\
*dumpdb Dump database and cache to /var/tmp/named_dump.db.\n\
reload Reload configuration file and zones.\n\
refresh Refresh zone data, reloading if necessary.\n\
stats Dump statistics to statistics file.\n\
*trace Increment debugging level by one.\n\
*notrace Set debugging level to 0.\n\
*querylog Toggle query logging.\n\
*stop Stop the server.\n\
*restart Restart the server.\n\
\n\
* == not yet implemented\n\
Version: %s\n",
}
do { \
if (result != ISC_R_SUCCESS) { \
exit(1); \
} else \
} while (0)
int
char secret[1024];
const char *servername = NULL;
unsigned int port = NS_OMAPI_PORT;
unsigned int algorithm;
int ch;
int len;
progname++;
else
!= -1) {
switch (ch) {
case 'c':
break;
case 'M':
isc_mem_debugging = 1;
break;
case 'm':
break;
case 'p':
if (port > 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);
}
/* XXXDCL probably should use ISC_ENTROPY_GOOD. talk with graff. */
DO("initialize digital signatures",
if (servername != NULL)
else {
progname);
exit(1);
}
/*
* Look for the name of the key to use.
*/
; /* Was set on command line, do nothing. */
&keyname));
else if (configopts != NULL)
DO("get default key",
else {
progname);
exit(1);
}
/*
* Get the key's definition.
*/
/* XXX need methods for structure access? */
else {
exit(1);
}
DO("decode base64 secret",
host = servername;
DO("register omapi object",
ndc_setvalue, /* setvalue */
NULL, /* getvalue */
NULL, /* destroy */
NULL, /* stuffvalues */
NULL, /* lookup */
NULL, /* create */
NULL)); /* remove */
/*
* Initialize the static ndc_g_ndc variable (normally this is done
* by omapi_object_create on a dynamic variable).
*/
DO("register local authenticator",
NULL));
DO("send remote authenticator",
/*
* Preload the waitresult as successful.
*/
result == ISC_R_SUCCESS &&
/* Skip leading white space. */
/* Extract command */
if (len == 0) {
exit(1);
}
char omapiargs[DNS_NAME_MAXTEXT];
if (argc > 0) {
argc--;
argv++;
}
if (argc > 0) {
argc--;
argv++;
}
omapiargs[0]=0;
}
}
}
char omapiargs[DNS_NAME_MAXTEXT];
if (argc > 0) {
argc--;
argv++;
}
if (argc > 0) {
argc--;
argv++;
}
omapiargs[0]=0;
}
}
}
} else {
}
if (result == ISC_R_NOTIMPLEMENTED)
else if (result != ISC_R_SUCCESS)
else
printf("%s: %s command successful\n",
}
notify("command loop done");
/*
* Close the connection and wait to be disconnected. The connection
* is only still open if the protocol object is still attached
* to the omapimgr.
*/
/*
* Free the protocol manager.
*/
}
if (show_final_mem)
}
exit(1);
return (0);
}