aclconf.c revision c7e266b7e5675e12d1ca3cc929f24b3e86d41f8e
/*
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 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.
*/
/* $Id: aclconf.c,v 1.10 2007/09/12 01:09:08 each Exp $ */
#include <config.h>
#include <isccfg/namedconf.h>
#include <dns/fixedname.h>
void
}
void
{
}
}
/*
* Find the definition of the named acl whose name is "name".
*/
static isc_result_t
const cfg_listelt_t *elt;
if (result != ISC_R_SUCCESS)
return (result);
}
return (ISC_R_SUCCESS);
}
}
return (ISC_R_NOTFOUND);
}
static isc_result_t
{
/* Look for an already-converted version. */
{
"acl loop detected: %s", aclname);
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
}
/* Not yet converted. Convert now. */
if (result != ISC_R_SUCCESS) {
"undefined ACL '%s'", aclname);
return (result);
}
/*
* Add a loop detection element.
*/
nest_level, &dacl);
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
static isc_result_t
{
unsigned int keylen;
if (result != ISC_R_SUCCESS) {
"key name '%s' is not a valid domain name",
txtname);
return (result);
}
}
int nest_level,
{
const cfg_listelt_t *elt;
/*
* If target already points to an ACL, then we're being
* called recursively to configure a nested ACL. The
* nested ACL's contents should just be absorbed into its
* parent ACL.
*/
} else {
/*
* Need to allocate a new ACL structure. Count the items
* in the ACL definition and allocate space for that many
* elements (even though some or all of them may end up in
* the iptable instead of the element array).
*/
unsigned int element_count = 0;
if (cfg_obj_istuple(ce))
if (cfg_obj_isnetprefix(ce))
}
if (result != ISC_R_SUCCESS)
return (result);
}
{
if (cfg_obj_istuple(ce)) {
/* This must be a negated element. */
} else
/*
* If nest_level is nonzero, then every element is
* to be stored as a separate, nested ACL rather than
* merged into the main iptable.
*/
if (nest_level) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
if (cfg_obj_isnetprefix(ce)) {
/* Network prefix */
unsigned int bitlen;
if (result != ISC_R_SUCCESS)
goto cleanup;
continue;
} else if (cfg_obj_islist(ce)) {
/*
* If we're nesting ACLs, put the nested
* ACL onto the elements list; otherwise
* merge it into *this* ACL.
*/
if (nest_level == 0) {
&dacl);
} else {
nest_level - 1,
}
if (result != ISC_R_SUCCESS)
goto cleanup;
continue;
} else if (cfg_obj_isstring(ce)) {
/* ACL name */
/* iptable entry with zero bit length */
ISC_TRUE);
continue;
/* negated "any" */
continue;
} else {
if (result == ISC_R_SUCCESS) {
/* found it in acl definitions */
? (nest_level - 1)
: 0,
&inneracl);
}
if (result != ISC_R_SUCCESS)
goto cleanup;
if (nest_level) {
} else {
}
continue;
}
/* Key name */
if (result != ISC_R_SUCCESS)
goto cleanup;
} else {
"address match list contains "
"unsupported element type");
goto cleanup;
}
/*
* XXX each: This should only be reached for localhost,
* localnets and keyname elements -- probably should
* be refactored for clearer flow
*/
de++;
}
return (ISC_R_SUCCESS);
return (result);
}