acl.c revision 7693d4de8fca501dfe6989a7f30d8d3c86fe096a
/*
* Copyright (C) 1999 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.
*/
#include <config.h>
#include <isc/assertions.h>
/*
* Create a new ACL with 'n' uninitialized elements.
*/
{
return (ISC_R_NOMEMORY);
/* Must set magic early because we use dns_acl_detach() to clean up. */
goto cleanup;
}
return (ISC_R_SUCCESS);
return (result);
}
static isc_result_t
{
if (result != ISC_R_SUCCESS)
return (result);
return (result);
}
}
}
const char *opname,
{
int match;
else if (fallback_acl != NULL)
acl = fallback_acl;
else if (default_allow)
goto allow;
else
goto deny;
if (result != DNS_R_SUCCESS)
goto deny; /* Internal error, already logged. */
if (match > 0)
goto allow;
goto deny; /* Negative match or no match. */
"%s approved", opname);
return (DNS_R_SUCCESS);
deny:
"%s denied", opname);
return (DNS_R_REFUSED);
}
int *match,
{
unsigned int i;
int indirectmatch;
switch (e->type) {
goto matched;
break;
goto matched;
break;
e->u.nestedacl,
if (result != ISC_R_SUCCESS)
return (result);
/*
* Treat negative matches in indirect ACLs as
* "no match".
* That way, a negated indirect ACL will never become
* a surprise positive match through double negation.
*/
if (indirectmatch > 0)
goto matched;
/*
* A negative indirect match may have set *matchelt,
* but we don't want it set when we return.
*/
break;
case dns_aclelementtype_any:
*matchelt = e;
return (ISC_R_SUCCESS);
default:
INSIST(0);
break;
}
}
/* No match. */
*match = 0;
return (ISC_R_SUCCESS);
}
void
{
}
static void
{
unsigned int i;
break;
break;
default:
break;
}
}
}
void
{
}
{
return (ISC_FALSE);
return (ISC_FALSE);
case dns_aclelementtype_any:
return (ISC_TRUE);
default:
INSIST(0);
return (ISC_FALSE);
}
}
unsigned int i;
if (a == b)
return (ISC_TRUE);
return (ISC_FALSE);
for (i = 0; i < a->length; i++) {
if (! dns_aclelement_equal(&a->elements[i],
&b->elements[i]))
return (ISC_FALSE);
}
return (ISC_TRUE);
}