1 /* acl.c - routines to parse and check acl's */
4 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/socket.h>
14 #include <ac/string.h>
18 static AccessControl * acl_get(
19 AccessControl *ac, int *count,
20 Backend *be, Operation *op,
22 int nmatches, regmatch_t *matches );
24 static slap_control_t acl_mask(
25 AccessControl *ac, slap_access_mask_t *mask,
26 Backend *be, Connection *conn, Operation *op,
27 Entry *e, char *attr, struct berval *val,
28 regmatch_t *matches );
30 #ifdef SLAPD_ACI_ENABLED
34 Entry *e, char *attr, struct berval *val, struct berval *aci,
35 regmatch_t *matches, slap_access_t *grant, slap_access_t *deny );
37 char *supportedACIMechs[] = {
38 "1.3.6.1.4.1.4203.666.7.1", /* experimental IETF aci family */
39 "1.3.6.1.4.1.4203.666.7.2", /* experimental OpenLDAP aci family */
44 static int regex_matches(char *pat, char *str, char *buf, regmatch_t *matches);
45 static void string_expand(char *newbuf, int bufsiz, char *pattern,
46 char *match, regmatch_t *matches);
50 * access_allowed - check whether op->o_ndn is allowed the requested access
51 * to entry e, attribute attr, value val. if val is null, access to
52 * the whole attribute is assumed (all values).
54 * This routine loops through all access controls and calls
55 * acl_mask() on each applicable access control.
56 * The loop exits when a definitive answer is reached or
57 * or no more controls remain.
78 char accessmaskbuf[ACCESSMASK_MAXLEN];
80 slap_access_mask_t mask;
81 slap_control_t control;
83 regmatch_t matches[MAXREMATCHES];
85 Debug( LDAP_DEBUG_ACL,
86 "=> access_allowed: %s access to \"%s\" \"%s\" requested\n",
92 assert( attr != NULL );
93 assert( access > ACL_NONE );
95 /* grant database root access */
96 if ( be != NULL && be_isroot( be, op->o_ndn ) ) {
97 Debug( LDAP_DEBUG_ACL,
98 "<= root access granted\n",
104 * no-user-modification operational attributes are ignored
105 * by ACL_WRITE checking as any found here are not provided
108 if ( access >= ACL_WRITE && oc_check_op_no_usermod_attr( attr ) ) {
109 Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
110 " %s access granted\n",
115 /* use backend default access if no backend acls */
116 if( be != NULL && be->be_acl == NULL ) {
117 Debug( LDAP_DEBUG_ACL,
118 "=> access_allowed: backend default %s access %s to \"%s\"\n",
119 access2str( access ),
120 be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn );
122 return be->be_dfltaccess >= access;
125 /* be is always non-NULL */
126 /* use global default access if no global acls */
127 } else if ( be == NULL && global_acl == NULL ) {
128 Debug( LDAP_DEBUG_ACL,
129 "=> access_allowed: global default %s access %s to \"%s\"\n",
130 access2str( access ),
131 global_default_access >= access ? "granted" : "denied", op->o_dn );
133 return global_default_access >= access;
138 memset(matches, 0, sizeof(matches));
144 while( a = acl_get( a, &count, be, op, e, attr, MAXREMATCHES, matches ) )
148 for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) {
149 Debug( LDAP_DEBUG_ACL, "=> match[%d]: %d %d ", i,
150 (int)matches[i].rm_so, (int)matches[i].rm_eo );
152 if( matches[i].rm_so <= matches[0].rm_eo ) {
154 for ( n = matches[i].rm_so; n < matches[i].rm_eo; n++) {
155 Debug( LDAP_DEBUG_ACL, "%c", e->e_ndn[n], 0, 0 );
158 Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 );
161 control = acl_mask( a, &mask, be, conn, op,
162 e, attr, val, matches );
164 if ( control != ACL_BREAK ) {
168 memset(matches, 0, sizeof(matches));
171 if ( ACL_IS_INVALID( mask ) ) {
172 Debug( LDAP_DEBUG_ACL,
173 "=> access_allowed: \"%s\" (%s) invalid!\n",
177 } else if ( control == ACL_BREAK ) {
178 Debug( LDAP_DEBUG_ACL,
179 "=> access_allowed: no more rules\n", 0, 0, 0);
183 Debug( LDAP_DEBUG_ACL,
184 "=> access_allowed: %s access %s by %s\n",
185 access2str( access ),
186 ACL_GRANT(mask, access) ? "granted" : "denied",
187 accessmask2str( mask, accessmaskbuf ) );
189 return ACL_GRANT(mask, access);
193 * acl_get - return the acl applicable to entry e, attribute
194 * attr. the acl returned is suitable for use in subsequent calls to
195 * acl_access_allowed().
198 static AccessControl *
211 assert( count != NULL );
226 for ( ; a != NULL; a = a->acl_next ) {
229 if (a->acl_dn_pat != NULL) {
230 Debug( LDAP_DEBUG_ACL, "=> dnpat: [%d] %s nsub: %d\n",
231 *count, a->acl_dn_pat, (int) a->acl_dn_re.re_nsub );
233 if (regexec(&a->acl_dn_re, e->e_ndn, nmatch, matches, 0)) {
237 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] matched\n",
242 if ( a->acl_filter != NULL ) {
243 ber_int_t rc = test_filter( NULL, NULL, NULL, e, a->acl_filter );
244 if ( rc != LDAP_COMPARE_TRUE ) {
249 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] check attr %s\n",
252 if ( attr == NULL || a->acl_attrs == NULL ||
253 charray_inlist( a->acl_attrs, attr ) )
255 Debug( LDAP_DEBUG_ACL,
256 "<= acl_get: [%d] acl %s attr: %s\n",
257 *count, e->e_dn, attr );
260 matches[0].rm_so = matches[0].rm_eo = -1;
263 Debug( LDAP_DEBUG_ACL, "<= acl_get: done.\n", 0, 0, 0 );
269 * acl_mask - modifies mask based upon the given acl and the
270 * requested access to entry e, attribute attr, value val. if val
271 * is null, access to the whole attribute is assumed (all values).
273 * returns 0 access NOT allowed
277 static slap_control_t
280 slap_access_mask_t *mask,
293 char accessmaskbuf[ACCESSMASK_MAXLEN];
297 assert( mask != NULL );
299 Debug( LDAP_DEBUG_ACL,
300 "=> acl_mask: access to entry \"%s\", attr \"%s\" requested\n",
303 Debug( LDAP_DEBUG_ACL,
304 "=> acl_mask: to value \"%s\" by \"%s\", (%s) \n",
305 val ? val->bv_val : "*",
306 op->o_ndn ? op->o_ndn : "",
307 accessmask2str( *mask, accessmaskbuf ) );
309 for ( i = 1, b = a->acl_access; b != NULL; b = b->a_next, i++ ) {
310 slap_access_mask_t oldmask, modmask;
312 ACL_INVALIDATE( modmask );
314 /* AND <who> clauses */
315 if ( b->a_dn_pat != NULL ) {
316 Debug( LDAP_DEBUG_ACL, "<= check a_dn_pat: %s\n",
319 * if access applies to the entry itself, and the
320 * user is bound as somebody in the same namespace as
321 * the entry, OR the given dn matches the dn pattern
323 if ( strcmp( b->a_dn_pat, "anonymous" ) == 0 ) {
324 if (op->o_ndn != NULL && op->o_ndn[0] != '\0' ) {
328 } else if ( strcmp( b->a_dn_pat, "users" ) == 0 ) {
329 if (op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
333 } else if ( strcmp( b->a_dn_pat, "self" ) == 0 ) {
334 if( op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
338 if ( e->e_dn == NULL || strcmp( e->e_ndn, op->o_ndn ) != 0 ) {
342 } else if ( strcmp( b->a_dn_pat, "*" ) != 0 ) {
343 int ret = regex_matches( b->a_dn_pat,
344 op->o_ndn, e->e_ndn, matches );
352 if ( b->a_sockurl_pat != NULL ) {
353 Debug( LDAP_DEBUG_ACL, "<= check a_sockurl_pat: %s\n",
354 b->a_sockurl_pat, 0, 0 );
356 if ( strcmp( b->a_sockurl_pat, "*" ) != 0 &&
357 !regex_matches( b->a_sockurl_pat, conn->c_listener_url,
358 e->e_ndn, matches ) )
364 if ( b->a_domain_pat != NULL ) {
365 Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n",
366 b->a_domain_pat, 0, 0 );
368 if ( strcmp( b->a_domain_pat, "*" ) != 0 &&
369 !regex_matches( b->a_domain_pat, conn->c_peer_domain,
370 e->e_ndn, matches ) )
376 if ( b->a_peername_pat != NULL ) {
377 Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n",
378 b->a_peername_pat, 0, 0 );
380 if ( strcmp( b->a_peername_pat, "*" ) != 0 &&
381 !regex_matches( b->a_peername_pat, conn->c_peer_name,
382 e->e_ndn, matches ) )
388 if ( b->a_sockname_pat != NULL ) {
389 Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n",
390 b->a_sockname_pat, 0, 0 );
392 if ( strcmp( b->a_sockname_pat, "*" ) != 0 &&
393 !regex_matches( b->a_sockname_pat, conn->c_sock_name,
394 e->e_ndn, matches ) )
400 if ( b->a_dn_at != NULL && op->o_ndn != NULL ) {
405 Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n",
408 bv.bv_val = op->o_ndn;
409 bv.bv_len = strlen( bv.bv_val );
411 #ifdef SLAPD_SCHEMA_NOT_COMPAT
412 dn_at = at_canonical_name( b->a_dn_at );
417 /* see if asker is listed in dnattr */
418 if ( (at = attr_find( e->e_attrs, dn_at )) != NULL
419 #ifdef SLAPD_SCHEMA_NOT_COMPAT
420 /* not yet implemented */
422 && value_find( at->a_vals, &bv, at->a_syntax, 3 ) == 0
428 #ifdef SLAPD_SCHEMA_NOT_COMPAT
429 /* not yet implemented */
431 || value_cmp( &bv, val, at->a_syntax, 2 )
438 /* asker not listed in dnattr - check for self access */
439 } else if ( ! b->a_dn_self || val == NULL
440 #ifdef SLAPD_SCHEMA_NOT_COMPAT
441 /* not yet implemented */
443 || value_cmp( &bv, val, at->a_syntax, 2 ) != 0
451 if ( b->a_group_pat != NULL && op->o_ndn != NULL ) {
454 /* b->a_group is an unexpanded entry name, expanded it should be an
455 * entry with objectclass group* and we test to see if odn is one of
456 * the values in the attribute group
458 /* see if asker is listed in dnattr */
459 string_expand(buf, sizeof(buf), b->a_group_pat, e->e_ndn, matches);
460 if ( dn_normalize(buf) == NULL ) {
461 /* did not expand to a valid dn */
465 if (backend_group(be, e, buf, op->o_ndn,
466 b->a_group_oc, b->a_group_at) != 0)
472 #ifdef SLAPD_ACI_ENABLED
473 if ( b->a_aci_at != NULL ) {
475 slap_access_t grant, deny, tgrant, tdeny;
477 /* this case works different from the others above.
478 * since aci's themselves give permissions, we need
479 * to first check b->a_mask, the ACL's access level.
482 if( op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
486 if ( e->e_dn == NULL ) {
490 /* first check if the right being requested
491 * is allowed by the ACL clause.
493 if ( ! ACL_GRANT( b->a_mask, *mask ) ) {
497 /* get the aci attribute */
498 at = attr_find( e->e_attrs, b->a_aci_at );
503 /* start out with nothing granted, nothing denied */
507 /* the aci is an multi-valued attribute. The
508 * rights are determined by OR'ing the individual
509 * rights given by the acis.
511 for ( i = 0; at->a_vals[i] != NULL; i++ ) {
512 if (aci_mask( be, op,
513 e, attr, val, at->a_vals[i],
514 matches, &grant, &deny ) != 0)
521 /* remove anything that the ACL clause does not allow */
522 tgrant &= b->a_mask & ACL_PRIV_MASK;
523 tdeny &= ACL_PRIV_MASK;
525 /* see if we have anything to contribute */
526 if( ACL_IS_INVALID(tgrant) && ACL_IS_INVALID(tdeny) ) {
530 /* this could be improved by changing acl_mask so that it can deal with
531 * by clauses that return grant/deny pairs. Right now, it does either
532 * additive or subtractive rights, but not both at the same time. So,
533 * we need to combine the grant/deny pair into a single rights mask in
534 * a smart way: if either grant or deny is "empty", then we use the
535 * opposite as is, otherwise we remove any denied rights from the grant
536 * rights mask and construct an additive mask.
538 if (ACL_IS_INVALID(tdeny)) {
539 modmask = tgrant | ACL_PRIV_ADDITIVE;
541 } else if (ACL_IS_INVALID(tgrant)) {
542 modmask = tdeny | ACL_PRIV_SUBSTRACTIVE;
545 modmask = (tgrant & ~tdeny) | ACL_PRIV_ADDITIVE;
555 Debug( LDAP_DEBUG_ACL,
556 "<= acl_mask: [%d] applying %s (%s)\n",
557 i, accessmask2str( modmask, accessmaskbuf ),
558 b->a_type == ACL_CONTINUE
560 : b->a_type == ACL_BREAK
567 if( ACL_IS_ADDITIVE(modmask) ) {
569 ACL_PRIV_SET( *mask, modmask );
572 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
574 } else if( ACL_IS_SUBTRACTIVE(modmask) ) {
575 /* substract privs */
576 ACL_PRIV_CLR( *mask, modmask );
579 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
586 Debug( LDAP_DEBUG_ACL,
587 "<= acl_mask: [%d] mask: %s\n",
588 i, accessmask2str(*mask, accessmaskbuf), 0 );
590 if( b->a_type == ACL_CONTINUE ) {
593 } else if ( b->a_type == ACL_BREAK ) {
601 Debug( LDAP_DEBUG_ACL,
602 "<= acl_mask: no more <who> clauses, returning %s (stop)\n",
603 accessmask2str(*mask, accessmaskbuf), 0, 0 );
608 * acl_check_modlist - check access control on the given entry to see if
609 * it allows the given modifications by the user associated with op.
610 * returns 1 if mods allowed ok
625 assert( be != NULL );
627 /* short circuit root database access */
628 if ( be_isroot( be, op->o_ndn ) ) {
629 Debug( LDAP_DEBUG_ACL,
630 "<= acl_access_allowed: granted to database root\n",
635 /* use backend default access if no backend acls */
636 if( be != NULL && be->be_acl == NULL ) {
637 Debug( LDAP_DEBUG_ACL,
638 "=> access_allowed: backend default %s access %s to \"%s\"\n",
639 access2str( ACL_WRITE ),
640 be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn );
642 return be->be_dfltaccess >= ACL_WRITE;
645 /* be is always non-NULL */
646 /* use global default access if no global acls */
647 } else if ( be == NULL && global_acl == NULL ) {
648 Debug( LDAP_DEBUG_ACL,
649 "=> access_allowed: global default %s access %s to \"%s\"\n",
650 access2str( ACL_WRITE ),
651 global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn );
653 return global_default_access >= ACL_WRITE;
657 for ( ; mlist != NULL; mlist = mlist->ml_next ) {
659 * no-user-modification operational attributes are ignored
660 * by ACL_WRITE checking as any found here are not provided
663 if ( oc_check_op_no_usermod_attr( mlist->ml_type ) ) {
664 Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
665 " modify access granted\n",
666 mlist->ml_type, 0, 0 );
670 switch ( mlist->ml_op & ~LDAP_MOD_BVALUES ) {
671 case LDAP_MOD_REPLACE:
673 if ( mlist->ml_bvalues == NULL ) {
676 for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) {
677 if ( ! access_allowed( be, conn, op, e,
678 mlist->ml_type, mlist->ml_bvalues[i],
686 case LDAP_MOD_DELETE:
687 if ( mlist->ml_bvalues == NULL ) {
688 if ( ! access_allowed( be, conn, op, e,
689 mlist->ml_type, NULL,
696 for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) {
697 if ( ! access_allowed( be, conn, op, e,
698 mlist->ml_type, mlist->ml_bvalues[i],
711 #ifdef SLAPD_ACI_ENABLED
713 aci_bvstrdup (struct berval *bv)
717 s = (char *)ch_malloc(bv->bv_len + 1);
719 memcpy(s, bv->bv_val, bv->bv_len);
726 aci_strbvcmp (char *s, struct berval *bv)
730 res = strncasecmp( s, bv->bv_val, bv->bv_len );
734 if (len > (int)bv->bv_len)
736 if (len < (int)bv->bv_len)
742 aci_get_part (struct berval *list, int ix, char sep, struct berval *bv)
753 while (len >= 0 && --ix >= 0) {
754 while (--len >= 0 && *p++ != sep) ;
756 while (len >= 0 && *p == ' ') {
767 while (--len >= 0 && *p != sep) {
771 while (bv->bv_len > 0 && *--p == ' ')
777 aci_list_map_rights (
785 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
788 switch (*bv.bv_val) {
790 ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
793 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
794 * the right 's' to mean "set", but in the examples states
795 * that the right 's' means "search". The latter definition
798 ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
801 ACL_PRIV_SET(mask, ACL_PRIV_READ);
804 ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
807 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not
808 * define any equivalent to the AUTH right, so I've just used
811 ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
822 aci_list_has_attr (struct berval *list, char *attr, struct berval *val)
824 struct berval bv, left, right;
827 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
828 if (aci_get_part(&bv, 0, '=', &left) < 0
829 || aci_get_part(&bv, 1, '=', &right) < 0)
831 if (aci_strbvcmp(attr, &bv) == 0)
833 } else if (val == NULL) {
834 if (aci_strbvcmp(attr, &left) == 0)
837 if (aci_strbvcmp(attr, &left) == 0) {
838 /* this is experimental code that implements a
839 * simple (prefix) match of the attribute value.
840 * the ACI draft does not provide for aci's that
841 * apply to specific values, but it would be
842 * nice to have. If the <attr> part of an aci's
843 * rights list is of the form <attr>=<value>,
844 * that means the aci applies only to attrs with
845 * the given value. Furthermore, if the attr is
846 * of the form <attr>=<value>*, then <value> is
847 * treated as a prefix, and the aci applies to
848 * any value with that prefix.
850 * Ideally, this would allow r.e. matches.
852 if (aci_get_part(&right, 0, '*', &left) < 0
853 || right.bv_len <= left.bv_len)
855 if (aci_strbvcmp(val->bv_val, &right) == 0)
857 } else if (val->bv_len >= left.bv_len) {
858 if (strncasecmp( val->bv_val, left.bv_val, left.bv_len ) == 0)
868 aci_list_get_attr_rights (struct berval *list, char *attr, struct berval *val)
874 /* loop through each rights/attr pair, skip first part (action) */
876 for (i = 1; aci_get_part(list, i + 1, ';', &bv) >= 0; i += 2) {
877 if (aci_list_has_attr(&bv, attr, val) == 0)
879 if (aci_get_part(list, i, ';', &bv) < 0)
881 mask |= aci_list_map_rights(&bv);
887 aci_list_get_rights (
891 slap_access_t *grant,
894 struct berval perm, actn;
898 if (attr == NULL || *attr == 0 || strcasecmp(attr, "entry") == 0) {
905 /* loop through each permissions clause */
906 for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) {
907 if (aci_get_part(&perm, 0, ';', &actn) < 0)
909 if (aci_strbvcmp( "grant", &actn ) == 0) {
911 } else if (aci_strbvcmp( "deny", &actn ) == 0) {
918 *mask |= aci_list_get_attr_rights(&perm, attr, val);
919 *mask |= aci_list_get_attr_rights(&perm, "[all]", NULL);
936 char *subjdn, *grpdn;
939 /* format of string is "group/objectClassValue/groupAttrName" */
940 if (aci_get_part(subj, 0, '/', &bv) < 0)
942 subjdn = aci_bvstrdup(&bv);
946 if (aci_get_part(subj, 1, '/', &bv) < 0)
947 grpoc = ch_strdup(grpoc);
949 grpoc = aci_bvstrdup(&bv);
951 if (aci_get_part(subj, 2, '/', &bv) < 0)
952 grpat = ch_strdup(grpat);
954 grpat = aci_bvstrdup(&bv);
956 grpdn = (char *)ch_malloc(1024);
957 if (grpoc != NULL && grpat != NULL && grpdn != NULL) {
958 string_expand(grpdn, 1024, subjdn, e->e_ndn, matches);
959 if ( dn_normalize(grpdn) != NULL ) {
960 rc = (backend_group(be, e, grpdn, op->o_ndn, grpoc, grpat) == 0);
981 slap_access_t *grant,
985 struct berval bv, perms, sdn;
989 /* parse an aci of the form:
990 oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN
992 See draft-ietf-ldapext-aci-model-04.txt section 9.1 for
993 a full description of the format for this attribute.
995 For now, this routine only supports scope=entry.
998 /* check that the aci has all 5 components */
999 if (aci_get_part(aci, 4, '#', NULL) < 0)
1002 /* check that the aci family is supported */
1003 if (aci_get_part(aci, 0, '#', &bv) < 0)
1005 for (i = 0; supportedACIMechs[i] != NULL; i++) {
1006 if (aci_strbvcmp( supportedACIMechs[i], &bv ) == 0)
1009 if (supportedACIMechs[i] == NULL)
1012 /* check that the scope is "entry" */
1013 if (aci_get_part(aci, 1, '#', &bv) < 0
1014 || aci_strbvcmp( "entry", &bv ) != 0)
1019 /* get the list of permissions clauses, bail if empty */
1020 if (aci_get_part(aci, 2, '#', &perms) <= 0)
1023 /* check if any permissions allow desired access */
1024 if (aci_list_get_rights(&perms, attr, val, grant, deny) == 0)
1027 /* see if we have a DN match */
1028 if (aci_get_part(aci, 3, '#', &bv) < 0)
1031 if (aci_get_part(aci, 4, '#', &sdn) < 0)
1034 if (aci_strbvcmp( "access-id", &bv ) == 0) {
1035 subjdn = aci_bvstrdup(&sdn);
1039 if ( dn_normalize(subjdn) != NULL )
1040 if (strcasecmp(op->o_ndn, subjdn) != 0)
1046 if (aci_strbvcmp( "self", &bv ) == 0) {
1047 if (strcasecmp(op->o_ndn, e->e_ndn) == 0)
1050 } else if (aci_strbvcmp( "dnattr", &bv ) == 0) {
1054 attrname = aci_bvstrdup(&sdn);
1055 at = attr_find(e->e_attrs, attrname);
1059 bv.bv_val = op->o_ndn;
1060 bv.bv_len = strlen( bv.bv_val );
1062 if (value_find( at->a_vals, &bv, at->a_syntax, 3 ) == 0 )
1066 } else if (aci_strbvcmp( "group", &bv ) == 0) {
1067 if (aci_group_member(&sdn, "groupOfNames", "member", be, e, op, matches))
1070 } else if (aci_strbvcmp( "role", &bv ) == 0) {
1071 if (aci_group_member(&sdn, "organizationalRole", "roleOccupant", be, e, op, matches))
1079 get_supported_acimech (int index)
1081 if (index < 0 || index >= (sizeof(supportedACIMechs) / sizeof(char *)))
1083 return(supportedACIMechs[index]);
1086 #endif /* SLAPD_ACI_ENABLED */
1094 regmatch_t *matches)
1103 bufsiz--; /* leave space for lone $ */
1106 for ( dp = newbuf, sp = pat; size < bufsiz && *sp ; sp++) {
1107 /* did we previously see a $ */
1112 } else if (*sp >= '0' && *sp <= '9' ) {
1119 i = matches[n].rm_so;
1120 l = matches[n].rm_eo;
1121 for ( ; size < 512 && i < l; size++, i++ ) {
1139 /* must have ended with a single $ */
1146 Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern: %s\n", pat, 0, 0 );
1147 Debug( LDAP_DEBUG_TRACE, "=> string_expand: expanded: %s\n", newbuf, 0, 0 );
1152 char *pat, /* pattern to expand and match against */
1153 char *str, /* string to match against pattern */
1154 char *buf, /* buffer with $N expansion variables */
1155 regmatch_t *matches /* offsets in buffer for $N expansion variables */
1162 if(str == NULL) str = "";
1164 string_expand(newbuf, sizeof(newbuf), pat, buf, matches);
1165 if (( rc = regcomp(&re, newbuf, REG_EXTENDED|REG_ICASE))) {
1167 regerror(rc, &re, error, sizeof(error));
1169 Debug( LDAP_DEBUG_TRACE,
1170 "compile( \"%s\", \"%s\") failed %s\n",
1175 rc = regexec(&re, str, 0, NULL, 0);
1178 Debug( LDAP_DEBUG_TRACE,
1179 "=> regex_matches: string: %s\n", str, 0, 0 );
1180 Debug( LDAP_DEBUG_TRACE,
1181 "=> regex_matches: rc: %d %s\n",
1182 rc, !rc ? "matches" : "no matches", 0 );