omapiconf.c revision 734ae1f7c6abafe1f1ca164aad7a3dd01ee82cbd
/*
* 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: omapiconf.c,v 1.17 2001/03/22 00:06:51 bwelling Exp $ */
/*
* Principal Author: DCL
*/
#include <config.h>
typedef struct ns_omapikey ns_omapikey_t;
struct ns_omapikey {
char *keyname;
};
typedef struct ns_omapilistener ns_omapilistener_t;
struct ns_omapilistener {
/* XXXDCL magic */
};
static ns_omapilistenerlist_t listeners;
static isc_mutex_t listeners_lock;
static void
initialize_mutex(void) {
}
static void
while (!ISC_LIST_EMPTY(*keylist)) {
}
}
static void
}
static void
}
void
if (exiting) {
/*
* When not exiting, this function is called from
* ns_omapi_configure(), which already holds the lock.
*/
if (ISC_LIST_EMPTY(listeners))
else
}
/*
* This is asynchronous. As listeners shut down, they will
* call listen_done().
*/
if (exiting)
}
static isc_boolean_t
int match;
return (ISC_FALSE);
else
return (ISC_TRUE);
}
static isc_boolean_t
{
return (ISC_TRUE);
}
return (ISC_FALSE);
}
static isc_result_t
const char *str;
{
break;
}
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
static isc_result_t
{
const char *str;
{
goto cleanup;
goto cleanup;
}
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
}
static isc_boolean_t
/*
* XXXDCL Ideally algorithm would be checked, too, but the current
* config API makes this moderately hard, and omapi will check it
* anyway.
*/
}
static isc_result_t
/*
* Create a generic object to be the manager for handling
* incoming server connections.
*/
if (result == ISC_R_SUCCESS)
/*
* Start listening for connections.
*/
return (result);
}
static void
char *keyid;
char secret[1024];
isc_buffer_t b;
/*
* Register the keys used by this listener. omapi_auth_deregister()
* is used to delete any existing key in case its secret or algorithm
* changed.
*
* XXXDCL but this means a little extra work overall when nothing
* changed. In fact, the same key will be register/deregistered/
* reregistered if it appears more than once in the controls statement.
*
* XXXDCL a separate problem is that keys that have been removed
* from the controls statement in a reconfiguration are not deleted
* until the server shuts down.
*/
{
/*
* XXXDCL confparser.y apparently allows any keyid
* in the list even if it has not been defined with
* the keys statement.
*/
if (result != ISC_R_SUCCESS)
"couldn't find key %s for use with "
else {
"unsupported algorithm '%s' in "
"key '%s' for use with command "
"channel %s",
continue;
}
if (result != ISC_R_SUCCESS) {
"secret for key '%s' on "
"command channel %s: %s",
continue;
}
isc_buffer_base(&b),
isc_buffer_usedlength(&b));
if (result != ISC_R_SUCCESS)
"couldn't register key '%s' for"
"use with command channel %s: %s",
}
}
}
static void
{
break;
return;
}
/*
* There is already a listener for this sockaddr.
* Update the access list and key information.
*
* First, keep the old access list unless a new one can be made.
*/
if (result == ISC_R_SUCCESS) {
} else
/* XXXDCL say the old acl is still used? */
"couldn't install new acl for "
"command channel %s: %s",
if (result != ISC_R_SUCCESS)
"couldn't install new keys for "
"command channel %s: %s",
else {
}
}
static void
{
if (result == ISC_R_SUCCESS) {
/*
* Make the acl.
*/
&new_acl);
}
if (result == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
"couldn't install new keys for "
"command channel %s: %s",
}
if (result == ISC_R_SUCCESS)
if (result == ISC_R_SUCCESS) {
"command channel listening on %s", socktext);
} else {
"couldn't add command channel %s: %s",
}
/* XXXDCL return error results? fail hard? */
}
{
char socktext[ISC_SOCKADDR_FORMATSIZE];
/*
* Get te list of named.conf 'controls' statements.
*/
/*
* Run through the new control channel list, noting sockets that
* are already being listened on and moving them to the new list.
*
* the underlying config code, or to the bind attempt getting an
* address-in-use error.
*/
if (controlslist != NULL) {
"no key statements for use by "
"control channels");
{
if (inetcontrols == NULL)
continue;
{
/*
* The parser handles BIND 8 configuration file
* syntax, so it allows unix phrases as well
* inet phrases with no keys{} clause.
*
* "unix" phrases have been reported as
* unsupported by the parser.
*
* The keylist == NULL case was already warned
* about a few lines above.
*/
if (isc_sockaddr_getport(addr) == 0)
sizeof(socktext));
if (cfg_obj_isvoid(obj)) {
"no keys clause in "
"control channel %s",
socktext);
continue;
}
"no keys specified in "
"control channel %s",
socktext);
continue;
}
continue;
ISC_LOG_DEBUG(9),
"processing control channel %s",
socktext);
/*
* Remove the listener from the old
* list, so it won't be shut down.
*/
link);
else
/*
* This is a new listener.
*/
socktext);
}
}
}
/*
* ns_omapi_shutdown() will stop whatever is on the global listeners
* list, which currently only has whatever sockaddr was in the previous
* configuration (if any) that does not remain in the current
* configuration.
*/
/*
* Put all of the valid listeners on the listeners list.
* Anything already on listeners in the process of shutting down
* will be taken care of by listen_done().
*/
return (ISC_R_SUCCESS);
}