1999-12-16 23:11:07 +00:00
|
|
|
/*
|
2007-06-19 23:47:24 +00:00
|
|
|
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
2002-02-20 03:35:59 +00:00
|
|
|
* Copyright (C) 1999-2002 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2007-06-18 23:47:57 +00:00
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
1999-12-16 23:11:07 +00:00
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2004-03-05 05:14:21 +00:00
|
|
|
* 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.
|
1999-12-16 23:11:07 +00:00
|
|
|
*/
|
|
|
|
|
2007-11-19 23:13:28 +00:00
|
|
|
/* $Id: aclconf.c,v 1.15 2007/11/19 23:13:28 each Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-08-11 01:53:47 +00:00
|
|
|
#include <isc/mem.h>
|
2000-05-08 19:23:32 +00:00
|
|
|
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2002-01-04 02:32:16 +00:00
|
|
|
#include <isccfg/namedconf.h>
|
2005-01-11 03:46:11 +00:00
|
|
|
#include <isccfg/aclconf.h>
|
2002-01-04 02:32:16 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/acl.h>
|
2007-09-12 01:09:08 +00:00
|
|
|
#include <dns/iptable.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
#include <dns/fixedname.h>
|
2000-01-20 00:59:17 +00:00
|
|
|
#include <dns/log.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2005-03-16 03:34:45 +00:00
|
|
|
#define LOOP_MAGIC ISC_MAGIC('L','O','O','P')
|
2000-11-27 19:42:38 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
void
|
2005-01-11 03:46:11 +00:00
|
|
|
cfg_aclconfctx_init(cfg_aclconfctx_t *ctx) {
|
1999-12-16 23:11:07 +00:00
|
|
|
ISC_LIST_INIT(ctx->named_acl_cache);
|
|
|
|
}
|
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
void
|
2005-01-11 03:46:11 +00:00
|
|
|
cfg_aclconfctx_destroy(cfg_aclconfctx_t *ctx) {
|
2007-09-14 01:46:06 +00:00
|
|
|
dns_acl_t *dacl, *next;
|
2007-09-12 01:09:08 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache);
|
|
|
|
dacl != NULL;
|
|
|
|
dacl = next)
|
|
|
|
{
|
|
|
|
next = ISC_LIST_NEXT(dacl, nextincache);
|
|
|
|
dns_acl_detach(&dacl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
/*
|
|
|
|
* Find the definition of the named acl whose name is "name".
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2006-02-28 02:39:52 +00:00
|
|
|
get_acl_def(const cfg_obj_t *cctx, const char *name, const cfg_obj_t **ret) {
|
2001-03-04 21:21:39 +00:00
|
|
|
isc_result_t result;
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *acls = NULL;
|
|
|
|
const cfg_listelt_t *elt;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
result = cfg_map_get(cctx, "acl", &acls);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
for (elt = cfg_list_first(acls);
|
|
|
|
elt != NULL;
|
|
|
|
elt = cfg_list_next(elt)) {
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *acl = cfg_listelt_value(elt);
|
2001-03-04 21:21:39 +00:00
|
|
|
const char *aclname = cfg_obj_asstring(cfg_tuple_get(acl, "name"));
|
|
|
|
if (strcasecmp(aclname, name) == 0) {
|
2007-09-12 01:09:08 +00:00
|
|
|
if (ret != NULL) {
|
|
|
|
*ret = cfg_tuple_get(acl, "value");
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (ISC_R_NOTFOUND);
|
|
|
|
}
|
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
static isc_result_t
|
2006-02-28 02:39:52 +00:00
|
|
|
convert_named_acl(const cfg_obj_t *nameobj, const cfg_obj_t *cctx,
|
2005-01-11 03:46:11 +00:00
|
|
|
isc_log_t *lctx, cfg_aclconfctx_t *ctx,
|
2007-10-12 04:17:18 +00:00
|
|
|
isc_mem_t *mctx, unsigned int nest_level,
|
2007-09-14 01:46:06 +00:00
|
|
|
dns_acl_t **target)
|
1999-12-16 23:11:07 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *cacl = NULL;
|
1999-12-16 23:11:07 +00:00
|
|
|
dns_acl_t *dacl;
|
2005-03-16 03:34:45 +00:00
|
|
|
dns_acl_t loop;
|
2005-08-23 02:36:11 +00:00
|
|
|
const char *aclname = cfg_obj_asstring(nameobj);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
|
|
|
/* Look for an already-converted version. */
|
|
|
|
for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache);
|
|
|
|
dacl != NULL;
|
|
|
|
dacl = ISC_LIST_NEXT(dacl, nextincache))
|
|
|
|
{
|
2001-03-04 21:21:39 +00:00
|
|
|
if (strcasecmp(aclname, dacl->name) == 0) {
|
2005-03-16 03:34:45 +00:00
|
|
|
if (ISC_MAGIC_VALID(dacl, LOOP_MAGIC)) {
|
|
|
|
cfg_obj_log(nameobj, lctx, ISC_LOG_ERROR,
|
|
|
|
"acl loop detected: %s", aclname);
|
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
dns_acl_attach(dacl, target);
|
2000-08-11 02:11:20 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Not yet converted. Convert now. */
|
2001-03-04 21:21:39 +00:00
|
|
|
result = get_acl_def(cctx, aclname, &cacl);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-01-11 03:46:11 +00:00
|
|
|
cfg_obj_log(nameobj, lctx, ISC_LOG_WARNING,
|
2001-03-04 21:21:39 +00:00
|
|
|
"undefined ACL '%s'", aclname);
|
1999-12-16 23:11:07 +00:00
|
|
|
return (result);
|
|
|
|
}
|
2005-03-16 03:34:45 +00:00
|
|
|
/*
|
|
|
|
* Add a loop detection element.
|
|
|
|
*/
|
|
|
|
memset(&loop, 0, sizeof(loop));
|
|
|
|
ISC_LINK_INIT(&loop, nextincache);
|
2005-08-23 02:36:11 +00:00
|
|
|
DE_CONST(aclname, loop.name);
|
2005-03-16 03:34:45 +00:00
|
|
|
loop.magic = LOOP_MAGIC;
|
|
|
|
ISC_LIST_APPEND(ctx->named_acl_cache, &loop, nextincache);
|
2007-09-12 01:09:08 +00:00
|
|
|
result = cfg_acl_fromconfig(cacl, cctx, lctx, ctx, mctx,
|
2007-09-14 01:46:06 +00:00
|
|
|
nest_level, &dacl);
|
2005-03-16 03:34:45 +00:00
|
|
|
ISC_LIST_UNLINK(ctx->named_acl_cache, &loop, nextincache);
|
|
|
|
loop.magic = 0;
|
|
|
|
loop.name = NULL;
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-12-16 23:11:07 +00:00
|
|
|
return (result);
|
2000-08-11 01:53:47 +00:00
|
|
|
dacl->name = isc_mem_strdup(dacl->mctx, aclname);
|
2000-08-11 02:11:20 +00:00
|
|
|
if (dacl->name == NULL)
|
|
|
|
return (ISC_R_NOMEMORY);
|
1999-12-16 23:11:07 +00:00
|
|
|
ISC_LIST_APPEND(ctx->named_acl_cache, dacl, nextincache);
|
|
|
|
dns_acl_attach(dacl, target);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2006-02-28 02:39:52 +00:00
|
|
|
convert_keyname(const cfg_obj_t *keyobj, isc_log_t *lctx, isc_mem_t *mctx,
|
2005-01-11 03:46:11 +00:00
|
|
|
dns_name_t *dnsname)
|
|
|
|
{
|
1999-12-16 23:11:07 +00:00
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t buf;
|
|
|
|
dns_fixedname_t fixname;
|
|
|
|
unsigned int keylen;
|
2001-03-04 21:21:39 +00:00
|
|
|
const char *txtname = cfg_obj_asstring(keyobj);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
|
|
|
keylen = strlen(txtname);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&buf, txtname, keylen);
|
1999-12-16 23:11:07 +00:00
|
|
|
isc_buffer_add(&buf, keylen);
|
|
|
|
dns_fixedname_init(&fixname);
|
|
|
|
result = dns_name_fromtext(dns_fixedname_name(&fixname), &buf,
|
|
|
|
dns_rootname, ISC_FALSE, NULL);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2005-01-11 03:46:11 +00:00
|
|
|
cfg_obj_log(keyobj, lctx, ISC_LOG_WARNING,
|
2001-03-04 21:21:39 +00:00
|
|
|
"key name '%s' is not a valid domain name",
|
|
|
|
txtname);
|
1999-12-16 23:11:07 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
return (dns_name_dup(dns_fixedname_name(&fixname), mctx, dnsname));
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
isc_result_t
|
2006-02-28 02:39:52 +00:00
|
|
|
cfg_acl_fromconfig(const cfg_obj_t *caml,
|
|
|
|
const cfg_obj_t *cctx,
|
2007-09-14 01:46:06 +00:00
|
|
|
isc_log_t *lctx,
|
2005-01-11 03:46:11 +00:00
|
|
|
cfg_aclconfctx_t *ctx,
|
|
|
|
isc_mem_t *mctx,
|
2007-10-12 04:17:18 +00:00
|
|
|
unsigned int nest_level,
|
2005-01-11 03:46:11 +00:00
|
|
|
dns_acl_t **target)
|
1999-12-16 23:11:07 +00:00
|
|
|
{
|
|
|
|
isc_result_t result;
|
2007-09-12 01:09:08 +00:00
|
|
|
dns_acl_t *dacl = NULL, *inneracl = NULL;
|
1999-12-16 23:11:07 +00:00
|
|
|
dns_aclelement_t *de;
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_listelt_t *elt;
|
2007-09-14 01:46:06 +00:00
|
|
|
dns_iptable_t *iptab;
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2007-09-12 01:09:08 +00:00
|
|
|
REQUIRE(target != NULL);
|
2007-09-14 01:46:06 +00:00
|
|
|
REQUIRE(*target == NULL || DNS_ACL_VALID(*target));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2007-09-14 01:46:06 +00:00
|
|
|
if (*target != NULL) {
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-10-12 04:17:18 +00:00
|
|
|
dns_acl_attach(*target, &dacl);
|
|
|
|
dns_acl_detach(target);
|
2007-09-14 01:46:06 +00:00
|
|
|
} 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).
|
|
|
|
*/
|
2007-10-12 04:17:18 +00:00
|
|
|
isc_boolean_t recurse = ISC_TF(nest_level == 0);
|
|
|
|
result = dns_acl_create(mctx,
|
|
|
|
cfg_list_length(caml, recurse),
|
|
|
|
&dacl);
|
2007-09-14 01:46:06 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
de = dacl->elements;
|
2001-03-04 21:21:39 +00:00
|
|
|
for (elt = cfg_list_first(caml);
|
|
|
|
elt != NULL;
|
|
|
|
elt = cfg_list_next(elt))
|
1999-12-16 23:11:07 +00:00
|
|
|
{
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *ce = cfg_listelt_value(elt);
|
2007-09-12 01:09:08 +00:00
|
|
|
isc_boolean_t neg;
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (cfg_obj_istuple(ce)) {
|
|
|
|
/* This must be a negated element. */
|
|
|
|
ce = cfg_tuple_get(ce, "value");
|
2007-09-12 01:09:08 +00:00
|
|
|
neg = ISC_TRUE;
|
|
|
|
} else
|
|
|
|
neg = ISC_FALSE;
|
|
|
|
|
2007-09-14 01:46:06 +00:00
|
|
|
/*
|
|
|
|
* If nest_level is nonzero, then every element is
|
|
|
|
* to be stored as a separate, nested ACL rather than
|
|
|
|
* merged into the main iptable.
|
|
|
|
*/
|
|
|
|
iptab = dacl->iptable;
|
2007-10-12 04:17:18 +00:00
|
|
|
|
|
|
|
if (nest_level != 0) {
|
|
|
|
result = dns_acl_create(mctx,
|
|
|
|
cfg_list_length(ce, ISC_FALSE),
|
2007-09-14 01:46:06 +00:00
|
|
|
&de->nestedacl);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
iptab = de->nestedacl->iptable;
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
if (cfg_obj_isnetprefix(ce)) {
|
|
|
|
/* Network prefix */
|
2007-09-14 01:46:06 +00:00
|
|
|
isc_netaddr_t addr;
|
|
|
|
unsigned int bitlen;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2007-09-14 01:46:06 +00:00
|
|
|
cfg_obj_asnetprefix(ce, &addr, &bitlen);
|
2007-10-18 05:42:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If nesting ACLs (nest_level != 0), we negate
|
|
|
|
* the nestedacl element, not the iptable entry
|
|
|
|
*/
|
2007-09-14 01:46:06 +00:00
|
|
|
result = dns_iptable_addprefix(iptab, &addr, bitlen,
|
2007-10-18 05:42:03 +00:00
|
|
|
ISC_TF(nest_level != 0 || !neg));
|
1999-12-16 23:11:07 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2007-09-14 01:46:06 +00:00
|
|
|
|
2007-10-12 04:17:18 +00:00
|
|
|
if (nest_level != 0) {
|
2007-09-14 01:46:06 +00:00
|
|
|
de->type = dns_aclelementtype_nestedacl;
|
|
|
|
de->negative = neg;
|
|
|
|
} else
|
|
|
|
continue;
|
2001-03-04 21:21:39 +00:00
|
|
|
} else if (cfg_obj_islist(ce)) {
|
2007-09-14 01:46:06 +00:00
|
|
|
/*
|
|
|
|
* If we're nesting ACLs, put the nested
|
|
|
|
* ACL onto the elements list; otherwise
|
|
|
|
* merge it into *this* ACL.
|
|
|
|
*/
|
|
|
|
if (nest_level == 0) {
|
2007-10-19 00:28:20 +00:00
|
|
|
if (inneracl != NULL)
|
|
|
|
dns_acl_detach(&inneracl);
|
|
|
|
|
|
|
|
result = cfg_acl_fromconfig(ce, cctx, lctx,
|
|
|
|
ctx, mctx, 0,
|
|
|
|
&inneracl);
|
2007-09-14 01:46:06 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2007-10-19 00:28:20 +00:00
|
|
|
|
|
|
|
dns_acl_merge(dacl, inneracl,
|
|
|
|
ISC_TF(!neg));
|
|
|
|
dns_acl_detach(&inneracl);
|
2007-09-14 01:46:06 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
2007-09-12 01:09:08 +00:00
|
|
|
de->type = dns_aclelementtype_nestedacl;
|
2007-09-14 01:46:06 +00:00
|
|
|
de->negative = neg;
|
2007-10-19 00:28:20 +00:00
|
|
|
result = cfg_acl_fromconfig(ce, cctx, lctx,
|
|
|
|
ctx, mctx,
|
|
|
|
nest_level - 1,
|
|
|
|
&de->nestedacl);
|
2007-09-14 01:46:06 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
/* Fall through */
|
|
|
|
}
|
|
|
|
} else if (cfg_obj_istype(ce, &cfg_type_keyref)) {
|
|
|
|
/* Key name */
|
|
|
|
de->type = dns_aclelementtype_keyname;
|
|
|
|
de->negative = neg;
|
|
|
|
dns_name_init(&de->keyname, NULL);
|
|
|
|
result = convert_keyname(ce, lctx, mctx,
|
|
|
|
&de->keyname);
|
1999-12-16 23:11:07 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
2007-09-14 01:46:06 +00:00
|
|
|
goto cleanup;
|
2001-03-04 21:21:39 +00:00
|
|
|
} else if (cfg_obj_isstring(ce)) {
|
|
|
|
/* ACL name */
|
2005-08-23 02:36:11 +00:00
|
|
|
const char *name = cfg_obj_asstring(ce);
|
2007-09-14 01:46:06 +00:00
|
|
|
if (strcasecmp(name, "any") == 0) {
|
|
|
|
/* iptable entry with zero bit length */
|
2007-11-19 23:13:28 +00:00
|
|
|
result = dns_iptable_addprefix(iptab, NULL, 0,
|
|
|
|
ISC_TF(nest_level != 0 || !neg));
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (nest_level != 0) {
|
|
|
|
de->type = dns_aclelementtype_nestedacl;
|
|
|
|
de->negative = neg;
|
|
|
|
} else
|
|
|
|
continue;
|
2007-09-12 01:09:08 +00:00
|
|
|
} else if (strcasecmp(name, "none") == 0) {
|
2007-09-14 01:46:06 +00:00
|
|
|
/* negated "any" */
|
2007-11-19 23:13:28 +00:00
|
|
|
result = dns_iptable_addprefix(iptab, NULL, 0,
|
|
|
|
ISC_TF(nest_level != 0 || neg));
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (nest_level != 0) {
|
|
|
|
de->type = dns_aclelementtype_nestedacl;
|
|
|
|
de->negative = !neg;
|
|
|
|
} else
|
|
|
|
continue;
|
2007-09-12 01:09:08 +00:00
|
|
|
} else if (strcasecmp(name, "localhost") == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
de->type = dns_aclelementtype_localhost;
|
2007-09-14 01:46:06 +00:00
|
|
|
de->negative = neg;
|
2001-03-04 21:21:39 +00:00
|
|
|
} else if (strcasecmp(name, "localnets") == 0) {
|
|
|
|
de->type = dns_aclelementtype_localnets;
|
2007-09-14 01:46:06 +00:00
|
|
|
de->negative = neg;
|
2001-03-04 21:21:39 +00:00
|
|
|
} else {
|
2007-09-12 01:09:08 +00:00
|
|
|
result = get_acl_def(cctx, name, NULL);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
/* found it in acl definitions */
|
2007-10-12 04:17:18 +00:00
|
|
|
if (inneracl != NULL)
|
|
|
|
dns_acl_detach(&inneracl);
|
2007-09-12 01:09:08 +00:00
|
|
|
result = convert_named_acl(ce, cctx,
|
|
|
|
lctx, ctx, mctx,
|
2007-10-12 04:17:18 +00:00
|
|
|
(nest_level != 0)
|
2007-09-14 01:46:06 +00:00
|
|
|
? (nest_level - 1)
|
|
|
|
: 0,
|
|
|
|
&inneracl);
|
2007-09-12 01:09:08 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2007-09-12 01:09:08 +00:00
|
|
|
|
2007-10-12 04:17:18 +00:00
|
|
|
if (nest_level != 0) {
|
|
|
|
de->type = dns_aclelementtype_nestedacl;
|
2007-09-14 01:46:06 +00:00
|
|
|
de->negative = neg;
|
2007-10-12 04:17:18 +00:00
|
|
|
if(de->nestedacl != NULL)
|
|
|
|
dns_acl_detach(&de->nestedacl);
|
|
|
|
dns_acl_attach(inneracl,
|
|
|
|
&de->nestedacl);
|
|
|
|
dns_acl_detach(&inneracl);
|
|
|
|
/* Fall through */
|
2007-09-14 01:46:06 +00:00
|
|
|
} else {
|
|
|
|
dns_acl_merge(dacl, inneracl,
|
|
|
|
ISC_TF(!neg));
|
|
|
|
dns_acl_detach(&inneracl);
|
2007-10-12 04:17:18 +00:00
|
|
|
continue;
|
2007-09-14 01:46:06 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
|
|
|
} else {
|
2005-01-11 03:46:11 +00:00
|
|
|
cfg_obj_log(ce, lctx, ISC_LOG_WARNING,
|
2001-03-04 21:21:39 +00:00
|
|
|
"address match list contains "
|
|
|
|
"unsupported element type");
|
1999-12-16 23:11:07 +00:00
|
|
|
result = ISC_R_FAILURE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2007-09-12 01:09:08 +00:00
|
|
|
|
2007-09-14 01:46:06 +00:00
|
|
|
/*
|
|
|
|
* This should only be reached for localhost, localnets
|
|
|
|
* and keyname elements, and nested ACLs if nest_level is
|
|
|
|
* nonzero (i.e., in sortlists).
|
|
|
|
*/
|
2007-10-12 04:17:18 +00:00
|
|
|
if (de->nestedacl != NULL &&
|
|
|
|
de->type != dns_aclelementtype_nestedacl)
|
2007-09-14 01:46:06 +00:00
|
|
|
dns_acl_detach(&de->nestedacl);
|
|
|
|
|
|
|
|
dacl->node_count++;
|
|
|
|
de->node_num = dacl->node_count;
|
2007-09-12 01:09:08 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
de++;
|
|
|
|
dacl->length++;
|
2007-09-14 01:46:06 +00:00
|
|
|
INSIST(dacl->length <= dacl->alloc);
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2007-10-12 04:17:18 +00:00
|
|
|
dns_acl_attach(dacl, target);
|
|
|
|
result = ISC_R_SUCCESS;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-12-16 23:11:07 +00:00
|
|
|
cleanup:
|
2007-10-12 04:17:18 +00:00
|
|
|
if (inneracl != NULL)
|
|
|
|
dns_acl_detach(&inneracl);
|
1999-12-16 23:11:07 +00:00
|
|
|
dns_acl_detach(&dacl);
|
|
|
|
return (result);
|
|
|
|
}
|