X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Facl.c;h=72a89e2751086049b139b853a50a8d096ce366af;hb=a8efbbeef4dbc9f48efda1eae0ca77e9365a8f46;hp=95ad25942664b6cb1c21242fab96d1badac39ce5;hpb=ac989f108dcf930a3339a02c94c5ae292595cf78;p=openldap diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 95ad259426..72a89e2751 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -1,31 +1,19 @@ /* acl.c - routines to parse and check acl's */ -#include -#include -#include -#include -#include -#include -#include - -#include "slap.h" +#include "portable.h" -extern Attribute *attr_find(); -extern struct acl *global_acl; -extern int global_default_access; -extern char *access2str(); -extern char *dn_normalize_case(); +#include -int acl_access_allowed(); -int access_allowed(); -struct acl *acl_get_applicable(); +#include +#include +#include -static int regex_matches(); +#include "slap.h" -static string_expand(char *newbuf, int bufsiz, char *pattern, - char *match, regmatch_t *matches); +static int regex_matches(char *pat, char *str, char *buf, regmatch_t *matches); +static void string_expand(char *newbuf, int bufsiz, char *pattern, + char *match, regmatch_t *matches); -extern Entry * be_dn2entry(Backend *be, char *bdn, char **matched); /* * access_allowed - check whether dn is allowed the requested access @@ -84,8 +72,8 @@ access_allowed( if (a) { for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) { - Debug( LDAP_DEBUG_ARGS, "=> match[%d]: %d %d ", - i, matches[i].rm_so, matches[i].rm_eo ); + Debug( LDAP_DEBUG_ARGS, "=> match[%d]: %d %d ", i, + (int)matches[i].rm_so, (int)matches[i].rm_eo ); if( matches[i].rm_so <= matches[0].rm_eo ) { for ( n = matches[i].rm_so; n < matches[i].rm_eo; n++) { @@ -141,7 +129,7 @@ acl_get_applicable( for ( i = 1, a = be->be_acl; a != NULL; a = a->acl_next, i++ ) { if (a->acl_dnpat != NULL) { Debug( LDAP_DEBUG_TRACE, "=> dnpat: [%d] %s nsub: %d\n", - i, a->acl_dnpat, a->acl_dnre.re_nsub); + i, a->acl_dnpat, (int) a->acl_dnre.re_nsub); if (regexec(&a->acl_dnre, edn, nmatch, matches, 0)) continue; @@ -172,7 +160,7 @@ acl_get_applicable( for ( i = 1, a = global_acl; a != NULL; a = a->acl_next, i++ ) { if (a->acl_dnpat != NULL) { Debug( LDAP_DEBUG_TRACE, "=> dnpat: [%d] %s nsub: %d\n", - i, a->acl_dnpat, a->acl_dnre.re_nsub); + i, a->acl_dnpat, (int) a->acl_dnre.re_nsub); if (regexec(&a->acl_dnre, edn, nmatch, matches, 0)) { continue; @@ -361,23 +349,18 @@ acl_access_allowed( return( (b->a_access & ~ACL_SELF) >= access ); } -#ifdef ACLGROUP +#ifdef SLAPD_ACLGROUPS if ( b->a_group != NULL && op->o_dn != NULL ) { char buf[512]; /* b->a_group is an unexpanded entry name, expanded it should be an * entry with objectclass group* and we test to see if odn is one of - * the values in the attribute uniquegroup + * the values in the attribute group */ - Debug( LDAP_DEBUG_ARGS, "<= check a_group: %s\n", - b->a_group, 0, 0); - Debug( LDAP_DEBUG_ARGS, "<= check a_group: odn: %s\n", - odn, 0, 0); - /* see if asker is listed in dnattr */ string_expand(buf, sizeof(buf), b->a_group, edn, matches); - if (be_group(be, buf, odn) == 0) { + if (be_group(be, buf, odn, b->a_objectclassvalue, b->a_groupattrname) == 0) { Debug( LDAP_DEBUG_ACL, "<= acl_access_allowed: matched by clause #%d (group) access granted\n", i, 0, 0 ); @@ -385,7 +368,7 @@ acl_access_allowed( return( (b->a_access & ~ACL_SELF) >= access ); } } -#endif /* ACLGROUP */ +#endif /* SLAPD_ACLGROUPS */ } if ( odn ) free( odn ); @@ -478,7 +461,8 @@ acl_check_mods( return( LDAP_SUCCESS ); } -static string_expand( +static void +string_expand( char *newbuf, int bufsiz, char *pat, @@ -549,7 +533,7 @@ regex_matches( char error[512]; regerror(rc, &re, error, sizeof(error)); - Debug( LDAP_DEBUG_ANY, + Debug( LDAP_DEBUG_TRACE, "compile( \"%s\", \"%s\") failed %s\n", pat, str, error ); return( 0 );