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>
25 aci_bv_entry = { sizeof("entry") - 1, "entry" },
26 aci_bv_br_entry = { sizeof("[entry]") - 1, "[entry]" },
27 aci_bv_br_all = { sizeof("[all]") - 1, "[all]" },
28 aci_bv_access_id = { sizeof("access-id") - 1, "access-id" },
29 aci_bv_anonymous = { sizeof("anonymous") - 1, "anonymous" },
30 aci_bv_users = { sizeof("users") - 1, "users" },
31 aci_bv_self = { sizeof("self") - 1, "self" },
32 aci_bv_dnattr = { sizeof("dnattr") - 1, "dnattr" },
33 aci_bv_group = { sizeof("group") - 1, "group" },
34 aci_bv_role = { sizeof("role") - 1, "role" },
35 aci_bv_set = { sizeof("set") - 1, "set" },
36 aci_bv_set_ref = { sizeof("set-ref") - 1, "set-ref"},
37 aci_bv_grant = { sizeof("grant") - 1, "grant" },
38 aci_bv_deny = { sizeof("deny") - 1, "deny" };
40 static AccessControl * acl_get(
41 AccessControl *ac, int *count,
42 Backend *be, Operation *op,
44 AttributeDescription *desc,
45 int nmatches, regmatch_t *matches );
47 static slap_control_t acl_mask(
48 AccessControl *ac, slap_mask_t *mask,
49 Backend *be, Connection *conn, Operation *op,
51 AttributeDescription *desc,
55 AccessControlState *state );
57 #ifdef SLAPD_ACI_ENABLED
63 AttributeDescription *desc,
68 slap_access_t *deny );
71 static int regex_matches(
72 struct berval *pat, char *str, char *buf, regmatch_t *matches);
73 static void string_expand(
74 struct berval *newbuf, struct berval *pattern,
75 char *match, regmatch_t *matches);
77 typedef struct AciSetCookie {
84 SLAP_SET_GATHER aci_set_gather;
85 static int aci_match_set ( struct berval *subj, Backend *be,
86 Entry *e, Connection *conn, Operation *op, int setref );
89 * access_allowed - check whether op->o_ndn is allowed the requested access
90 * to entry e, attribute attr, value val. if val is null, access to
91 * the whole attribute is assumed (all values).
93 * This routine loops through all access controls and calls
94 * acl_mask() on each applicable access control.
95 * The loop exits when a definitive answer is reached or
96 * or no more controls remain.
109 AttributeDescription *desc,
111 slap_access_t access,
112 AccessControlState *state )
118 char accessmaskbuf[ACCESSMASK_MAXLEN];
121 slap_control_t control;
123 regmatch_t matches[MAXREMATCHES];
126 assert( desc != NULL );
127 assert( access > ACL_NONE );
129 attr = desc->ad_cname.bv_val;
131 assert( attr != NULL );
133 if( state && state->as_recorded ) {
134 if( state->as_recorded & ACL_STATE_RECORDED_NV &&
137 return state->as_result;
139 } else if ( state->as_recorded & ACL_STATE_RECORDED_VD &&
140 val != NULL && state->as_vd_acl == NULL )
142 return state->as_result;
147 LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
148 "access_allowed: conn %d %s access to \"%s\" \"%s\" requested\n",
149 conn ? conn->c_connid : -1, access2str( access ), e->e_dn, attr ));
151 Debug( LDAP_DEBUG_ACL,
152 "=> access_allowed: %s access to \"%s\" \"%s\" requested\n",
153 access2str( access ), e->e_dn, attr );
161 if ( be == NULL ) be = &backends[0];
162 assert( be != NULL );
164 /* grant database root access */
165 if ( be != NULL && be_isroot( be, &op->o_ndn ) ) {
167 LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
168 "access_allowed: conn %d root access granted\n",
171 Debug( LDAP_DEBUG_ACL,
172 "<= root access granted\n",
179 * no-user-modification operational attributes are ignored
180 * by ACL_WRITE checking as any found here are not provided
183 if ( access >= ACL_WRITE && is_at_no_user_mod( desc->ad_type )
184 && desc != slap_schema.si_ad_entry
185 && desc != slap_schema.si_ad_children )
188 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
189 "access_allowed: conn %d NoUserMod Operational attribute: %s access granted\n",
190 conn->c_connid, attr ));
192 Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
193 " %s access granted\n",
199 /* use backend default access if no backend acls */
200 if( be != NULL && be->be_acl == NULL ) {
202 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
203 "access_allowed: conn %d backend default %s access %s to \"%s\"\n",
204 conn->c_connid, access2str( access ),
205 be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn.bv_val ));
207 Debug( LDAP_DEBUG_ACL,
208 "=> access_allowed: backend default %s access %s to \"%s\"\n",
209 access2str( access ),
210 be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn.bv_val );
212 ret = be->be_dfltaccess >= access;
216 /* be is always non-NULL */
217 /* use global default access if no global acls */
218 } else if ( be == NULL && global_acl == NULL ) {
220 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
221 "access_allowed: conn %d global default %s access %s to \"%s\"\n",
222 conn->c_connid, access2str( access ),
223 global_default_access >= access ? "granted" : "denied", op->o_dn.bv_val ));
225 Debug( LDAP_DEBUG_ACL,
226 "=> access_allowed: global default %s access %s to \"%s\"\n",
227 access2str( access ),
228 global_default_access >= access ? "granted" : "denied", op->o_dn.bv_val );
230 ret = global_default_access >= access;
238 if( state && ( state->as_recorded & ACL_STATE_RECORDED_VD )) {
239 assert( state->as_vd_acl != NULL );
241 a = state->as_vd_acl;
242 mask = state->as_vd_acl_mask;
243 count = state->as_vd_acl_count;
244 AC_MEMCPY( matches, state->as_vd_acl_matches,
252 memset(matches, '\0', sizeof(matches));
255 while((a = acl_get( a, &count, be, op, e, desc,
256 MAXREMATCHES, matches )) != NULL)
260 for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) {
262 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
263 "access_allowed: conn %d match[%d]: %d %d ",
265 (int)matches[i].rm_so, (int)matches[i].rm_eo ));
267 Debug( LDAP_DEBUG_ACL, "=> match[%d]: %d %d ", i,
268 (int)matches[i].rm_so, (int)matches[i].rm_eo );
270 if( matches[i].rm_so <= matches[0].rm_eo ) {
272 for ( n = matches[i].rm_so; n < matches[i].rm_eo; n++) {
273 Debug( LDAP_DEBUG_ACL, "%c", e->e_ndn[n], 0, 0 );
277 LDAP_LOG(( "acl", LDAP_LEVEL_ARGS, "\n" ));
279 Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 );
284 control = acl_mask( a, &mask, be, conn, op,
285 e, desc, val, matches, count, state );
287 if ( control != ACL_BREAK ) {
291 memset(matches, '\0', sizeof(matches));
294 if ( ACL_IS_INVALID( mask ) ) {
296 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
297 "access_allowed: conn %d \"%s\" (%s) invalid!\n",
298 conn->c_connid, e->e_dn, attr ));
300 Debug( LDAP_DEBUG_ACL,
301 "=> access_allowed: \"%s\" (%s) invalid!\n",
306 } else if ( control == ACL_BREAK ) {
308 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
309 "access_allowed: conn %d no more rules\n", conn->c_connid ));
311 Debug( LDAP_DEBUG_ACL,
312 "=> access_allowed: no more rules\n", 0, 0, 0);
319 LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
320 "access_allowed: conn %d %s access %s by %s\n",
322 access2str( access ),
323 ACL_GRANT( mask, access ) ? "granted" : "denied",
324 accessmask2str( mask, accessmaskbuf ) ));
326 Debug( LDAP_DEBUG_ACL,
327 "=> access_allowed: %s access %s by %s\n",
328 access2str( access ),
329 ACL_GRANT(mask, access) ? "granted" : "denied",
330 accessmask2str( mask, accessmaskbuf ) );
333 ret = ACL_GRANT(mask, access);
336 if( state != NULL ) {
337 state->as_recorded |= ACL_STATE_RECORDED;
338 state->as_result = ret;
344 * acl_get - return the acl applicable to entry e, attribute
345 * attr. the acl returned is suitable for use in subsequent calls to
346 * acl_access_allowed().
349 static AccessControl *
356 AttributeDescription *desc,
358 regmatch_t *matches )
364 assert( count != NULL );
365 assert( desc != NULL );
367 attr = desc->ad_cname.bv_val;
369 assert( attr != NULL );
384 dnlen = e->e_nname.bv_len;
386 for ( ; a != NULL; a = a->acl_next ) {
389 if (a->acl_dn_pat.bv_len != 0) {
390 if ( a->acl_dn_style == ACL_STYLE_REGEX ) {
392 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
393 "acl_get: dnpat [%d] %s nsub: %d\n",
394 *count, a->acl_dn_pat.bv_val, (int) a->acl_dn_re.re_nsub ));
396 Debug( LDAP_DEBUG_ACL, "=> dnpat: [%d] %s nsub: %d\n",
397 *count, a->acl_dn_pat.bv_val, (int) a->acl_dn_re.re_nsub );
399 if (regexec(&a->acl_dn_re, e->e_ndn, nmatch, matches, 0))
404 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
405 "acl_get: dn [%d] %s\n",
406 *count, a->acl_dn_pat.bv_val ));
408 Debug( LDAP_DEBUG_ACL, "=> dn: [%d] %s\n",
409 *count, a->acl_dn_pat.bv_val, 0 );
411 patlen = a->acl_dn_pat.bv_len;
412 if ( dnlen < patlen )
415 if ( a->acl_dn_style == ACL_STYLE_BASE ) {
416 /* base dn -- entire object DN must match */
417 if ( dnlen != patlen )
420 } else if ( a->acl_dn_style == ACL_STYLE_ONE ) {
423 if ( dnlen <= patlen )
426 if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
429 rdnlen = dn_rdnlen( NULL, &e->e_nname );
430 if ( rdnlen != dnlen - patlen - 1 )
433 } else if ( a->acl_dn_style == ACL_STYLE_SUBTREE ) {
434 if ( dnlen > patlen && !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
437 } else if ( a->acl_dn_style == ACL_STYLE_CHILDREN ) {
438 if ( dnlen <= patlen )
440 if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) )
444 if ( strcmp( a->acl_dn_pat.bv_val, e->e_ndn + dnlen - patlen ) != 0 )
449 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
450 "acl_get: [%d] matched\n",
453 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] matched\n",
458 if ( a->acl_filter != NULL ) {
459 ber_int_t rc = test_filter( NULL, NULL, NULL, e, a->acl_filter );
460 if ( rc != LDAP_COMPARE_TRUE ) {
466 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
467 "acl_get: [%d] check attr %s\n",
470 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] check attr %s\n",
473 if ( attr == NULL || a->acl_attrs == NULL ||
474 ad_inlist( desc, a->acl_attrs ) )
477 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
478 "acl_get: [%d] acl %s attr: %s\n",
479 *count, e->e_dn, attr ));
481 Debug( LDAP_DEBUG_ACL,
482 "<= acl_get: [%d] acl %s attr: %s\n",
483 *count, e->e_dn, attr );
487 matches[0].rm_so = matches[0].rm_eo = -1;
491 LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
492 "acl_get: done.\n" ));
494 Debug( LDAP_DEBUG_ACL, "<= acl_get: done.\n", 0, 0, 0 );
500 * Record value-dependent access control state
502 #define ACL_RECORD_VALUE_STATE do { \
503 if( state && !( state->as_recorded & ACL_STATE_RECORDED_VD )) { \
504 state->as_recorded |= ACL_STATE_RECORDED_VD; \
505 state->as_vd_acl = a; \
506 AC_MEMCPY( state->as_vd_acl_matches, matches, \
507 sizeof( state->as_vd_acl_matches )) ; \
508 state->as_vd_acl_count = count; \
509 state->as_vd_access = b; \
510 state->as_vd_access_count = i; \
515 * acl_mask - modifies mask based upon the given acl and the
516 * requested access to entry e, attribute attr, value val. if val
517 * is null, access to the whole attribute is assumed (all values).
519 * returns 0 access NOT allowed
523 static slap_control_t
531 AttributeDescription *desc,
535 AccessControlState *state )
537 int i, odnlen, patlen;
541 char accessmaskbuf[ACCESSMASK_MAXLEN];
546 assert( mask != NULL );
547 assert( desc != NULL );
549 attr = desc->ad_cname.bv_val;
551 assert( attr != NULL );
554 LDAP_LOG(( "acl", LDAP_LEVEL_ENTRY,
555 "acl_mask: conn %d access to entry \"%s\", attr \"%s\" requested\n",
556 conn->c_connid, e->e_dn, attr ));
558 LDAP_LOG(( "acl", LDAP_LEVEL_ARGS,
559 " to %s by \"%s\", (%s) \n",
560 val ? "value" : "all values",
561 op->o_ndn.bv_val ? op->o_ndn.bv_val : "",
562 accessmask2str( *mask, accessmaskbuf ) ));
564 Debug( LDAP_DEBUG_ACL,
565 "=> acl_mask: access to entry \"%s\", attr \"%s\" requested\n",
568 Debug( LDAP_DEBUG_ACL,
569 "=> acl_mask: to %s by \"%s\", (%s) \n",
570 val ? "value" : "all values",
571 op->o_ndn.bv_val ? op->o_ndn.bv_val : "",
572 accessmask2str( *mask, accessmaskbuf ) );
575 if( state && ( state->as_recorded & ACL_STATE_RECORDED_VD )
576 && state->as_vd_acl == a )
578 b = state->as_vd_access;
579 i = state->as_vd_access_count;
586 for ( ; b != NULL; b = b->a_next, i++ ) {
587 slap_mask_t oldmask, modmask;
589 ACL_INVALIDATE( modmask );
591 /* AND <who> clauses */
592 if ( b->a_dn_pat.bv_len != 0 ) {
594 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
595 "acl_mask: conn %d check a_dn_pat: %s\n",
596 conn->c_connid, b->a_dn_pat.bv_val ));
598 Debug( LDAP_DEBUG_ACL, "<= check a_dn_pat: %s\n",
599 b->a_dn_pat.bv_val, 0, 0);
602 * if access applies to the entry itself, and the
603 * user is bound as somebody in the same namespace as
604 * the entry, OR the given dn matches the dn pattern
606 if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
607 if ( op->o_ndn.bv_len != 0 ) {
611 } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
612 if ( op->o_ndn.bv_len == 0 ) {
616 } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
617 if ( op->o_ndn.bv_len == 0 ) {
621 if ( e->e_dn == NULL || !dn_match( &e->e_nname, &op->o_ndn ) ) {
625 } else if ( b->a_dn_style == ACL_STYLE_REGEX ) {
626 if ( ber_bvccmp( &b->a_dn_pat, '*' ) == 0 ) {
627 int ret = regex_matches( &b->a_dn_pat,
628 op->o_ndn.bv_val, e->e_ndn, matches );
636 if ( e->e_dn == NULL )
639 patlen = b->a_dn_pat.bv_len;
640 odnlen = op->o_ndn.bv_len;
641 if ( odnlen < patlen )
644 if ( b->a_dn_style == ACL_STYLE_BASE ) {
645 /* base dn -- entire object DN must match */
646 if ( odnlen != patlen )
649 } else if ( b->a_dn_style == ACL_STYLE_ONE ) {
652 if ( odnlen <= patlen )
655 if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) )
658 rdnlen = dn_rdnlen( NULL, &op->o_ndn );
659 if ( rdnlen != odnlen - patlen - 1 )
662 } else if ( b->a_dn_style == ACL_STYLE_SUBTREE ) {
663 if ( odnlen > patlen && !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) )
666 } else if ( b->a_dn_style == ACL_STYLE_CHILDREN ) {
667 if ( odnlen <= patlen )
669 if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) )
673 if ( strcmp( b->a_dn_pat.bv_val, op->o_ndn.bv_val + odnlen - patlen ) != 0 )
678 if ( b->a_sockurl_pat.bv_len ) {
680 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
681 "acl_mask: conn %d check a_sockurl_pat: %s\n",
682 conn->c_connid, b->a_sockurl_pat.bv_val ));
684 Debug( LDAP_DEBUG_ACL, "<= check a_sockurl_pat: %s\n",
685 b->a_sockurl_pat.bv_val, 0, 0 );
688 if ( ber_bvccmp( &b->a_sockurl_pat, '*' ) != 0) {
689 if ( b->a_sockurl_style == ACL_STYLE_REGEX) {
690 if (!regex_matches( &b->a_sockurl_pat, conn->c_listener_url.bv_val,
691 e->e_ndn, matches ) )
696 if ( ber_bvstrcasecmp( &b->a_sockurl_pat, &conn->c_listener_url ) != 0 )
702 if ( b->a_domain_pat.bv_len ) {
704 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
705 "acl_mask: conn %d check a_domain_pat: %s\n",
706 conn->c_connid, b->a_domain_pat.bv_val ));
708 Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n",
709 b->a_domain_pat.bv_val, 0, 0 );
711 if ( ber_bvccmp( &b->a_domain_pat, '*' ) != 0) {
712 if ( b->a_domain_style == ACL_STYLE_REGEX) {
713 if (!regex_matches( &b->a_domain_pat, conn->c_peer_domain.bv_val,
714 e->e_ndn, matches ) )
719 if ( ber_bvstrcasecmp( &b->a_domain_pat, &conn->c_peer_domain ) != 0 )
725 if ( b->a_peername_pat.bv_len ) {
727 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
728 "acl_mask: conn %d check a_perrname_path: %s\n",
729 conn->c_connid, b->a_peername_pat.bv_val ));
731 Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n",
732 b->a_peername_pat.bv_val, 0, 0 );
734 if ( ber_bvccmp( &b->a_peername_pat, '*' ) != 0) {
735 if ( b->a_peername_style == ACL_STYLE_REGEX) {
736 if (!regex_matches( &b->a_peername_pat, conn->c_peer_name.bv_val,
737 e->e_ndn, matches ) )
742 if ( ber_bvstrcasecmp( &b->a_peername_pat, &conn->c_peer_name ) != 0 )
748 if ( b->a_sockname_pat.bv_len ) {
750 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
751 "acl_mask: conn %d check a_sockname_path: %s\n",
752 conn->c_connid, b->a_sockname_pat.bv_val ));
754 Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n",
755 b->a_sockname_pat.bv_val, 0, 0 );
757 if ( ber_bvccmp( &b->a_sockname_pat, '*' ) != 0) {
758 if ( b->a_sockname_style == ACL_STYLE_REGEX) {
759 if (!regex_matches( &b->a_sockname_pat, conn->c_sock_name.bv_val,
760 e->e_ndn, matches ) )
765 if ( ber_bvstrcasecmp( &b->a_sockname_pat, &conn->c_sock_name ) != 0 )
771 if ( b->a_dn_at != NULL ) {
776 const char *attr = b->a_dn_at->ad_cname.bv_val;
778 assert( attr != NULL );
780 if ( op->o_ndn.bv_len == 0 ) {
785 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
786 "acl_mask: conn %d check a_dn_pat: %s\n",
787 conn->c_connid, attr ));
789 Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n",
794 /* see if asker is listed in dnattr */
795 for( at = attrs_find( e->e_attrs, b->a_dn_at );
797 at = attrs_find( at->a_next, b->a_dn_at ) )
799 if( value_find( b->a_dn_at, at->a_vals, &bv ) == 0 ) {
807 /* have a dnattr match. if this is a self clause then
808 * the target must also match the op dn.
810 if ( b->a_dn_self ) {
811 /* check if the target is an attribute. */
814 /* target is attribute, check if the attribute value
817 rc = value_match( &match, b->a_dn_at,
818 b->a_dn_at->ad_type->sat_equality, 0,
820 /* on match error or no match, fail the ACL clause */
821 if (rc != LDAP_SUCCESS || match != 0 )
825 /* no dnattr match, check if this is a self clause */
826 if ( ! b->a_dn_self )
829 ACL_RECORD_VALUE_STATE;
831 /* this is a self clause, check if the target is an
837 /* target is attribute, check if the attribute value
840 rc = value_match( &match, b->a_dn_at,
841 b->a_dn_at->ad_type->sat_equality, 0,
844 /* on match error or no match, fail the ACL clause */
845 if (rc != LDAP_SUCCESS || match != 0 )
850 if ( b->a_group_pat.bv_len ) {
853 struct berval ndn = { 0, NULL };
856 if ( op->o_ndn.bv_len == 0 ) {
860 bv.bv_len = sizeof(buf) - 1;
863 /* b->a_group is an unexpanded entry name, expanded it should be an
864 * entry with objectclass group* and we test to see if odn is one of
865 * the values in the attribute group
867 /* see if asker is listed in dnattr */
868 if ( b->a_group_style == ACL_STYLE_REGEX ) {
869 string_expand(&bv, &b->a_group_pat, e->e_ndn, matches);
870 if ( dnNormalize2(NULL, &bv, &ndn) != LDAP_SUCCESS ) {
871 /* did not expand to a valid dn */
879 rc = backend_group(be, conn, op, e, &bv, &op->o_ndn,
880 b->a_group_oc, b->a_group_at);
888 if ( b->a_set_pat.bv_len != 0 ) {
889 if (aci_match_set( &b->a_set_pat, be, e, conn, op, 0 ) == 0) {
894 if ( b->a_authz.sai_ssf ) {
896 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
897 "acl_mask: conn %d check a_authz.sai_ssf: ACL %u > OP %u\n",
898 conn->c_connid, b->a_authz.sai_ssf, op->o_ssf ));
900 Debug( LDAP_DEBUG_ACL, "<= check a_authz.sai_ssf: ACL %u > OP %u\n",
901 b->a_authz.sai_ssf, op->o_ssf, 0 );
903 if ( b->a_authz.sai_ssf > op->o_ssf ) {
908 if ( b->a_authz.sai_transport_ssf ) {
910 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
911 "acl_mask: conn %d check a_authz.sai_transport_ssf: ACL %u > OP %u\n",
912 conn->c_connid, b->a_authz.sai_transport_ssf, op->o_transport_ssf ));
914 Debug( LDAP_DEBUG_ACL,
915 "<= check a_authz.sai_transport_ssf: ACL %u > OP %u\n",
916 b->a_authz.sai_transport_ssf, op->o_transport_ssf, 0 );
918 if ( b->a_authz.sai_transport_ssf > op->o_transport_ssf ) {
923 if ( b->a_authz.sai_tls_ssf ) {
925 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
926 "acl_mask: conn %d check a_authz.sai_tls_ssf: ACL %u > OP %u\n",
927 conn->c_connid, b->a_authz.sai_tls_ssf, op->o_tls_ssf ));
929 Debug( LDAP_DEBUG_ACL,
930 "<= check a_authz.sai_tls_ssf: ACL %u > OP %u\n",
931 b->a_authz.sai_tls_ssf, op->o_tls_ssf, 0 );
933 if ( b->a_authz.sai_tls_ssf > op->o_tls_ssf ) {
938 if ( b->a_authz.sai_sasl_ssf ) {
940 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
941 "acl_mask: conn %d check a_authz.sai_sasl_ssf: ACL %u > OP %u\n",
942 conn->c_connid, b->a_authz.sai_sasl_ssf, op->o_sasl_ssf ));
944 Debug( LDAP_DEBUG_ACL,
945 "<= check a_authz.sai_sasl_ssf: ACL %u > OP %u\n",
946 b->a_authz.sai_sasl_ssf, op->o_sasl_ssf, 0 );
948 if ( b->a_authz.sai_sasl_ssf > op->o_sasl_ssf ) {
953 #ifdef SLAPD_ACI_ENABLED
954 if ( b->a_aci_at != NULL ) {
956 slap_access_t grant, deny, tgrant, tdeny;
958 /* this case works different from the others above.
959 * since aci's themselves give permissions, we need
960 * to first check b->a_access_mask, the ACL's access level.
963 if ( e->e_nname.bv_len == 0 ) {
964 /* no ACIs in the root DSE */
968 /* first check if the right being requested
969 * is allowed by the ACL clause.
971 if ( ! ACL_GRANT( b->a_access_mask, *mask ) ) {
975 /* get the aci attribute */
976 at = attr_find( e->e_attrs, b->a_aci_at );
981 ACL_RECORD_VALUE_STATE;
983 /* start out with nothing granted, nothing denied */
987 /* the aci is an multi-valued attribute. The
988 * rights are determined by OR'ing the individual
989 * rights given by the acis.
991 for ( i = 0; at->a_vals[i].bv_val != NULL; i++ ) {
992 if (aci_mask( be, conn, op,
993 e, desc, val, &at->a_vals[i],
994 matches, &grant, &deny ) != 0)
1001 /* remove anything that the ACL clause does not allow */
1002 tgrant &= b->a_access_mask & ACL_PRIV_MASK;
1003 tdeny &= ACL_PRIV_MASK;
1005 /* see if we have anything to contribute */
1006 if( ACL_IS_INVALID(tgrant) && ACL_IS_INVALID(tdeny) ) {
1010 /* this could be improved by changing acl_mask so that it can deal with
1011 * by clauses that return grant/deny pairs. Right now, it does either
1012 * additive or subtractive rights, but not both at the same time. So,
1013 * we need to combine the grant/deny pair into a single rights mask in
1014 * a smart way: if either grant or deny is "empty", then we use the
1015 * opposite as is, otherwise we remove any denied rights from the grant
1016 * rights mask and construct an additive mask.
1018 if (ACL_IS_INVALID(tdeny)) {
1019 modmask = tgrant | ACL_PRIV_ADDITIVE;
1021 } else if (ACL_IS_INVALID(tgrant)) {
1022 modmask = tdeny | ACL_PRIV_SUBSTRACTIVE;
1025 modmask = (tgrant & ~tdeny) | ACL_PRIV_ADDITIVE;
1031 modmask = b->a_access_mask;
1035 LDAP_LOG(( "acl", LDAP_LEVEL_RESULTS,
1036 "acl_mask: conn %d [%d] applying %s (%s)\n",
1037 conn->c_connid, i, accessmask2str( modmask, accessmaskbuf),
1038 b->a_type == ACL_CONTINUE ? "continue" : b->a_type == ACL_BREAK
1039 ? "break" : "stop" ));
1041 Debug( LDAP_DEBUG_ACL,
1042 "<= acl_mask: [%d] applying %s (%s)\n",
1043 i, accessmask2str( modmask, accessmaskbuf ),
1044 b->a_type == ACL_CONTINUE
1046 : b->a_type == ACL_BREAK
1053 if( ACL_IS_ADDITIVE(modmask) ) {
1055 ACL_PRIV_SET( *mask, modmask );
1058 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
1060 } else if( ACL_IS_SUBTRACTIVE(modmask) ) {
1061 /* substract privs */
1062 ACL_PRIV_CLR( *mask, modmask );
1065 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
1073 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
1074 "acl_mask: conn %d [%d] mask: %s\n",
1075 conn->c_connid, i, accessmask2str( *mask, accessmaskbuf) ));
1077 Debug( LDAP_DEBUG_ACL,
1078 "<= acl_mask: [%d] mask: %s\n",
1079 i, accessmask2str(*mask, accessmaskbuf), 0 );
1082 if( b->a_type == ACL_CONTINUE ) {
1085 } else if ( b->a_type == ACL_BREAK ) {
1093 /* implicit "by * none" clause */
1097 LDAP_LOG(( "acl", LDAP_LEVEL_RESULTS,
1098 "acl_mask: conn %d no more <who> clauses, returning %d (stop)\n",
1099 conn->c_connid, accessmask2str( *mask, accessmaskbuf) ));
1101 Debug( LDAP_DEBUG_ACL,
1102 "<= acl_mask: no more <who> clauses, returning %s (stop)\n",
1103 accessmask2str(*mask, accessmaskbuf), 0, 0 );
1109 * acl_check_modlist - check access control on the given entry to see if
1110 * it allows the given modifications by the user associated with op.
1111 * returns 1 if mods allowed ok
1112 * 0 mods not allowed
1121 Modifications *mlist
1126 assert( be != NULL );
1128 /* short circuit root database access */
1129 if ( be_isroot( be, &op->o_ndn ) ) {
1131 LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1,
1132 "acl_check_modlist: conn %d access granted to root user\n",
1135 Debug( LDAP_DEBUG_ACL,
1136 "<= acl_access_allowed: granted to database root\n",
1142 /* use backend default access if no backend acls */
1143 if( be != NULL && be->be_acl == NULL ) {
1145 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
1146 "acl_check_modlist: conn %d backend default %s access %s to \"%s\"\n",
1147 conn->c_connid, access2str( ACL_WRITE ),
1148 be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn.bv_val ));
1150 Debug( LDAP_DEBUG_ACL,
1151 "=> access_allowed: backend default %s access %s to \"%s\"\n",
1152 access2str( ACL_WRITE ),
1153 be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn.bv_val );
1155 return be->be_dfltaccess >= ACL_WRITE;
1158 /* be is always non-NULL */
1159 /* use global default access if no global acls */
1160 } else if ( be == NULL && global_acl == NULL ) {
1162 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
1163 "acl_check_modlist: conn %d global default %s access %s to \"%s\"\n",
1164 conn->c_connid, access2str( ACL_WRITE ),
1165 global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn ));
1167 Debug( LDAP_DEBUG_ACL,
1168 "=> access_allowed: global default %s access %s to \"%s\"\n",
1169 access2str( ACL_WRITE ),
1170 global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn );
1172 return global_default_access >= ACL_WRITE;
1176 for ( ; mlist != NULL; mlist = mlist->sml_next ) {
1177 static AccessControlState state_init = ACL_STATE_INIT;
1178 AccessControlState state;
1181 * no-user-modification operational attributes are ignored
1182 * by ACL_WRITE checking as any found here are not provided
1185 if ( is_at_no_user_mod( mlist->sml_desc->ad_type ) ) {
1187 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
1188 "acl_check_modlist: conn %d no-user-mod %s: modify access granted\n",
1189 conn->c_connid, mlist->sml_desc->ad_cname.bv_val ));
1191 Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
1192 " modify access granted\n",
1193 mlist->sml_desc->ad_cname.bv_val, 0, 0 );
1200 switch ( mlist->sml_op ) {
1201 case LDAP_MOD_REPLACE:
1203 * We must check both permission to delete the whole
1204 * attribute and permission to add the specific attributes.
1205 * This prevents abuse from selfwriters.
1207 if ( ! access_allowed( be, conn, op, e,
1208 mlist->sml_desc, NULL, ACL_WRITE, &state ) )
1213 if ( mlist->sml_bvalues == NULL ) break;
1215 /* fall thru to check value to add */
1218 assert( mlist->sml_bvalues != NULL );
1220 for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ ) {
1221 if ( ! access_allowed( be, conn, op, e,
1222 mlist->sml_desc, bv, ACL_WRITE, &state ) )
1229 case LDAP_MOD_DELETE:
1230 if ( mlist->sml_bvalues == NULL ) {
1231 if ( ! access_allowed( be, conn, op, e,
1232 mlist->sml_desc, NULL, ACL_WRITE, NULL ) )
1238 for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ ) {
1239 if ( ! access_allowed( be, conn, op, e,
1240 mlist->sml_desc, bv, ACL_WRITE, &state ) )
1247 case SLAP_MOD_SOFTADD:
1248 /* allow adding attribute via modrdn thru */
1261 aci_bvstrdup( struct berval *bv )
1265 s = (char *)ch_malloc(bv->bv_len + 1);
1267 AC_MEMCPY(s, bv->bv_val, bv->bv_len);
1275 struct berval *list,
1289 while (len >= 0 && --ix >= 0) {
1290 while (--len >= 0 && *p++ != sep) ;
1292 while (len >= 0 && *p == ' ') {
1303 while (--len >= 0 && *p != sep) {
1307 while (bv->bv_len > 0 && *--p == ' ')
1313 aci_set_gather (void *cookie, struct berval *name, struct berval *attr)
1315 AciSetCookie *cp = cookie;
1316 BerVarray bvals = NULL;
1319 /* this routine needs to return the bervals instead of
1320 * plain strings, since syntax is not known. It should
1321 * also return the syntax or some "comparison cookie".
1324 if (dnNormalize2(NULL, name, &ndn) == LDAP_SUCCESS) {
1326 AttributeDescription *desc = NULL;
1327 if (slap_bv2ad(attr, &desc, &text) == LDAP_SUCCESS) {
1328 backend_attribute(cp->be, NULL, NULL,
1329 cp->e, &ndn, desc, &bvals);
1338 struct berval *subj,
1346 struct berval set = { 0, NULL };
1348 AciSetCookie cookie;
1351 ber_dupbv( &set, subj );
1353 struct berval subjdn, ndn = { 0, NULL };
1354 struct berval setat;
1357 AttributeDescription *desc = NULL;
1359 /* format of string is "entry/setAttrName" */
1360 if (aci_get_part(subj, 0, '/', &subjdn) < 0) {
1364 if ( aci_get_part(subj, 1, '/', &setat) < 0 ) {
1365 setat.bv_val = SLAPD_ACI_SET_ATTR;
1366 setat.bv_len = sizeof(SLAPD_ACI_SET_ATTR)-1;
1369 if ( setat.bv_val != NULL ) {
1371 * NOTE: dnNormalize2 honors the ber_len field
1372 * as the length of the dn to be normalized
1374 if ( dnNormalize2(NULL, &subjdn, &ndn) == LDAP_SUCCESS
1375 && slap_bv2ad(&setat, &desc, &text) == LDAP_SUCCESS )
1377 backend_attribute(be, NULL, NULL, e,
1378 &ndn, desc, &bvals);
1379 if ( bvals != NULL ) {
1380 if ( bvals[0].bv_val != NULL ) {
1383 bvals[0].bv_val = NULL;
1384 for (i=1;bvals[i].bv_val;i++);
1385 bvals[0].bv_val = bvals[i-1].bv_val;
1386 bvals[i-1].bv_val = NULL;
1388 ber_bvarray_free(bvals);
1396 if (set.bv_val != NULL) {
1401 rc = (slap_set_filter(aci_set_gather, &cookie, &set,
1402 &op->o_ndn, &e->e_nname, NULL) > 0);
1403 ch_free(set.bv_val);
1408 #ifdef SLAPD_ACI_ENABLED
1410 aci_list_map_rights(
1411 struct berval *list )
1418 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
1421 switch (*bv.bv_val) {
1423 ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
1426 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
1427 * the right 's' to mean "set", but in the examples states
1428 * that the right 's' means "search". The latter definition
1431 ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
1434 ACL_PRIV_SET(mask, ACL_PRIV_READ);
1437 ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
1440 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not
1441 * define any equivalent to the AUTH right, so I've just used
1444 ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
1456 struct berval *list,
1457 const struct berval *attr,
1458 struct berval *val )
1460 struct berval bv, left, right;
1463 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
1464 if (aci_get_part(&bv, 0, '=', &left) < 0
1465 || aci_get_part(&bv, 1, '=', &right) < 0)
1467 if (ber_bvstrcasecmp(attr, &bv) == 0)
1469 } else if (val == NULL) {
1470 if (ber_bvstrcasecmp(attr, &left) == 0)
1473 if (ber_bvstrcasecmp(attr, &left) == 0) {
1474 /* this is experimental code that implements a
1475 * simple (prefix) match of the attribute value.
1476 * the ACI draft does not provide for aci's that
1477 * apply to specific values, but it would be
1478 * nice to have. If the <attr> part of an aci's
1479 * rights list is of the form <attr>=<value>,
1480 * that means the aci applies only to attrs with
1481 * the given value. Furthermore, if the attr is
1482 * of the form <attr>=<value>*, then <value> is
1483 * treated as a prefix, and the aci applies to
1484 * any value with that prefix.
1486 * Ideally, this would allow r.e. matches.
1488 if (aci_get_part(&right, 0, '*', &left) < 0
1489 || right.bv_len <= left.bv_len)
1491 if (ber_bvstrcasecmp(val, &right) == 0)
1493 } else if (val->bv_len >= left.bv_len) {
1494 if (strncasecmp( val->bv_val, left.bv_val, left.bv_len ) == 0)
1503 static slap_access_t
1504 aci_list_get_attr_rights(
1505 struct berval *list,
1506 const struct berval *attr,
1507 struct berval *val )
1513 /* loop through each rights/attr pair, skip first part (action) */
1515 for (i = 1; aci_get_part(list, i + 1, ';', &bv) >= 0; i += 2) {
1516 if (aci_list_has_attr(&bv, attr, val) == 0)
1518 if (aci_get_part(list, i, ';', &bv) < 0)
1520 mask |= aci_list_map_rights(&bv);
1526 aci_list_get_rights(
1527 struct berval *list,
1528 const struct berval *attr,
1530 slap_access_t *grant,
1531 slap_access_t *deny )
1533 struct berval perm, actn;
1534 slap_access_t *mask;
1537 if (attr == NULL || attr->bv_len == 0
1538 || ber_bvstrcasecmp( attr, &aci_bv_entry ) == 0) {
1539 attr = &aci_bv_br_entry;
1545 /* loop through each permissions clause */
1546 for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) {
1547 if (aci_get_part(&perm, 0, ';', &actn) < 0)
1549 if (ber_bvstrcasecmp( &aci_bv_grant, &actn ) == 0) {
1551 } else if (ber_bvstrcasecmp( &aci_bv_deny, &actn ) == 0) {
1558 *mask |= aci_list_get_attr_rights(&perm, attr, val);
1559 *mask |= aci_list_get_attr_rights(&perm, &aci_bv_br_all, NULL);
1566 struct berval *subj,
1567 struct berval *defgrpoc,
1568 struct berval *defgrpat,
1577 struct berval subjdn;
1578 struct berval grpoc;
1579 struct berval grpat;
1580 ObjectClass *grp_oc = NULL;
1581 AttributeDescription *grp_ad = NULL;
1585 /* format of string is "group/objectClassValue/groupAttrName" */
1586 if (aci_get_part(subj, 0, '/', &subjdn) < 0) {
1590 if (aci_get_part(subj, 1, '/', &grpoc) < 0) {
1594 if (aci_get_part(subj, 2, '/', &grpat) < 0) {
1598 rc = slap_bv2ad( &grpat, &grp_ad, &text );
1599 if( rc != LDAP_SUCCESS ) {
1605 grp_oc = oc_bvfind( &grpoc );
1607 if (grp_oc != NULL && grp_ad != NULL ) {
1609 bv.bv_val = (char *)ch_malloc(1024);
1611 string_expand(&bv, &subjdn, e->e_ndn, matches);
1612 if ( dnNormalize2(NULL, &bv, &ndn) == LDAP_SUCCESS ) {
1613 rc = (backend_group(be, conn, op, e, &ndn, &op->o_ndn, grp_oc, grp_ad) == 0);
1623 static struct berval GroupClass = {
1624 sizeof(SLAPD_GROUP_CLASS)-1, SLAPD_GROUP_CLASS };
1625 static struct berval GroupAttr = {
1626 sizeof(SLAPD_GROUP_ATTR)-1, SLAPD_GROUP_ATTR };
1627 static struct berval RoleClass = {
1628 sizeof(SLAPD_ROLE_CLASS)-1, SLAPD_ROLE_CLASS };
1629 static struct berval RoleAttr = {
1630 sizeof(SLAPD_ROLE_ATTR)-1, SLAPD_ROLE_ATTR };
1638 AttributeDescription *desc,
1641 regmatch_t *matches,
1642 slap_access_t *grant,
1646 struct berval bv, perms, sdn;
1650 assert( desc->ad_cname.bv_val != NULL );
1652 /* parse an aci of the form:
1653 oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN
1655 See draft-ietf-ldapext-aci-model-04.txt section 9.1 for
1656 a full description of the format for this attribute.
1658 For now, this routine only supports scope=entry.
1661 /* check that the aci has all 5 components */
1662 if (aci_get_part(aci, 4, '#', NULL) < 0)
1665 /* check that the aci family is supported */
1666 if (aci_get_part(aci, 0, '#', &bv) < 0)
1669 /* check that the scope is "entry" */
1670 if (aci_get_part(aci, 1, '#', &bv) < 0
1671 || ber_bvstrcasecmp( &aci_bv_entry, &bv ) != 0)
1676 /* get the list of permissions clauses, bail if empty */
1677 if (aci_get_part(aci, 2, '#', &perms) <= 0)
1680 /* check if any permissions allow desired access */
1681 if (aci_list_get_rights(&perms, &desc->ad_cname, val, grant, deny) == 0)
1684 /* see if we have a DN match */
1685 if (aci_get_part(aci, 3, '#', &bv) < 0)
1688 if (aci_get_part(aci, 4, '#', &sdn) < 0)
1691 if (ber_bvstrcasecmp( &aci_bv_access_id, &bv ) == 0) {
1694 if ( dnNormalize2(NULL, &sdn, &ndn) == LDAP_SUCCESS ) {
1695 if (!dn_match( &op->o_ndn, &ndn))
1702 if (ber_bvstrcasecmp( &aci_bv_self, &bv ) == 0) {
1703 if (dn_match(&op->o_ndn, &e->e_nname))
1706 } else if (ber_bvstrcasecmp( &aci_bv_dnattr, &bv ) == 0) {
1708 AttributeDescription *ad = NULL;
1711 rc = slap_bv2ad( &sdn, &ad, &text );
1713 if( rc != LDAP_SUCCESS ) {
1721 for(at = attrs_find( e->e_attrs, ad );
1723 at = attrs_find( at->a_next, ad ) )
1725 if (value_find( ad, at->a_vals, &bv) == 0 ) {
1734 } else if (ber_bvstrcasecmp( &aci_bv_group, &bv ) == 0) {
1735 if (aci_group_member(&sdn, &GroupClass, &GroupAttr, be, e, conn, op, matches))
1738 } else if (ber_bvstrcasecmp( &aci_bv_role, &bv ) == 0) {
1739 if (aci_group_member(&sdn, &RoleClass, &RoleAttr, be, e, conn, op, matches))
1742 } else if (ber_bvstrcasecmp( &aci_bv_set, &bv ) == 0) {
1743 if (aci_match_set(&sdn, be, e, conn, op, 0))
1746 } else if (ber_bvstrcasecmp( &aci_bv_set_ref, &bv ) == 0) {
1747 if (aci_match_set(&sdn, be, e, conn, op, 1))
1755 #endif /* SLAPD_ACI_ENABLED */
1762 regmatch_t *matches)
1770 bv->bv_val[0] = '\0';
1771 bv->bv_len--; /* leave space for lone $ */
1774 for ( dp = bv->bv_val, sp = pat->bv_val; size < bv->bv_len &&
1775 sp < pat->bv_val + pat->bv_len ; sp++) {
1776 /* did we previously see a $ */
1781 } else if (*sp >= '0' && *sp <= '9' ) {
1788 i = matches[n].rm_so;
1789 l = matches[n].rm_eo;
1790 for ( ; size < bv->bv_len && i < l; size++, i++ ) {
1808 /* must have ended with a single $ */
1817 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
1818 "string_expand: pattern = %.*s\n", pat->bv_len, pat->bv_val ));
1819 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL1,
1820 "string_expand: expanded = %s\n", bv->bv_val ));
1822 Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern: %.*s\n", pat->bv_len, pat->bv_val, 0 );
1823 Debug( LDAP_DEBUG_TRACE, "=> string_expand: expanded: %s\n", bv->bv_val, 0, 0 );
1829 struct berval *pat, /* pattern to expand and match against */
1830 char *str, /* string to match against pattern */
1831 char *buf, /* buffer with $N expansion variables */
1832 regmatch_t *matches /* offsets in buffer for $N expansion variables */
1840 bv.bv_len = sizeof(newbuf);
1843 if(str == NULL) str = "";
1845 string_expand(&bv, pat, buf, matches);
1846 if (( rc = regcomp(&re, newbuf, REG_EXTENDED|REG_ICASE))) {
1848 regerror(rc, &re, error, sizeof(error));
1851 LDAP_LOG(( "aci", LDAP_LEVEL_ERR,
1852 "regex_matches: compile( \"%s\", \"%s\") failed %s\n",
1853 pat->bv_val, str, error ));
1855 Debug( LDAP_DEBUG_TRACE,
1856 "compile( \"%s\", \"%s\") failed %s\n",
1857 pat->bv_val, str, error );
1862 rc = regexec(&re, str, 0, NULL, 0);
1866 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL2,
1867 "regex_matches: string: %s\n", str ));
1868 LDAP_LOG(( "aci", LDAP_LEVEL_DETAIL2,
1869 "regex_matches: rc: %d %s\n",
1870 rc, rc ? "matches" : "no matches" ));
1872 Debug( LDAP_DEBUG_TRACE,
1873 "=> regex_matches: string: %s\n", str, 0, 0 );
1874 Debug( LDAP_DEBUG_TRACE,
1875 "=> regex_matches: rc: %d %s\n",
1876 rc, !rc ? "matches" : "no matches", 0 );