aclconf.c revision ea419adc4eca4c3e44f2c282035b5dce6b795fe2
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 1999, 2000 Internet Software Consortium.
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * Permission to use, copy, modify, and distribute this software for any
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * purpose with or without fee is hereby granted, provided that the above
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
15a44745412679c30a6d022733925af70a38b715David Lawrence * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15a44745412679c30a6d022733925af70a38b715David Lawrence * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15a44745412679c30a6d022733925af70a38b715David Lawrence * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9aba20edee4e704433a464ae43b070b0775de506Mark Andrews/* $Id: aclconf.c,v 1.21 2000/08/11 01:53:47 gson Exp $ */
593cb00bd17e5e2ab0dcb7c635a9a81082dc5d0eAndreas Gustafsson#include <isc/string.h> /* Required for HP/UX (and others?) */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_aclconfctx_init(dns_aclconfctx_t *ctx) {
3e14b69d196a3ebeecc4662c426344dcfd7db678Andreas Gustafssondns_aclconfctx_destroy(dns_aclconfctx_t *ctx) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache);
9aba20edee4e704433a464ae43b070b0775de506Mark Andrewsconvert_named_acl(char *aclname, dns_c_ctx_t *cctx,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson /* Look for an already-converted version. */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson /* Not yet converted. Convert now. */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = dns_c_acltable_getacl(cctx->acls, aclname, &cacl);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_log_write(dns_lctx, DNS_LOGCATEGORY_SECURITY,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = dns_acl_fromconfig(cacl->ipml, cctx, ctx, mctx, &dacl);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson dacl->name = isc_mem_strdup(dacl->mctx, aclname);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence ISC_LIST_APPEND(ctx->named_acl_cache, dacl, nextincache);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssonconvert_keyname(char *txtname, isc_mem_t *mctx, dns_name_t *dnsname) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = dns_name_fromtext(dns_fixedname_name(&fixname), &buf,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_log_write(dns_lctx, DNS_LOGCATEGORY_SECURITY,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson "key name \"%s\" is not a valid domain name",
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson return (dns_name_dup(dns_fixedname_name(&fixname), mctx, dnsname));
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafssondns_acl_fromconfig(dns_c_ipmatchlist_t *caml,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson REQUIRE(target != NULL && *target == NULL);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson result = dns_acl_create(mctx, count, &dacl);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson de->negative = dns_c_ipmatchelement_isneg(ce);
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson isc_netaddr_fromsockaddr(&de->u.ip_prefix.address,
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson /* XXX "mask" is a misnomer */
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson de->u.ip_prefix.prefixlen = ce->u.direct.mask;
19f4d25fd5b35b1375b0b9f13b66770ee4a66154Brian Wellington result = dns_acl_fromconfig(ce->u.indirect.list,
f621719829356f27e831507b75e88e8a655e48d8Danny Mayer isc_log_write(dns_lctx, DNS_LOGCATEGORY_SECURITY,
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington "address match list contains "
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson "unsupported element type");