1999-12-16 23:11:07 +00:00
|
|
|
/*
|
2013-03-01 10:39:29 +11:00
|
|
|
* Copyright (C) 2004-2013 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
|
|
|
*/
|
|
|
|
|
2012-03-08 00:21:15 +11:00
|
|
|
/* $Id$ */
|
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
|
|
|
|
2013-02-27 17:19:39 -08:00
|
|
|
#ifdef HAVE_GEOIP
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#endif /* HAVE_GEOIP */
|
|
|
|
|
2008-05-21 23:47:01 +00:00
|
|
|
#define LOOP_MAGIC ISC_MAGIC('L','O','O','P')
|
2000-11-27 19:42:38 +00:00
|
|
|
|
2011-06-17 07:05:02 +00:00
|
|
|
isc_result_t
|
|
|
|
cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
|
|
|
|
isc_result_t result;
|
|
|
|
cfg_aclconfctx_t *actx;
|
|
|
|
|
|
|
|
REQUIRE(mctx != NULL);
|
|
|
|
REQUIRE(ret != NULL && *ret == NULL);
|
|
|
|
|
|
|
|
actx = isc_mem_get(mctx, sizeof(*actx));
|
|
|
|
if (actx == NULL)
|
|
|
|
return (ISC_R_NOMEMORY);
|
|
|
|
|
|
|
|
result = isc_refcount_init(&actx->references, 1);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
actx->mctx = NULL;
|
|
|
|
isc_mem_attach(mctx, &actx->mctx);
|
|
|
|
ISC_LIST_INIT(actx->named_acl_cache);
|
|
|
|
|
2013-02-27 17:19:39 -08:00
|
|
|
actx->geoip = NULL;
|
|
|
|
|
2011-06-17 07:05:02 +00:00
|
|
|
*ret = actx;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
isc_mem_put(mctx, actx, sizeof(*actx));
|
|
|
|
return (result);
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
void
|
2011-06-17 07:05:02 +00:00
|
|
|
cfg_aclconfctx_attach(cfg_aclconfctx_t *src, cfg_aclconfctx_t **dest) {
|
|
|
|
REQUIRE(src != NULL);
|
|
|
|
REQUIRE(dest != NULL && *dest == NULL);
|
2007-09-12 01:09:08 +00:00
|
|
|
|
2011-06-17 07:05:02 +00:00
|
|
|
isc_refcount_increment(&src->references, NULL);
|
|
|
|
*dest = src;
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2010-08-11 18:14:20 +00:00
|
|
|
void
|
2011-06-17 07:05:02 +00:00
|
|
|
cfg_aclconfctx_detach(cfg_aclconfctx_t **actxp) {
|
|
|
|
cfg_aclconfctx_t *actx;
|
2010-08-11 18:14:20 +00:00
|
|
|
dns_acl_t *dacl, *next;
|
2011-06-17 07:05:02 +00:00
|
|
|
unsigned int refs;
|
|
|
|
|
|
|
|
REQUIRE(actxp != NULL && *actxp != NULL);
|
|
|
|
|
|
|
|
actx = *actxp;
|
|
|
|
|
|
|
|
isc_refcount_decrement(&actx->references, &refs);
|
|
|
|
if (refs == 0) {
|
|
|
|
for (dacl = ISC_LIST_HEAD(actx->named_acl_cache);
|
|
|
|
dacl != NULL;
|
|
|
|
dacl = next)
|
|
|
|
{
|
|
|
|
next = ISC_LIST_NEXT(dacl, nextincache);
|
|
|
|
ISC_LIST_UNLINK(actx->named_acl_cache, dacl,
|
|
|
|
nextincache);
|
|
|
|
dns_acl_detach(&dacl);
|
|
|
|
}
|
|
|
|
isc_mem_putanddetach(&actx->mctx, actx, sizeof(*actx));
|
2010-08-11 18:14:20 +00:00
|
|
|
}
|
2011-06-17 07:05:02 +00:00
|
|
|
|
|
|
|
*actxp = NULL;
|
2010-08-11 18:14:20 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2008-05-21 23:47:01 +00:00
|
|
|
|
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);
|
2012-12-08 12:48:57 +11:00
|
|
|
isc_buffer_constinit(&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,
|
2009-09-01 00:22:28 +00:00
|
|
|
dns_rootname, 0, NULL);
|
1999-12-16 23:11:07 +00:00
|
|
|
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
|
|
|
|
2008-10-24 02:28:55 +00:00
|
|
|
/*
|
|
|
|
* Recursively pre-parse an ACL definition to find the total number
|
|
|
|
* of non-IP-prefix elements (localhost, localnets, key) in all nested
|
|
|
|
* ACLs, so that the parent will have enough space allocated for the
|
|
|
|
* elements table after all the nested ACLs have been merged in to the
|
|
|
|
* parent.
|
|
|
|
*/
|
|
|
|
static int
|
2009-10-01 04:06:37 +00:00
|
|
|
count_acl_elements(const cfg_obj_t *caml, const cfg_obj_t *cctx,
|
|
|
|
isc_boolean_t *has_negative)
|
2008-10-24 02:28:55 +00:00
|
|
|
{
|
|
|
|
const cfg_listelt_t *elt;
|
|
|
|
const cfg_obj_t *cacl = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
int n = 0;
|
|
|
|
|
2009-10-01 04:06:37 +00:00
|
|
|
if (has_negative != NULL)
|
|
|
|
*has_negative = ISC_FALSE;
|
|
|
|
|
2008-10-24 02:28:55 +00:00
|
|
|
for (elt = cfg_list_first(caml);
|
|
|
|
elt != NULL;
|
|
|
|
elt = cfg_list_next(elt)) {
|
|
|
|
const cfg_obj_t *ce = cfg_listelt_value(elt);
|
|
|
|
|
2013-02-27 17:19:39 -08:00
|
|
|
/* might be a negated element, in which case get the value. */
|
2009-10-01 04:06:37 +00:00
|
|
|
if (cfg_obj_istuple(ce)) {
|
2013-02-27 17:19:39 -08:00
|
|
|
const cfg_obj_t *negated =
|
|
|
|
cfg_tuple_get(ce, "negated");
|
|
|
|
if (! cfg_obj_isvoid(negated)) {
|
|
|
|
ce = negated;
|
|
|
|
if (has_negative != NULL)
|
|
|
|
*has_negative = ISC_TRUE;
|
|
|
|
}
|
2009-10-01 04:06:37 +00:00
|
|
|
}
|
2008-10-24 02:28:55 +00:00
|
|
|
|
|
|
|
if (cfg_obj_istype(ce, &cfg_type_keyref)) {
|
|
|
|
n++;
|
|
|
|
} else if (cfg_obj_islist(ce)) {
|
2009-10-01 04:06:37 +00:00
|
|
|
isc_boolean_t negative;
|
|
|
|
n += count_acl_elements(ce, cctx, &negative);
|
|
|
|
if (negative)
|
|
|
|
n++;
|
2013-02-27 17:19:39 -08:00
|
|
|
#ifdef HAVE_GEOIP
|
|
|
|
} else if (cfg_obj_istuple(ce) &&
|
|
|
|
cfg_obj_isvoid(cfg_tuple_get(ce, "negated")))
|
|
|
|
{
|
|
|
|
n++;
|
|
|
|
#endif /* HAVE_GEOIP */
|
2008-10-24 02:28:55 +00:00
|
|
|
} else if (cfg_obj_isstring(ce)) {
|
|
|
|
const char *name = cfg_obj_asstring(ce);
|
|
|
|
if (strcasecmp(name, "localhost") == 0 ||
|
|
|
|
strcasecmp(name, "localnets") == 0) {
|
|
|
|
n++;
|
|
|
|
} else if (strcasecmp(name, "any") != 0 &&
|
|
|
|
strcasecmp(name, "none") != 0) {
|
|
|
|
result = get_acl_def(cctx, name, &cacl);
|
|
|
|
if (result == ISC_R_SUCCESS)
|
2009-10-01 04:06:37 +00:00
|
|
|
n += count_acl_elements(cacl, cctx,
|
2009-10-01 23:48:08 +00:00
|
|
|
NULL) + 1;
|
2008-10-24 02:28:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2013-02-27 17:19:39 -08:00
|
|
|
#ifdef HAVE_GEOIP
|
|
|
|
static dns_geoip_subtype_t
|
|
|
|
get_subtype(const cfg_obj_t *obj, isc_log_t *lctx,
|
|
|
|
dns_geoip_subtype_t subtype, const char *dbname)
|
|
|
|
{
|
|
|
|
if (dbname == NULL)
|
|
|
|
return (subtype);
|
|
|
|
|
|
|
|
switch (subtype) {
|
|
|
|
case dns_geoip_countrycode:
|
|
|
|
if (strcasecmp(dbname, "city") == 0)
|
|
|
|
return (dns_geoip_city_countrycode);
|
|
|
|
else if (strcasecmp(dbname, "region") == 0)
|
|
|
|
return (dns_geoip_region_countrycode);
|
|
|
|
else if (strcasecmp(dbname, "country") == 0)
|
|
|
|
return (dns_geoip_country_code);
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_ERROR,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"country search: ignored");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_countrycode3:
|
|
|
|
if (strcasecmp(dbname, "city") == 0)
|
|
|
|
return (dns_geoip_city_countrycode3);
|
|
|
|
else if (strcasecmp(dbname, "country") == 0)
|
|
|
|
return (dns_geoip_country_code3);
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_ERROR,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"country search: ignored");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_countryname:
|
|
|
|
if (strcasecmp(dbname, "city") == 0)
|
|
|
|
return (dns_geoip_city_countryname);
|
|
|
|
else if (strcasecmp(dbname, "country") == 0)
|
|
|
|
return (dns_geoip_country_name);
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_ERROR,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"country search: ignored");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_region:
|
|
|
|
if (strcasecmp(dbname, "city") == 0)
|
|
|
|
return (dns_geoip_city_region);
|
|
|
|
else if (strcasecmp(dbname, "region") == 0)
|
|
|
|
return (dns_geoip_region_code);
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_ERROR,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"region search: ignored");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_regionname:
|
|
|
|
if (strcasecmp(dbname, "city") == 0)
|
|
|
|
return (dns_geoip_city_region);
|
|
|
|
else if (strcasecmp(dbname, "region") == 0)
|
|
|
|
return (dns_geoip_region_name);
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_ERROR,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"region search: ignored");
|
|
|
|
return (subtype);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Log a warning if the wrong database was specified
|
|
|
|
* on an unambiguous query
|
|
|
|
*/
|
|
|
|
case dns_geoip_city_name:
|
|
|
|
case dns_geoip_city_postalcode:
|
|
|
|
case dns_geoip_city_metrocode:
|
|
|
|
case dns_geoip_city_areacode:
|
|
|
|
case dns_geoip_city_continentcode:
|
|
|
|
case dns_geoip_city_timezonecode:
|
|
|
|
if (strcasecmp(dbname, "city") != 0)
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_WARNING,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"a 'city'-only search type: ignoring");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_isp_name:
|
|
|
|
if (strcasecmp(dbname, "isp") != 0)
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_WARNING,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"an 'isp' search: ignoring");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_org_name:
|
|
|
|
if (strcasecmp(dbname, "org") != 0)
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_WARNING,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"an 'org' search: ignoring");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_as_asnum:
|
|
|
|
if (strcasecmp(dbname, "asnum") != 0)
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_WARNING,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"an 'asnum' search: ignoring");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_domain_name:
|
|
|
|
if (strcasecmp(dbname, "domain") != 0)
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_WARNING,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"a 'domain' search: ignoring");
|
|
|
|
return (subtype);
|
|
|
|
case dns_geoip_netspeed_id:
|
|
|
|
if (strcasecmp(dbname, "netspeed") != 0)
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_WARNING,
|
|
|
|
"invalid GeoIP DB specified for "
|
|
|
|
"a 'netspeed' search: ignoring");
|
|
|
|
return (subtype);
|
|
|
|
default:
|
|
|
|
INSIST(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_boolean_t
|
|
|
|
geoip_can_answer(dns_aclelement_t *elt, cfg_aclconfctx_t *ctx) {
|
|
|
|
if (ctx->geoip == NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
|
|
|
|
switch (elt->geoip_elem.subtype) {
|
|
|
|
case dns_geoip_countrycode:
|
|
|
|
case dns_geoip_countrycode3:
|
|
|
|
case dns_geoip_countryname:
|
|
|
|
if (ctx->geoip->city_v4 != NULL ||
|
|
|
|
ctx->geoip->city_v6 != NULL ||
|
|
|
|
ctx->geoip->country_v4 != NULL ||
|
|
|
|
ctx->geoip->country_v6 != NULL ||
|
|
|
|
ctx->geoip->region != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_region:
|
|
|
|
case dns_geoip_regionname:
|
|
|
|
if (ctx->geoip->city_v4 != NULL ||
|
|
|
|
ctx->geoip->city_v6 != NULL ||
|
|
|
|
ctx->geoip->region != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_country_code:
|
|
|
|
case dns_geoip_country_code3:
|
|
|
|
case dns_geoip_country_name:
|
|
|
|
if (ctx->geoip->country_v4 != NULL ||
|
|
|
|
ctx->geoip->country_v6 != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_region_countrycode:
|
|
|
|
case dns_geoip_region_code:
|
|
|
|
case dns_geoip_region_name:
|
|
|
|
if (ctx->geoip->region != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_city_countrycode:
|
|
|
|
case dns_geoip_city_countrycode3:
|
|
|
|
case dns_geoip_city_countryname:
|
|
|
|
case dns_geoip_city_region:
|
|
|
|
case dns_geoip_city_regionname:
|
|
|
|
case dns_geoip_city_name:
|
|
|
|
case dns_geoip_city_postalcode:
|
|
|
|
case dns_geoip_city_metrocode:
|
|
|
|
case dns_geoip_city_areacode:
|
|
|
|
case dns_geoip_city_continentcode:
|
|
|
|
case dns_geoip_city_timezonecode:
|
|
|
|
if (ctx->geoip->city_v4 != NULL ||
|
|
|
|
ctx->geoip->city_v6 != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_isp_name:
|
|
|
|
if (ctx->geoip->isp != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_org_name:
|
|
|
|
if (ctx->geoip->org != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_as_asnum:
|
|
|
|
if (ctx->geoip->as != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_domain_name:
|
|
|
|
if (ctx->geoip->domain != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
case dns_geoip_netspeed_id:
|
|
|
|
if (ctx->geoip->netspeed != NULL)
|
|
|
|
return (ISC_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
parse_geoip_element(const cfg_obj_t *obj, isc_log_t *lctx,
|
|
|
|
cfg_aclconfctx_t *ctx, dns_aclelement_t *de)
|
|
|
|
{
|
|
|
|
const cfg_obj_t *ge;
|
|
|
|
const char *dbname = NULL;
|
|
|
|
const char *stype, *search;
|
|
|
|
dns_geoip_subtype_t subtype;
|
|
|
|
|
|
|
|
ge = cfg_tuple_get(obj, "db");
|
|
|
|
if (!cfg_obj_isvoid(ge))
|
|
|
|
dbname = cfg_obj_asstring(ge);
|
|
|
|
|
|
|
|
stype = cfg_obj_asstring(cfg_tuple_get(obj, "subtype"));
|
|
|
|
search = cfg_obj_asstring(cfg_tuple_get(obj, "search"));
|
|
|
|
|
|
|
|
if (strcasecmp(stype, "country") == 0 && strlen(search) == 2) {
|
|
|
|
/* Two-letter country code */
|
|
|
|
subtype = dns_geoip_countrycode;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 2);
|
|
|
|
} else if (strcasecmp(stype, "country") == 0 && strlen(search) == 3) {
|
|
|
|
/* Three-letter country code */
|
|
|
|
subtype = dns_geoip_countrycode3;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 3);
|
|
|
|
} else if (strcasecmp(stype, "country") == 0) {
|
|
|
|
/* Country name */
|
|
|
|
subtype = dns_geoip_countryname;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "region") == 0 && strlen(search) == 2) {
|
|
|
|
/* Two-letter region code */
|
|
|
|
subtype = dns_geoip_region;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 2);
|
|
|
|
} else if (strcasecmp(stype, "region") == 0) {
|
|
|
|
/* Region name */
|
|
|
|
subtype = dns_geoip_regionname;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "city") == 0) {
|
|
|
|
/* City name */
|
|
|
|
subtype = dns_geoip_city_name;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "postal") == 0 && strlen(search) < 7) {
|
|
|
|
subtype = dns_geoip_city_postalcode;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 6);
|
|
|
|
de->geoip_elem.as_string[6] = '\0';
|
|
|
|
} else if (strcasecmp(stype, "metro") == 0) {
|
|
|
|
subtype = dns_geoip_city_metrocode;
|
|
|
|
de->geoip_elem.as_int = atoi(search);
|
|
|
|
} else if (strcasecmp(stype, "area") == 0) {
|
|
|
|
subtype = dns_geoip_city_areacode;
|
|
|
|
de->geoip_elem.as_int = atoi(search);
|
|
|
|
} else if (strcasecmp(stype, "tz") == 0) {
|
|
|
|
subtype = dns_geoip_city_timezonecode;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "continent") == 0 && strlen(search) == 2) {
|
|
|
|
/* Two-letter continent code */
|
|
|
|
subtype = dns_geoip_city_continentcode;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 2);
|
|
|
|
} else if (strcasecmp(stype, "isp") == 0) {
|
|
|
|
subtype = dns_geoip_isp_name;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "asnum") == 0) {
|
|
|
|
subtype = dns_geoip_as_asnum;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "org") == 0) {
|
|
|
|
subtype = dns_geoip_org_name;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "domain") == 0) {
|
|
|
|
subtype = dns_geoip_domain_name;
|
|
|
|
strncpy(de->geoip_elem.as_string, search, 255);
|
|
|
|
} else if (strcasecmp(stype, "netspeed") == 0) {
|
|
|
|
subtype = dns_geoip_netspeed_id;
|
|
|
|
de->geoip_elem.as_int = atoi(search);
|
|
|
|
} else
|
|
|
|
INSIST(0);
|
|
|
|
|
|
|
|
de->geoip_elem.subtype = get_subtype(obj, lctx, subtype, dbname);
|
|
|
|
|
|
|
|
if (! geoip_can_answer(de, ctx)) {
|
|
|
|
cfg_obj_log(obj, lctx, ISC_LOG_ERROR,
|
|
|
|
"no GeoIP database installed which can answer "
|
|
|
|
"queries of type '%s'", stype);
|
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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;
|
2007-12-21 06:46:47 +00:00
|
|
|
int new_nest_level = 0;
|
|
|
|
|
|
|
|
if (nest_level != 0)
|
|
|
|
new_nest_level = nest_level - 1;
|
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
|
2008-10-24 02:28:55 +00:00
|
|
|
* in the ACL definition that will require space in the
|
2009-01-18 18:02:14 +00:00
|
|
|
* elements table. (Note that if nest_level is nonzero,
|
2008-10-24 02:28:55 +00:00
|
|
|
* *everything* goes in the elements table.)
|
2007-09-14 01:46:06 +00:00
|
|
|
*/
|
2008-10-24 02:28:55 +00:00
|
|
|
int nelem;
|
|
|
|
|
|
|
|
if (nest_level == 0)
|
2009-10-01 04:06:37 +00:00
|
|
|
nelem = count_acl_elements(caml, cctx, NULL);
|
2008-10-24 02:28:55 +00:00
|
|
|
else
|
|
|
|
nelem = cfg_list_length(caml, ISC_FALSE);
|
|
|
|
|
|
|
|
result = dns_acl_create(mctx, nelem, &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;
|
2008-10-24 02:28:55 +00:00
|
|
|
elt = cfg_list_next(elt)) {
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *ce = cfg_listelt_value(elt);
|
2013-02-27 17:19:39 -08:00
|
|
|
isc_boolean_t neg = ISC_FALSE;
|
2007-09-12 01:09:08 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
if (cfg_obj_istuple(ce)) {
|
2013-02-27 17:19:39 -08:00
|
|
|
/* Might be a negated element */
|
|
|
|
const cfg_obj_t *negated =
|
|
|
|
cfg_tuple_get(ce, "negated");
|
|
|
|
if (! cfg_obj_isvoid(negated)) {
|
|
|
|
neg = ISC_TRUE;
|
|
|
|
dacl->has_negatives = ISC_TRUE;
|
|
|
|
ce = negated;
|
|
|
|
}
|
|
|
|
}
|
2007-09-12 01:09:08 +00:00
|
|
|
|
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
|
|
|
|
2007-12-21 06:46:47 +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-12-21 06:46:47 +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-12-21 06:46:47 +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
|
2007-12-21 06:46:47 +00:00
|
|
|
* merge it into *this* ACL. We nest ACLs
|
|
|
|
* in two cases: 1) sortlist, 2) if the
|
|
|
|
* nested ACL contains negated members.
|
2007-09-14 01:46:06 +00:00
|
|
|
*/
|
2007-12-21 06:46:47 +00:00
|
|
|
if (inneracl != NULL)
|
|
|
|
dns_acl_detach(&inneracl);
|
|
|
|
result = cfg_acl_fromconfig(ce, cctx, lctx,
|
|
|
|
ctx, mctx, new_nest_level,
|
|
|
|
&inneracl);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
nested_acl:
|
|
|
|
if (nest_level > 0 || inneracl->has_negatives) {
|
|
|
|
de->type = dns_aclelementtype_nestedacl;
|
|
|
|
de->negative = neg;
|
|
|
|
if (de->nestedacl != NULL)
|
|
|
|
dns_acl_detach(&de->nestedacl);
|
|
|
|
dns_acl_attach(inneracl,
|
|
|
|
&de->nestedacl);
|
|
|
|
dns_acl_detach(&inneracl);
|
|
|
|
/* Fall through. */
|
|
|
|
} else {
|
2007-10-19 00:28:20 +00:00
|
|
|
dns_acl_merge(dacl, inneracl,
|
|
|
|
ISC_TF(!neg));
|
2008-07-19 00:09:44 +00:00
|
|
|
de += inneracl->length; /* elements added */
|
2007-10-19 00:28:20 +00:00
|
|
|
dns_acl_detach(&inneracl);
|
2007-09-14 01:46:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else if (cfg_obj_istype(ce, &cfg_type_keyref)) {
|
2007-12-21 06:46:47 +00:00
|
|
|
/* Key name. */
|
2007-09-14 01:46:06 +00:00
|
|
|
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;
|
2013-02-27 17:19:39 -08:00
|
|
|
#ifdef HAVE_GEOIP
|
|
|
|
} else if (cfg_obj_istuple(ce) &&
|
|
|
|
cfg_obj_isvoid(cfg_tuple_get(ce, "negated")))
|
|
|
|
{
|
|
|
|
result = parse_geoip_element(ce, lctx, ctx, de);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
de->type = dns_aclelementtype_geoip;
|
|
|
|
de->negative = neg;
|
|
|
|
#endif /* HAVE_GEOIP */
|
2001-03-04 21:21:39 +00:00
|
|
|
} else if (cfg_obj_isstring(ce)) {
|
2007-12-21 06:46:47 +00:00
|
|
|
/* 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) {
|
2007-12-21 06:46:47 +00:00
|
|
|
/* Iptable entry with zero bit length. */
|
2007-11-19 23:13:28 +00:00
|
|
|
result = dns_iptable_addprefix(iptab, NULL, 0,
|
2007-12-21 06:46:47 +00:00
|
|
|
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-12-21 06:46:47 +00:00
|
|
|
/* none == !any */
|
|
|
|
/*
|
|
|
|
* We don't unconditional set
|
|
|
|
* dacl->has_negatives and
|
|
|
|
* de->negative to true so we can handle
|
|
|
|
* "!none;".
|
|
|
|
*/
|
2007-11-19 23:13:28 +00:00
|
|
|
result = dns_iptable_addprefix(iptab, NULL, 0,
|
2007-12-21 06:46:47 +00:00
|
|
|
ISC_TF(nest_level != 0 || neg));
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!neg)
|
|
|
|
dacl->has_negatives = !neg;
|
|
|
|
|
|
|
|
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-12-18 01:53:26 +00:00
|
|
|
if (inneracl != NULL)
|
|
|
|
dns_acl_detach(&inneracl);
|
|
|
|
result = convert_named_acl(ce, cctx, lctx, ctx,
|
|
|
|
mctx, new_nest_level,
|
|
|
|
&inneracl);
|
2001-03-04 21:21:39 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2007-09-12 01:09:08 +00:00
|
|
|
|
2007-12-21 06:46:47 +00:00
|
|
|
goto nested_acl;
|
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
|
2008-05-21 23:47:01 +00:00
|
|
|
* nonzero (i.e., in sortlists).
|
2007-09-14 01:46:06 +00:00
|
|
|
*/
|
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
|
|
|
dacl->length++;
|
2007-12-21 06:46:47 +00:00
|
|
|
de++;
|
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);
|
|
|
|
}
|