1 /* acl.c - routines to parse and check acl's */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/socket.h>
14 #include <ac/string.h>
20 #define ACL_BUF_SIZE 1024 /* use most appropriate size */
26 aci_bv_entry = BER_BVC("entry"),
27 aci_bv_br_entry = BER_BVC("[entry]"),
28 aci_bv_br_all = BER_BVC("[all]"),
29 aci_bv_access_id = BER_BVC("access-id"),
30 aci_bv_anonymous = BER_BVC("anonymous"),
31 aci_bv_users = BER_BVC("users"),
32 aci_bv_self = BER_BVC("self"),
33 aci_bv_dnattr = BER_BVC("dnattr"),
34 aci_bv_group = BER_BVC("group"),
35 aci_bv_role = BER_BVC("role"),
36 aci_bv_set = BER_BVC("set"),
37 aci_bv_set_ref = BER_BVC("set-ref"),
38 aci_bv_grant = BER_BVC("grant"),
39 aci_bv_deny = BER_BVC("deny"),
41 aci_bv_group_class = BER_BVC(SLAPD_GROUP_CLASS),
42 aci_bv_group_attr = BER_BVC(SLAPD_GROUP_ATTR),
43 aci_bv_role_class = BER_BVC(SLAPD_ROLE_CLASS),
44 aci_bv_role_attr = BER_BVC(SLAPD_ROLE_ATTR);
47 static AccessControl * acl_get(
48 AccessControl *ac, int *count,
49 Backend *be, Operation *op,
51 AttributeDescription *desc,
52 int nmatches, regmatch_t *matches );
54 static slap_control_t acl_mask(
55 AccessControl *ac, slap_mask_t *mask,
56 Backend *be, Connection *conn, Operation *op,
58 AttributeDescription *desc,
62 AccessControlState *state );
64 #ifdef SLAPD_ACI_ENABLED
70 AttributeDescription *desc,
75 slap_access_t *deny );
78 static int regex_matches(
79 struct berval *pat, char *str, char *buf, regmatch_t *matches);
80 static void string_expand(
81 struct berval *newbuf, struct berval *pattern,
82 char *match, regmatch_t *matches);
84 typedef struct AciSetCookie {
91 SLAP_SET_GATHER aci_set_gather;
92 static int aci_match_set ( struct berval *subj, Backend *be,
93 Entry *e, Connection *conn, Operation *op, int setref );
96 * access_allowed - check whether op->o_ndn is allowed the requested access
97 * to entry e, attribute attr, value val. if val is null, access to
98 * the whole attribute is assumed (all values).
100 * This routine loops through all access controls and calls
101 * acl_mask() on each applicable access control.
102 * The loop exits when a definitive answer is reached or
103 * or no more controls remain.
116 AttributeDescription *desc,
118 slap_access_t access,
119 AccessControlState *state )
126 char accessmaskbuf[ACCESSMASK_MAXLEN];
129 slap_control_t control;
131 regmatch_t matches[MAXREMATCHES];
134 assert( desc != NULL );
135 assert( access > ACL_NONE );
137 attr = desc->ad_cname.bv_val;
139 assert( attr != NULL );
141 if( state && state->as_recorded ) {
142 if( state->as_recorded & ACL_STATE_RECORDED_NV &&
145 return state->as_result;
147 } else if ( state->as_recorded & ACL_STATE_RECORDED_VD &&
148 val != NULL && state->as_vd_acl == NULL )
150 return state->as_result;
155 LDAP_LOG( ACL, ENTRY,
156 "access_allowed: %s access to \"%s\" \"%s\" requested\n",
157 access2str( access ), e->e_dn, attr );
159 Debug( LDAP_DEBUG_ACL,
160 "=> access_allowed: %s access to \"%s\" \"%s\" requested\n",
161 access2str( access ), e->e_dn, attr );
169 if ( be == NULL ) be = &backends[0];
170 assert( be != NULL );
172 /* grant database root access */
173 if ( be != NULL && be_isroot( be, &op->o_ndn ) ) {
176 "access_allowed: conn %lu root access granted\n",
177 conn->c_connid, 0, 0 );
179 Debug( LDAP_DEBUG_ACL,
180 "<= root access granted\n",
187 * no-user-modification operational attributes are ignored
188 * by ACL_WRITE checking as any found here are not provided
191 if ( access >= ACL_WRITE && is_at_no_user_mod( desc->ad_type )
192 && desc != slap_schema.si_ad_entry
193 && desc != slap_schema.si_ad_children )
196 LDAP_LOG( ACL, DETAIL1,
197 "access_allowed: conn %lu NoUserMod Operational attribute: %s "
198 "access granted\n", conn->c_connid, attr , 0 );
200 Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
201 " %s access granted\n",
207 /* use backend default access if no backend acls */
208 if( be != NULL && be->be_acl == NULL ) {
210 LDAP_LOG( ACL, DETAIL1,
211 "access_allowed: backend default %s access %s to \"%s\"\n",
212 access2str( access ),
213 be->be_dfltaccess >= access ? "granted" : "denied",
216 Debug( LDAP_DEBUG_ACL,
217 "=> access_allowed: backend default %s access %s to \"%s\"\n",
218 access2str( access ),
219 be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn.bv_val );
221 ret = be->be_dfltaccess >= access;
225 /* be is always non-NULL */
226 /* use global default access if no global acls */
227 } else if ( be == NULL && global_acl == NULL ) {
229 LDAP_LOG( ACL, DETAIL1,
230 "access_allowed: global default %s access %s to \"%s\"\n",
231 access2str( access ),
232 global_default_access >= access ? "granted" : "denied",
235 Debug( LDAP_DEBUG_ACL,
236 "=> access_allowed: global default %s access %s to \"%s\"\n",
237 access2str( access ),
238 global_default_access >= access ? "granted" : "denied", op->o_dn.bv_val );
240 ret = global_default_access >= access;
248 if( state && ( state->as_recorded & ACL_STATE_RECORDED_VD )) {
249 assert( state->as_vd_acl != NULL );
251 a = state->as_vd_acl;
252 mask = state->as_vd_acl_mask;
253 count = state->as_vd_acl_count;
254 AC_MEMCPY( matches, state->as_vd_acl_matches,
262 memset(matches, '\0', sizeof(matches));
265 while((a = acl_get( a, &count, be, op, e, desc,
266 MAXREMATCHES, matches )) != NULL)
270 for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) {
272 LDAP_LOG( ACL, DETAIL1,
273 "access_allowed: match[%d]: %d %d ",
274 i, (int)matches[i].rm_so, (int)matches[i].rm_eo );
276 Debug( LDAP_DEBUG_ACL, "=> match[%d]: %d %d ", i,
277 (int)matches[i].rm_so, (int)matches[i].rm_eo );
279 if( matches[i].rm_so <= matches[0].rm_eo ) {
281 for ( n = matches[i].rm_so; n < matches[i].rm_eo; n++) {
282 Debug( LDAP_DEBUG_ACL, "%c", e->e_ndn[n], 0, 0 );
286 LDAP_LOG( ACL, ARGS, "\n" , 0, 0, 0 );
288 Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 );
293 control = acl_mask( a, &mask, be, conn, op,
294 e, desc, val, matches, count, state );
296 if ( control != ACL_BREAK ) {
300 memset(matches, '\0', sizeof(matches));
303 if ( ACL_IS_INVALID( mask ) ) {
305 LDAP_LOG( ACL, DETAIL1,
306 "access_allowed: conn %lu \"%s\" (%s) invalid!\n",
307 conn->c_connid, e->e_dn, attr );
309 Debug( LDAP_DEBUG_ACL,
310 "=> access_allowed: \"%s\" (%s) invalid!\n",
315 } else if ( control == ACL_BREAK ) {
317 LDAP_LOG( ACL, DETAIL1,
318 "access_allowed: conn %lu no more rules\n", conn->c_connid, 0,0 );
320 Debug( LDAP_DEBUG_ACL,
321 "=> access_allowed: no more rules\n", 0, 0, 0);
328 LDAP_LOG( ACL, ENTRY,
329 "access_allowed: %s access %s by %s\n",
330 access2str( access ), ACL_GRANT( mask, access ) ? "granted" : "denied",
331 accessmask2str( mask, accessmaskbuf ) );
333 Debug( LDAP_DEBUG_ACL,
334 "=> access_allowed: %s access %s by %s\n",
335 access2str( access ),
336 ACL_GRANT(mask, access) ? "granted" : "denied",
337 accessmask2str( mask, accessmaskbuf ) );
340 ret = ACL_GRANT(mask, access);
343 if( state != NULL ) {
344 state->as_recorded |= ACL_STATE_RECORDED;
345 state->as_result = ret;
351 * acl_get - return the acl applicable to entry e, attribute
352 * attr. the acl returned is suitable for use in subsequent calls to
353 * acl_access_allowed().
356 static AccessControl *
363 AttributeDescription *desc,
365 regmatch_t *matches )
371 assert( count != NULL );
372 assert( desc != NULL );
374 attr = desc->ad_cname.bv_val;
376 assert( attr != NULL );
391 dnlen = e->e_nname.bv_len;
393 for ( ; a != NULL; a = a->acl_next ) {
396 if ( a->acl_dn_pat.bv_len || ( a->acl_dn_style != ACL_STYLE_REGEX )) {
397 if ( a->acl_dn_style == ACL_STYLE_REGEX ) {
399 LDAP_LOG( ACL, DETAIL1,
400 "acl_get: dnpat [%d] %s nsub: %d\n",
401 *count, a->acl_dn_pat.bv_val,
402 (int) a->acl_dn_re.re_nsub );
404 Debug( LDAP_DEBUG_ACL, "=> dnpat: [%d] %s nsub: %d\n",
405 *count, a->acl_dn_pat.bv_val, (int) a->acl_dn_re.re_nsub );
407 if (regexec(&a->acl_dn_re, e->e_ndn, nmatch, matches, 0))
412 LDAP_LOG( ACL, DETAIL1, "acl_get: dn [%d] %s\n",
413 *count, a->acl_dn_pat.bv_val, 0 );
415 Debug( LDAP_DEBUG_ACL, "=> dn: [%d] %s\n",
416 *count, a->acl_dn_pat.bv_val, 0 );
418 patlen = a->acl_dn_pat.bv_len;
419 if ( dnlen < patlen )
422 if ( a->acl_dn_style == ACL_STYLE_BASE ) {
423 /* base dn -- entire object DN must match */
424 if ( dnlen != patlen )
427 } else if ( a->acl_dn_style == ACL_STYLE_ONE ) {
430 if ( dnlen <= patlen )
433 if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
436 rdnlen = dn_rdnlen( NULL, &e->e_nname );
437 if ( rdnlen != dnlen - patlen - 1 )
440 } else if ( a->acl_dn_style == ACL_STYLE_SUBTREE ) {
441 if ( dnlen > patlen && !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
444 } else if ( a->acl_dn_style == ACL_STYLE_CHILDREN ) {
445 if ( dnlen <= patlen )
447 if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
451 if ( strcmp( a->acl_dn_pat.bv_val, e->e_ndn + dnlen - patlen ) != 0 )
456 LDAP_LOG( ACL, DETAIL1,
457 "acl_get: [%d] matched\n", *count, 0, 0 );
459 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] matched\n",
464 if ( a->acl_filter != NULL ) {
465 ber_int_t rc = test_filter( NULL, NULL, NULL, e, a->acl_filter );
466 if ( rc != LDAP_COMPARE_TRUE ) {
472 LDAP_LOG( ACL, DETAIL1,
473 "acl_get: [%d] check attr %s\n", *count, attr ,0 );
475 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] check attr %s\n",
478 if ( attr == NULL || a->acl_attrs == NULL ||
479 ad_inlist( desc, a->acl_attrs ) )
482 LDAP_LOG( ACL, DETAIL1,
483 "acl_get: [%d] acl %s attr: %s\n", *count, e->e_dn, attr );
485 Debug( LDAP_DEBUG_ACL,
486 "<= acl_get: [%d] acl %s attr: %s\n",
487 *count, e->e_dn, attr );
491 matches[0].rm_so = matches[0].rm_eo = -1;
495 LDAP_LOG( ACL, RESULTS, "acl_get: done.\n", 0, 0, 0 );
497 Debug( LDAP_DEBUG_ACL, "<= acl_get: done.\n", 0, 0, 0 );
503 * Record value-dependent access control state
505 #define ACL_RECORD_VALUE_STATE do { \
506 if( state && !( state->as_recorded & ACL_STATE_RECORDED_VD )) { \
507 state->as_recorded |= ACL_STATE_RECORDED_VD; \
508 state->as_vd_acl = a; \
509 AC_MEMCPY( state->as_vd_acl_matches, matches, \
510 sizeof( state->as_vd_acl_matches )) ; \
511 state->as_vd_acl_count = count; \
512 state->as_vd_access = b; \
513 state->as_vd_access_count = i; \
518 * acl_mask - modifies mask based upon the given acl and the
519 * requested access to entry e, attribute attr, value val. if val
520 * is null, access to the whole attribute is assumed (all values).
522 * returns 0 access NOT allowed
526 static slap_control_t
534 AttributeDescription *desc,
538 AccessControlState *state )
540 int i, odnlen, patlen;
543 char accessmaskbuf[ACCESSMASK_MAXLEN];
548 assert( mask != NULL );
549 assert( desc != NULL );
551 attr = desc->ad_cname.bv_val;
553 assert( attr != NULL );
556 LDAP_LOG( ACL, ENTRY,
557 "acl_mask: conn %lu access to entry \"%s\", attr \"%s\" requested\n",
558 conn->c_connid, e->e_dn, attr );
561 " to %s by \"%s\", (%s) \n", val ? "value" : "all values",
562 op->o_ndn.bv_val ? op->o_ndn.bv_val : "",
563 accessmask2str( *mask, accessmaskbuf ) );
565 Debug( LDAP_DEBUG_ACL,
566 "=> acl_mask: access to entry \"%s\", attr \"%s\" requested\n",
569 Debug( LDAP_DEBUG_ACL,
570 "=> acl_mask: to %s by \"%s\", (%s) \n",
571 val ? "value" : "all values",
572 op->o_ndn.bv_val ? op->o_ndn.bv_val : "",
573 accessmask2str( *mask, accessmaskbuf ) );
576 if( state && ( state->as_recorded & ACL_STATE_RECORDED_VD )
577 && state->as_vd_acl == a )
579 b = state->as_vd_access;
580 i = state->as_vd_access_count;
587 for ( ; b != NULL; b = b->a_next, i++ ) {
588 slap_mask_t oldmask, modmask;
590 ACL_INVALIDATE( modmask );
592 /* AND <who> clauses */
593 if ( b->a_dn_pat.bv_len != 0 ) {
595 LDAP_LOG( ACL, DETAIL1,
596 "acl_mask: conn %lu check a_dn_pat: %s\n",
597 conn->c_connid, b->a_dn_pat.bv_val ,0 );
599 Debug( LDAP_DEBUG_ACL, "<= check a_dn_pat: %s\n",
600 b->a_dn_pat.bv_val, 0, 0);
603 * if access applies to the entry itself, and the
604 * user is bound as somebody in the same namespace as
605 * the entry, OR the given dn matches the dn pattern
607 if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
608 if ( op->o_ndn.bv_len != 0 ) {
612 } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
613 if ( op->o_ndn.bv_len == 0 ) {
617 } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
618 if ( op->o_ndn.bv_len == 0 ) {
622 if ( e->e_dn == NULL || !dn_match( &e->e_nname, &op->o_ndn ) ) {
626 } else if ( b->a_dn_style == ACL_STYLE_REGEX ) {
627 if ( !ber_bvccmp( &b->a_dn_pat, '*' ) ) {
628 int ret = regex_matches( &b->a_dn_pat,
629 op->o_ndn.bv_val, e->e_ndn, matches );
640 if ( e->e_dn == NULL )
643 if ( b->a_dn_expand ) {
645 char buf[ACL_BUF_SIZE];
647 bv.bv_len = sizeof( buf ) - 1;
650 string_expand(&bv, &b->a_dn_pat,
652 if ( dnNormalize2(NULL, &bv, &pat) != LDAP_SUCCESS ) {
653 /* did not expand to a valid dn */
661 odnlen = op->o_ndn.bv_len;
662 if ( odnlen < patlen ) {
663 goto dn_match_cleanup;
667 if ( b->a_dn_style == ACL_STYLE_BASE ) {
668 /* base dn -- entire object DN must match */
669 if ( odnlen != patlen ) {
670 goto dn_match_cleanup;
673 } else if ( b->a_dn_style == ACL_STYLE_ONE ) {
676 if ( odnlen <= patlen ) {
677 goto dn_match_cleanup;
680 if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) ) {
681 goto dn_match_cleanup;
684 rdnlen = dn_rdnlen( NULL, &op->o_ndn );
685 if ( rdnlen != odnlen - patlen - 1 ) {
686 goto dn_match_cleanup;
689 } else if ( b->a_dn_style == ACL_STYLE_SUBTREE ) {
690 if ( odnlen > patlen && !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) ) {
691 goto dn_match_cleanup;
694 } else if ( b->a_dn_style == ACL_STYLE_CHILDREN ) {
695 if ( odnlen <= patlen ) {
696 goto dn_match_cleanup;
699 if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) ) {
700 goto dn_match_cleanup;
704 got_match = !strcmp( pat.bv_val, op->o_ndn.bv_val + odnlen - patlen );
707 if ( pat.bv_val != b->a_dn_pat.bv_val ) {
717 if ( b->a_sockurl_pat.bv_len ) {
719 LDAP_LOG( ACL, DETAIL1,
720 "acl_mask: conn %lu check a_sockurl_pat: %s\n",
721 conn->c_connid, b->a_sockurl_pat.bv_val , 0 );
723 Debug( LDAP_DEBUG_ACL, "<= check a_sockurl_pat: %s\n",
724 b->a_sockurl_pat.bv_val, 0, 0 );
727 if ( !ber_bvccmp( &b->a_sockurl_pat, '*' ) ) {
728 if ( b->a_sockurl_style == ACL_STYLE_REGEX) {
729 if (!regex_matches( &b->a_sockurl_pat, conn->c_listener_url.bv_val,
730 e->e_ndn, matches ) )
735 if ( ber_bvstrcasecmp( &b->a_sockurl_pat, &conn->c_listener_url ) != 0 )
741 if ( b->a_domain_pat.bv_len ) {
743 LDAP_LOG( ACL, DETAIL1,
744 "acl_mask: conn %lu check a_domain_pat: %s\n",
745 conn->c_connid, b->a_domain_pat.bv_val , 0 );
747 Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n",
748 b->a_domain_pat.bv_val, 0, 0 );
750 if ( !ber_bvccmp( &b->a_domain_pat, '*' ) ) {
751 if ( b->a_domain_style == ACL_STYLE_REGEX) {
752 if (!regex_matches( &b->a_domain_pat, conn->c_peer_domain.bv_val,
753 e->e_ndn, matches ) )
758 char buf[ACL_BUF_SIZE];
760 struct berval cmp = conn->c_peer_domain;
761 struct berval pat = b->a_domain_pat;
763 if ( b->a_domain_expand ) {
766 bv.bv_len = sizeof(buf);
769 string_expand(&bv, &b->a_domain_pat, e->e_ndn, matches);
773 if ( b->a_domain_style == ACL_STYLE_SUBTREE ) {
774 int offset = cmp.bv_len - pat.bv_len;
779 if ( offset == 1 || ( offset > 1 && cmp.bv_val[ offset - 1 ] != '.' ) ) {
783 /* trim the domain */
784 cmp.bv_val = &cmp.bv_val[ offset ];
785 cmp.bv_len -= offset;
788 if ( ber_bvstrcasecmp( &pat, &cmp ) != 0 ) {
795 if ( b->a_peername_pat.bv_len ) {
797 LDAP_LOG( ACL, DETAIL1,
798 "acl_mask: conn %lu check a_perrname_path: %s\n",
799 conn->c_connid, b->a_peername_pat.bv_val , 0 );
801 Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n",
802 b->a_peername_pat.bv_val, 0, 0 );
804 if ( !ber_bvccmp( &b->a_peername_pat, '*' ) ) {
805 if ( b->a_peername_style == ACL_STYLE_REGEX) {
806 if (!regex_matches( &b->a_peername_pat, conn->c_peer_name.bv_val,
807 e->e_ndn, matches ) )
812 if ( ber_bvstrcasecmp( &b->a_peername_pat, &conn->c_peer_name ) != 0 )
818 if ( b->a_sockname_pat.bv_len ) {
820 LDAP_LOG( ACL, DETAIL1,
821 "acl_mask: conn %lu check a_sockname_path: %s\n",
822 conn->c_connid, b->a_sockname_pat.bv_val , 0 );
824 Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n",
825 b->a_sockname_pat.bv_val, 0, 0 );
827 if ( !ber_bvccmp( &b->a_sockname_pat, '*' ) ) {
828 if ( b->a_sockname_style == ACL_STYLE_REGEX) {
829 if (!regex_matches( &b->a_sockname_pat, conn->c_sock_name.bv_val,
830 e->e_ndn, matches ) )
835 if ( ber_bvstrcasecmp( &b->a_sockname_pat, &conn->c_sock_name ) != 0 )
841 if ( b->a_dn_at != NULL ) {
846 const char *attr = b->a_dn_at->ad_cname.bv_val;
848 assert( attr != NULL );
850 if ( op->o_ndn.bv_len == 0 ) {
855 LDAP_LOG( ACL, DETAIL1,
856 "acl_mask: conn %lu check a_dn_pat: %s\n",
857 conn->c_connid, attr , 0 );
859 Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n",
864 /* see if asker is listed in dnattr */
865 for( at = attrs_find( e->e_attrs, b->a_dn_at );
867 at = attrs_find( at->a_next, b->a_dn_at ) )
869 if( value_find( b->a_dn_at, at->a_vals, &bv ) == 0 ) {
877 /* have a dnattr match. if this is a self clause then
878 * the target must also match the op dn.
880 if ( b->a_dn_self ) {
881 /* check if the target is an attribute. */
884 /* target is attribute, check if the attribute value
887 rc = value_match( &match, b->a_dn_at,
888 b->a_dn_at->ad_type->sat_equality, 0,
890 /* on match error or no match, fail the ACL clause */
891 if (rc != LDAP_SUCCESS || match != 0 )
895 /* no dnattr match, check if this is a self clause */
896 if ( ! b->a_dn_self )
899 ACL_RECORD_VALUE_STATE;
901 /* this is a self clause, check if the target is an
907 /* target is attribute, check if the attribute value
910 rc = value_match( &match, b->a_dn_at,
911 b->a_dn_at->ad_type->sat_equality, 0,
914 /* on match error or no match, fail the ACL clause */
915 if (rc != LDAP_SUCCESS || match != 0 )
920 if ( b->a_group_pat.bv_len ) {
921 char buf[ACL_BUF_SIZE];
923 struct berval ndn = { 0, NULL };
926 if ( op->o_ndn.bv_len == 0 ) {
930 bv.bv_len = sizeof(buf) - 1;
933 /* b->a_group is an unexpanded entry name, expanded it should be an
934 * entry with objectclass group* and we test to see if odn is one of
935 * the values in the attribute group
937 /* see if asker is listed in dnattr */
938 if ( b->a_group_style == ACL_STYLE_REGEX ) {
939 string_expand(&bv, &b->a_group_pat, e->e_ndn, matches);
940 if ( dnNormalize2(NULL, &bv, &ndn) != LDAP_SUCCESS ) {
941 /* did not expand to a valid dn */
949 rc = backend_group(be, conn, op, e, &bv, &op->o_ndn,
950 b->a_group_oc, b->a_group_at);
958 if ( b->a_set_pat.bv_len != 0 ) {
959 if (aci_match_set( &b->a_set_pat, be, e, conn, op, 0 ) == 0) {
964 if ( b->a_authz.sai_ssf ) {
966 LDAP_LOG( ACL, DETAIL1,
967 "acl_mask: conn %lu check a_authz.sai_ssf: ACL %u > OP %u\n",
968 conn->c_connid, b->a_authz.sai_ssf, op->o_ssf );
970 Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_ssf: ACL %u > OP %u\n",
971 b->a_authz.sai_ssf, op->o_ssf, 0 );
973 if ( b->a_authz.sai_ssf > op->o_ssf ) {
978 if ( b->a_authz.sai_transport_ssf ) {
980 LDAP_LOG( ACL, DETAIL1,
981 "acl_mask: conn %lu check a_authz.sai_transport_ssf: "
983 conn->c_connid, b->a_authz.sai_transport_ssf,
984 op->o_transport_ssf );
986 Debug( LDAP_DEBUG_ACL,
987 "<= check a_authz.sai_transport_ssf: ACL %u > OP %u\n",
988 b->a_authz.sai_transport_ssf, op->o_transport_ssf, 0 );
990 if ( b->a_authz.sai_transport_ssf > op->o_transport_ssf ) {
995 if ( b->a_authz.sai_tls_ssf ) {
997 LDAP_LOG( ACL, DETAIL1,
998 "acl_mask: conn %lu check a_authz.sai_tls_ssf: ACL %u > "
1000 conn->c_connid, b->a_authz.sai_tls_ssf, op->o_tls_ssf );
1002 Debug( LDAP_DEBUG_ACL,
1003 "<= check a_authz.sai_tls_ssf: ACL %u > OP %u\n",
1004 b->a_authz.sai_tls_ssf, op->o_tls_ssf, 0 );
1006 if ( b->a_authz.sai_tls_ssf > op->o_tls_ssf ) {
1011 if ( b->a_authz.sai_sasl_ssf ) {
1013 LDAP_LOG( ACL, DETAIL1,
1014 "acl_mask: conn %lu check a_authz.sai_sasl_ssf: "
1016 conn->c_connid, b->a_authz.sai_sasl_ssf, op->o_sasl_ssf );
1018 Debug( LDAP_DEBUG_ACL,
1019 "<= check a_authz.sai_sasl_ssf: ACL %u > OP %u\n",
1020 b->a_authz.sai_sasl_ssf, op->o_sasl_ssf, 0 );
1022 if ( b->a_authz.sai_sasl_ssf > op->o_sasl_ssf ) {
1027 #ifdef SLAPD_ACI_ENABLED
1028 if ( b->a_aci_at != NULL ) {
1030 slap_access_t grant, deny, tgrant, tdeny;
1032 /* this case works different from the others above.
1033 * since aci's themselves give permissions, we need
1034 * to first check b->a_access_mask, the ACL's access level.
1037 if ( e->e_nname.bv_len == 0 ) {
1038 /* no ACIs in the root DSE */
1042 /* first check if the right being requested
1043 * is allowed by the ACL clause.
1045 if ( ! ACL_GRANT( b->a_access_mask, *mask ) ) {
1049 /* get the aci attribute */
1050 at = attr_find( e->e_attrs, b->a_aci_at );
1055 ACL_RECORD_VALUE_STATE;
1057 /* start out with nothing granted, nothing denied */
1061 /* the aci is an multi-valued attribute. The
1062 * rights are determined by OR'ing the individual
1063 * rights given by the acis.
1065 for ( i = 0; at->a_vals[i].bv_val != NULL; i++ ) {
1066 if (aci_mask( be, conn, op,
1067 e, desc, val, &at->a_vals[i],
1068 matches, &grant, &deny ) != 0)
1075 /* remove anything that the ACL clause does not allow */
1076 tgrant &= b->a_access_mask & ACL_PRIV_MASK;
1077 tdeny &= ACL_PRIV_MASK;
1079 /* see if we have anything to contribute */
1080 if( ACL_IS_INVALID(tgrant) && ACL_IS_INVALID(tdeny) ) {
1084 /* this could be improved by changing acl_mask so that it can deal with
1085 * by clauses that return grant/deny pairs. Right now, it does either
1086 * additive or subtractive rights, but not both at the same time. So,
1087 * we need to combine the grant/deny pair into a single rights mask in
1088 * a smart way: if either grant or deny is "empty", then we use the
1089 * opposite as is, otherwise we remove any denied rights from the grant
1090 * rights mask and construct an additive mask.
1092 if (ACL_IS_INVALID(tdeny)) {
1093 modmask = tgrant | ACL_PRIV_ADDITIVE;
1095 } else if (ACL_IS_INVALID(tgrant)) {
1096 modmask = tdeny | ACL_PRIV_SUBSTRACTIVE;
1099 modmask = (tgrant & ~tdeny) | ACL_PRIV_ADDITIVE;
1105 modmask = b->a_access_mask;
1109 LDAP_LOG( ACL, RESULTS,
1110 "acl_mask: [%d] applying %s (%s)\n",
1111 i, accessmask2str( modmask, accessmaskbuf),
1112 b->a_type == ACL_CONTINUE ? "continue" : b->a_type == ACL_BREAK
1113 ? "break" : "stop" );
1115 Debug( LDAP_DEBUG_ACL,
1116 "<= acl_mask: [%d] applying %s (%s)\n",
1117 i, accessmask2str( modmask, accessmaskbuf ),
1118 b->a_type == ACL_CONTINUE
1120 : b->a_type == ACL_BREAK
1127 if( ACL_IS_ADDITIVE(modmask) ) {
1129 ACL_PRIV_SET( *mask, modmask );
1132 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
1134 } else if( ACL_IS_SUBTRACTIVE(modmask) ) {
1135 /* substract privs */
1136 ACL_PRIV_CLR( *mask, modmask );
1139 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
1147 LDAP_LOG( ACL, DETAIL1,
1148 "acl_mask: conn %lu [%d] mask: %s\n",
1149 conn->c_connid, i, accessmask2str( *mask, accessmaskbuf) );
1151 Debug( LDAP_DEBUG_ACL,
1152 "<= acl_mask: [%d] mask: %s\n",
1153 i, accessmask2str(*mask, accessmaskbuf), 0 );
1156 if( b->a_type == ACL_CONTINUE ) {
1159 } else if ( b->a_type == ACL_BREAK ) {
1167 /* implicit "by * none" clause */
1171 LDAP_LOG( ACL, RESULTS,
1172 "acl_mask: conn %lu no more <who> clauses, returning %d (stop)\n",
1173 conn->c_connid, accessmask2str( *mask, accessmaskbuf) , 0 );
1175 Debug( LDAP_DEBUG_ACL,
1176 "<= acl_mask: no more <who> clauses, returning %s (stop)\n",
1177 accessmask2str(*mask, accessmaskbuf), 0, 0 );
1183 * acl_check_modlist - check access control on the given entry to see if
1184 * it allows the given modifications by the user associated with op.
1185 * returns 1 if mods allowed ok
1186 * 0 mods not allowed
1195 Modifications *mlist
1200 assert( be != NULL );
1202 /* short circuit root database access */
1203 if ( be_isroot( be, &op->o_ndn ) ) {
1205 LDAP_LOG( ACL, DETAIL1,
1206 "acl_check_modlist: conn %lu access granted to root user\n",
1207 conn->c_connid, 0, 0 );
1209 Debug( LDAP_DEBUG_ACL,
1210 "<= acl_access_allowed: granted to database root\n",
1216 /* use backend default access if no backend acls */
1217 if( be != NULL && be->be_acl == NULL ) {
1219 LDAP_LOG( ACL, DETAIL1,
1220 "acl_check_modlist: backend default %s access %s to \"%s\"\n",
1221 access2str( ACL_WRITE ),
1222 be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied",
1225 Debug( LDAP_DEBUG_ACL,
1226 "=> access_allowed: backend default %s access %s to \"%s\"\n",
1227 access2str( ACL_WRITE ),
1228 be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn.bv_val );
1230 return be->be_dfltaccess >= ACL_WRITE;
1233 /* be is always non-NULL */
1234 /* use global default access if no global acls */
1235 } else if ( be == NULL && global_acl == NULL ) {
1237 LDAP_LOG( ACL, DETAIL1,
1238 "acl_check_modlist: global default %s access %s to \"%s\"\n",
1239 access2str( ACL_WRITE ),
1240 global_default_access >= ACL_WRITE ? "granted" : "denied",
1243 Debug( LDAP_DEBUG_ACL,
1244 "=> access_allowed: global default %s access %s to \"%s\"\n",
1245 access2str( ACL_WRITE ),
1246 global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn );
1248 return global_default_access >= ACL_WRITE;
1252 for ( ; mlist != NULL; mlist = mlist->sml_next ) {
1253 static AccessControlState state_init = ACL_STATE_INIT;
1254 AccessControlState state;
1257 * no-user-modification operational attributes are ignored
1258 * by ACL_WRITE checking as any found here are not provided
1261 if ( is_at_no_user_mod( mlist->sml_desc->ad_type ) ) {
1263 LDAP_LOG( ACL, DETAIL1,
1264 "acl_check_modlist: conn %lu no-user-mod %s: modify access granted\n",
1265 conn->c_connid, mlist->sml_desc->ad_cname.bv_val , 0 );
1267 Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
1268 " modify access granted\n",
1269 mlist->sml_desc->ad_cname.bv_val, 0, 0 );
1276 switch ( mlist->sml_op ) {
1277 case LDAP_MOD_REPLACE:
1279 * We must check both permission to delete the whole
1280 * attribute and permission to add the specific attributes.
1281 * This prevents abuse from selfwriters.
1283 if ( ! access_allowed( be, conn, op, e,
1284 mlist->sml_desc, NULL, ACL_WRITE, &state ) )
1289 if ( mlist->sml_bvalues == NULL ) break;
1291 /* fall thru to check value to add */
1294 assert( mlist->sml_bvalues != NULL );
1296 for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ ) {
1297 if ( ! access_allowed( be, conn, op, e,
1298 mlist->sml_desc, bv, ACL_WRITE, &state ) )
1305 case LDAP_MOD_DELETE:
1306 if ( mlist->sml_bvalues == NULL ) {
1307 if ( ! access_allowed( be, conn, op, e,
1308 mlist->sml_desc, NULL, ACL_WRITE, NULL ) )
1314 for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ ) {
1315 if ( ! access_allowed( be, conn, op, e,
1316 mlist->sml_desc, bv, ACL_WRITE, &state ) )
1323 case SLAP_MOD_SOFTADD:
1324 /* allow adding attribute via modrdn thru */
1338 struct berval *list,
1352 while (len >= 0 && --ix >= 0) {
1353 while (--len >= 0 && *p++ != sep) ;
1355 while (len >= 0 && *p == ' ') {
1366 while (--len >= 0 && *p != sep) {
1370 while (bv->bv_len > 0 && *--p == ' ')
1376 aci_set_gather (void *cookie, struct berval *name, struct berval *attr)
1378 AciSetCookie *cp = cookie;
1379 BerVarray bvals = NULL;
1382 /* this routine needs to return the bervals instead of
1383 * plain strings, since syntax is not known. It should
1384 * also return the syntax or some "comparison cookie".
1387 if (dnNormalize2(NULL, name, &ndn) == LDAP_SUCCESS) {
1389 AttributeDescription *desc = NULL;
1390 if (slap_bv2ad(attr, &desc, &text) == LDAP_SUCCESS) {
1391 backend_attribute(cp->be, NULL, NULL,
1392 cp->e, &ndn, desc, &bvals);
1401 struct berval *subj,
1409 struct berval set = { 0, NULL };
1411 AciSetCookie cookie;
1414 ber_dupbv( &set, subj );
1416 struct berval subjdn, ndn = { 0, NULL };
1417 struct berval setat;
1420 AttributeDescription *desc = NULL;
1422 /* format of string is "entry/setAttrName" */
1423 if (aci_get_part(subj, 0, '/', &subjdn) < 0) {
1427 if ( aci_get_part(subj, 1, '/', &setat) < 0 ) {
1428 setat.bv_val = SLAPD_ACI_SET_ATTR;
1429 setat.bv_len = sizeof(SLAPD_ACI_SET_ATTR)-1;
1432 if ( setat.bv_val != NULL ) {
1434 * NOTE: dnNormalize2 honors the ber_len field
1435 * as the length of the dn to be normalized
1437 if ( dnNormalize2(NULL, &subjdn, &ndn) == LDAP_SUCCESS
1438 && slap_bv2ad(&setat, &desc, &text) == LDAP_SUCCESS )
1440 backend_attribute(be, NULL, NULL, e,
1441 &ndn, desc, &bvals);
1442 if ( bvals != NULL ) {
1443 if ( bvals[0].bv_val != NULL ) {
1446 bvals[0].bv_val = NULL;
1447 for (i=1;bvals[i].bv_val;i++);
1448 bvals[0].bv_val = bvals[i-1].bv_val;
1449 bvals[i-1].bv_val = NULL;
1451 ber_bvarray_free(bvals);
1459 if (set.bv_val != NULL) {
1464 rc = (slap_set_filter(aci_set_gather, &cookie, &set,
1465 &op->o_ndn, &e->e_nname, NULL) > 0);
1466 ch_free(set.bv_val);
1471 #ifdef SLAPD_ACI_ENABLED
1473 aci_list_map_rights(
1474 struct berval *list )
1481 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
1484 switch (*bv.bv_val) {
1486 ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
1489 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
1490 * the right 's' to mean "set", but in the examples states
1491 * that the right 's' means "search". The latter definition
1494 ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
1497 ACL_PRIV_SET(mask, ACL_PRIV_READ);
1500 ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
1503 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not
1504 * define any equivalent to the AUTH right, so I've just used
1507 ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
1519 struct berval *list,
1520 const struct berval *attr,
1521 struct berval *val )
1523 struct berval bv, left, right;
1526 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
1527 if (aci_get_part(&bv, 0, '=', &left) < 0
1528 || aci_get_part(&bv, 1, '=', &right) < 0)
1530 if (ber_bvstrcasecmp(attr, &bv) == 0)
1532 } else if (val == NULL) {
1533 if (ber_bvstrcasecmp(attr, &left) == 0)
1536 if (ber_bvstrcasecmp(attr, &left) == 0) {
1537 /* this is experimental code that implements a
1538 * simple (prefix) match of the attribute value.
1539 * the ACI draft does not provide for aci's that
1540 * apply to specific values, but it would be
1541 * nice to have. If the <attr> part of an aci's
1542 * rights list is of the form <attr>=<value>,
1543 * that means the aci applies only to attrs with
1544 * the given value. Furthermore, if the attr is
1545 * of the form <attr>=<value>*, then <value> is
1546 * treated as a prefix, and the aci applies to
1547 * any value with that prefix.
1549 * Ideally, this would allow r.e. matches.
1551 if (aci_get_part(&right, 0, '*', &left) < 0
1552 || right.bv_len <= left.bv_len)
1554 if (ber_bvstrcasecmp(val, &right) == 0)
1556 } else if (val->bv_len >= left.bv_len) {
1557 if (strncasecmp( val->bv_val, left.bv_val, left.bv_len ) == 0)
1566 static slap_access_t
1567 aci_list_get_attr_rights(
1568 struct berval *list,
1569 const struct berval *attr,
1570 struct berval *val )
1576 /* loop through each rights/attr pair, skip first part (action) */
1578 for (i = 1; aci_get_part(list, i + 1, ';', &bv) >= 0; i += 2) {
1579 if (aci_list_has_attr(&bv, attr, val) == 0)
1581 if (aci_get_part(list, i, ';', &bv) < 0)
1583 mask |= aci_list_map_rights(&bv);
1589 aci_list_get_rights(
1590 struct berval *list,
1591 const struct berval *attr,
1593 slap_access_t *grant,
1594 slap_access_t *deny )
1596 struct berval perm, actn;
1597 slap_access_t *mask;
1600 if (attr == NULL || attr->bv_len == 0
1601 || ber_bvstrcasecmp( attr, &aci_bv_entry ) == 0) {
1602 attr = &aci_bv_br_entry;
1608 /* loop through each permissions clause */
1609 for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) {
1610 if (aci_get_part(&perm, 0, ';', &actn) < 0)
1612 if (ber_bvstrcasecmp( &aci_bv_grant, &actn ) == 0) {
1614 } else if (ber_bvstrcasecmp( &aci_bv_deny, &actn ) == 0) {
1621 *mask |= aci_list_get_attr_rights(&perm, attr, val);
1622 *mask |= aci_list_get_attr_rights(&perm, &aci_bv_br_all, NULL);
1629 struct berval *subj,
1630 struct berval *defgrpoc,
1631 struct berval *defgrpat,
1639 struct berval subjdn;
1640 struct berval grpoc;
1641 struct berval grpat;
1642 ObjectClass *grp_oc = NULL;
1643 AttributeDescription *grp_ad = NULL;
1647 /* format of string is "group/objectClassValue/groupAttrName" */
1648 if (aci_get_part(subj, 0, '/', &subjdn) < 0) {
1652 if (aci_get_part(subj, 1, '/', &grpoc) < 0) {
1656 if (aci_get_part(subj, 2, '/', &grpat) < 0) {
1660 rc = slap_bv2ad( &grpat, &grp_ad, &text );
1661 if( rc != LDAP_SUCCESS ) {
1667 grp_oc = oc_bvfind( &grpoc );
1669 if (grp_oc != NULL && grp_ad != NULL ) {
1670 char buf[ACL_BUF_SIZE];
1671 struct berval bv, ndn;
1672 bv.bv_len = sizeof( buf );
1673 bv.bv_val = (char *)&buf;
1674 string_expand(&bv, &subjdn, e->e_ndn, matches);
1675 if ( dnNormalize2(NULL, &bv, &ndn) == LDAP_SUCCESS ) {
1676 rc = (backend_group(be, conn, op, e, &ndn, &op->o_ndn, grp_oc, grp_ad) == 0);
1691 AttributeDescription *desc,
1694 regmatch_t *matches,
1695 slap_access_t *grant,
1699 struct berval bv, perms, sdn;
1703 assert( desc->ad_cname.bv_val != NULL );
1705 /* parse an aci of the form:
1706 oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN
1708 See draft-ietf-ldapext-aci-model-04.txt section 9.1 for
1709 a full description of the format for this attribute.
1711 For now, this routine only supports scope=entry.
1714 /* check that the aci has all 5 components */
1715 if (aci_get_part(aci, 4, '#', NULL) < 0)
1718 /* check that the aci family is supported */
1719 if (aci_get_part(aci, 0, '#', &bv) < 0)
1722 /* check that the scope is "entry" */
1723 if (aci_get_part(aci, 1, '#', &bv) < 0
1724 || ber_bvstrcasecmp( &aci_bv_entry, &bv ) != 0)
1729 /* get the list of permissions clauses, bail if empty */
1730 if (aci_get_part(aci, 2, '#', &perms) <= 0)
1733 /* check if any permissions allow desired access */
1734 if (aci_list_get_rights(&perms, &desc->ad_cname, val, grant, deny) == 0)
1737 /* see if we have a DN match */
1738 if (aci_get_part(aci, 3, '#', &bv) < 0)
1741 if (aci_get_part(aci, 4, '#', &sdn) < 0)
1744 if (ber_bvstrcasecmp( &aci_bv_access_id, &bv ) == 0) {
1747 if ( dnNormalize2(NULL, &sdn, &ndn) == LDAP_SUCCESS ) {
1748 if (!dn_match( &op->o_ndn, &ndn))
1754 } else if (ber_bvstrcasecmp( &aci_bv_self, &bv ) == 0) {
1755 if (dn_match(&op->o_ndn, &e->e_nname))
1758 } else if (ber_bvstrcasecmp( &aci_bv_dnattr, &bv ) == 0) {
1760 AttributeDescription *ad = NULL;
1763 rc = slap_bv2ad( &sdn, &ad, &text );
1765 if( rc != LDAP_SUCCESS ) {
1773 for(at = attrs_find( e->e_attrs, ad );
1775 at = attrs_find( at->a_next, ad ) )
1777 if (value_find( ad, at->a_vals, &bv) == 0 ) {
1786 } else if (ber_bvstrcasecmp( &aci_bv_group, &bv ) == 0) {
1787 if (aci_group_member(&sdn, &aci_bv_group_class, &aci_bv_group_attr, be, e, conn, op, matches))
1790 } else if (ber_bvstrcasecmp( &aci_bv_role, &bv ) == 0) {
1791 if (aci_group_member(&sdn, &aci_bv_role_class, &aci_bv_role_attr, be, e, conn, op, matches))
1794 } else if (ber_bvstrcasecmp( &aci_bv_set, &bv ) == 0) {
1795 if (aci_match_set(&sdn, be, e, conn, op, 0))
1798 } else if (ber_bvstrcasecmp( &aci_bv_set_ref, &bv ) == 0) {
1799 if (aci_match_set(&sdn, be, e, conn, op, 1))
1807 #endif /* SLAPD_ACI_ENABLED */
1814 regmatch_t *matches)
1822 bv->bv_val[0] = '\0';
1823 bv->bv_len--; /* leave space for lone $ */
1826 for ( dp = bv->bv_val, sp = pat->bv_val; size < bv->bv_len &&
1827 sp < pat->bv_val + pat->bv_len ; sp++) {
1828 /* did we previously see a $ */
1830 if ( flag == 1 && *sp == '$' ) {
1835 } else if ( flag == 1 && *sp == '{') {
1838 } else if ( *sp >= '0' && *sp <= '9' ) {
1846 for ( sp++; *sp != '\0' && *sp != /* { */ '}'; sp++ ) {
1847 if ( *sp >= '0' && *sp <= '9' ) {
1848 n = 10*n + ( *sp - '0' );
1852 if ( *sp != /* { */ '}' ) {
1857 if ( n >= MAXREMATCHES ) {
1862 i = matches[n].rm_so;
1863 l = matches[n].rm_eo;
1864 for ( ; size < bv->bv_len && i < l; size++, i++ ) {
1882 /* must have ended with a single $ */
1891 LDAP_LOG( ACL, DETAIL1,
1892 "string_expand: pattern = %.*s\n", (int)pat->bv_len, pat->bv_val, 0 );
1893 LDAP_LOG( ACL, DETAIL1, "string_expand: expanded = %s\n", bv->bv_val, 0, 0 );
1895 Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern: %.*s\n", (int)pat->bv_len, pat->bv_val, 0 );
1896 Debug( LDAP_DEBUG_TRACE, "=> string_expand: expanded: %s\n", bv->bv_val, 0, 0 );
1902 struct berval *pat, /* pattern to expand and match against */
1903 char *str, /* string to match against pattern */
1904 char *buf, /* buffer with $N expansion variables */
1905 regmatch_t *matches /* offsets in buffer for $N expansion variables */
1913 bv.bv_len = sizeof(newbuf);
1916 if(str == NULL) str = "";
1918 string_expand(&bv, pat, buf, matches);
1919 if (( rc = regcomp(&re, newbuf, REG_EXTENDED|REG_ICASE))) {
1921 regerror(rc, &re, error, sizeof(error));
1925 "regex_matches: compile( \"%s\", \"%s\") failed %s\n",
1926 pat->bv_val, str, error );
1928 Debug( LDAP_DEBUG_TRACE,
1929 "compile( \"%s\", \"%s\") failed %s\n",
1930 pat->bv_val, str, error );
1935 rc = regexec(&re, str, 0, NULL, 0);
1939 LDAP_LOG( ACL, DETAIL2, "regex_matches: string: %s\n", str, 0, 0 );
1940 LDAP_LOG( ACL, DETAIL2, "regex_matches: rc: %d %s\n",
1941 rc, rc ? "matches" : "no matches", 0 );
1943 Debug( LDAP_DEBUG_TRACE,
1944 "=> regex_matches: string: %s\n", str, 0, 0 );
1945 Debug( LDAP_DEBUG_TRACE,
1946 "=> regex_matches: rc: %d %s\n",
1947 rc, !rc ? "matches" : "no matches", 0 );