omapiconf.c revision ce2be9b7211ab5bacaa10fe74ef35def3a3f6089
/*
* 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: omapiconf.c,v 1.5 2000/07/11 22:03:09 tale Exp $ */
/*
* Principal Author: DCL
*/
#include <config.h>
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
}
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
/*
* XXXDCL Ideally algorithm would be checked, too, but the current
* config API makes this moderately hard, and omapi will check it
* anyway.
*/
return (ISC_TRUE);
else
return (ISC_FALSE);
}
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 *socktext)
{
const 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.
*/
&keydef);
if (result != ISC_R_SUCCESS)
"couldn't find key %s for"
"use with command channel %s",
"unsupported algorithm %s in "
"key %s for use with "
"command channel %s",
socktext);
}
if (result == ISC_R_SUCCESS) {
&b);
}
"can't use secret for key %s on "
"command channel %s: %s",
} else if (result == ISC_R_SUCCESS)
isc_buffer_base(&b),
isc_buffer_usedlength(&b));
"couldn't register key %s for"
"use with command channel %s: %s",
}
}
static void
char *socktext)
{
/*
* 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",
/*
* Now update the key id list.
* XXXDCL the API for this seems incomplete. For now,
* I just reassign the pointer and set the control
* keyidlist to NULL so dns_c_ctrl_delete will not
* free it.
*/
break;
}
}
}
static void
{
if (result == ISC_R_SUCCESS) {
/*
* Make the acl.
*/
}
if (result == ISC_R_SUCCESS) {
/*
* Now update the key id list.
* XXXDCL the API for this seems incomplete. For now,
* I just reassign the pointer and set it to NULL so
* dns_c_ctrl_delete will not free it.
*/
}
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 a pointer to the named.conf ``controls'' statement information.
*/
/*
* 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 (result == ISC_R_SUCCESS) {
if (keydeflist == NULL)
"no key statements for use by "
"control channels");
if (keydeflist == NULL)
continue;
/*
* The only other type coming out of the
* configuration system is dns_c_unix_control.
*/
"unix control channel type is "
"not supported");
continue;
}
/*
* XXXDCL confparser.y currently allows the keys clause
* to be absent, which is pointless. it needs to be
* required.
*/
"missing keys clause for "
"control channel %s",
socktext);
continue;
}
"processing control channel %s",
socktext);
socktext);
/*
* Remove the listener from the old list,
* so it won't be shut down.
*/
else
/*
* This is a new listener.
*/
}
}
/*
* 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);
}