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 );
38 static int regex_matches(char *pat, char *str, char *buf, regmatch_t *matches);
39 static void string_expand(char *newbuf, int bufsiz, char *pattern,
40 char *match, regmatch_t *matches);
44 * access_allowed - check whether op->o_ndn is allowed the requested access
45 * to entry e, attribute attr, value val. if val is null, access to
46 * the whole attribute is assumed (all values).
48 * This routine loops through all access controls and calls
49 * acl_mask() on each applicable access control.
50 * The loop exits when a definitive answer is reached or
51 * or no more controls remain.
71 char accessmaskbuf[ACCESSMASK_MAXLEN];
72 slap_access_mask_t mask;
73 slap_control_t control;
75 regmatch_t matches[MAXREMATCHES];
77 Debug( LDAP_DEBUG_ACL,
78 "=> access_allowed: %s access to \"%s\" \"%s\" requested\n",
84 assert( attr != NULL );
85 assert( access > ACL_NONE );
87 /* grant database root access */
88 if ( be != NULL && be_isroot( be, op->o_ndn ) ) {
89 Debug( LDAP_DEBUG_ACL,
90 "<= root access granted\n",
95 /* no user modify operational attributes are ignored by ACL checking */
96 if ( oc_check_no_usermod_attr( attr ) ) {
97 Debug( LDAP_DEBUG_ACL, "NoUserMod Operational attribute:"
98 " %s access granted\n",
103 /* use backend default access if no backend acls */
104 if( be != NULL && be->be_acl == NULL ) {
105 Debug( LDAP_DEBUG_ACL,
106 "=> access_allowed: backend default %s access %s to \"%s\"\n",
107 access2str( access ),
108 be->be_dfltaccess >= access ? "granted" : "denied", op->o_dn );
110 return be->be_dfltaccess >= access;
113 /* be is always non-NULL */
114 /* use global default access if no global acls */
115 } else if ( be == NULL && global_acl == NULL ) {
116 Debug( LDAP_DEBUG_ACL,
117 "=> access_allowed: global default %s access %s to \"%s\"\n",
118 access2str( access ),
119 global_default_access >= access ? "granted" : "denied", op->o_dn );
121 return global_default_access >= access;
126 memset(matches, 0, sizeof(matches));
132 while( a = acl_get( a, &count, be, op, e, attr, MAXREMATCHES, matches ) )
136 for (i = 0; i < MAXREMATCHES && matches[i].rm_so > 0; i++) {
137 Debug( LDAP_DEBUG_ACL, "=> match[%d]: %d %d ", i,
138 (int)matches[i].rm_so, (int)matches[i].rm_eo );
140 if( matches[i].rm_so <= matches[0].rm_eo ) {
142 for ( n = matches[i].rm_so; n < matches[i].rm_eo; n++) {
143 Debug( LDAP_DEBUG_ACL, "%c", e->e_ndn[n], 0, 0 );
146 Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 );
149 control = acl_mask( a, &mask, be, conn, op,
150 e, attr, val, matches );
152 if ( control != ACL_BREAK ) {
156 memset(matches, 0, sizeof(matches));
159 if ( ACL_IS_INVALID( mask ) ) {
160 Debug( LDAP_DEBUG_ACL,
161 "=> access_allowed: \"%s\" (%s) invalid!\n",
165 } else if ( control == ACL_BREAK ) {
166 Debug( LDAP_DEBUG_ACL,
167 "=> access_allowed: no more rules\n", 0, 0, 0);
171 Debug( LDAP_DEBUG_ACL,
172 "=> access_allowed: %s access %s by %s\n",
173 access2str( access ),
174 ACL_GRANT(mask, access) ? "granted" : "denied",
175 accessmask2str( mask, accessmaskbuf ) );
177 return ACL_GRANT(mask, access);
181 * acl_get - return the acl applicable to entry e, attribute
182 * attr. the acl returned is suitable for use in subsequent calls to
183 * acl_access_allowed().
186 static AccessControl *
199 assert( count != NULL );
214 for ( ; a != NULL; a = a->acl_next ) {
217 if (a->acl_dn_pat != NULL) {
218 Debug( LDAP_DEBUG_ACL, "=> dnpat: [%d] %s nsub: %d\n",
219 *count, a->acl_dn_pat, (int) a->acl_dn_re.re_nsub );
221 if (regexec(&a->acl_dn_re, e->e_ndn, nmatch, matches, 0)) {
225 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] matched\n",
230 if ( a->acl_filter != NULL ) {
231 if ( test_filter( NULL, NULL, NULL, e, a->acl_filter ) != 0 ) {
236 Debug( LDAP_DEBUG_ACL, "=> acl_get: [%d] check attr %s\n",
239 if ( attr == NULL || a->acl_attrs == NULL ||
240 charray_inlist( a->acl_attrs, attr ) )
242 Debug( LDAP_DEBUG_ACL,
243 "<= acl_get: [%d] acl %s attr: %s\n",
244 *count, e->e_dn, attr );
247 matches[0].rm_so = matches[0].rm_eo = -1;
250 Debug( LDAP_DEBUG_ACL, "<= acl_get: done.\n", 0, 0, 0 );
256 * acl_mask - modifies mask based upon the given acl and the
257 * requested access to entry e, attribute attr, value val. if val
258 * is null, access to the whole attribute is assumed (all values).
260 * returns 0 access NOT allowed
264 static slap_control_t
267 slap_access_mask_t *mask,
279 char accessmaskbuf[ACCESSMASK_MAXLEN];
282 assert( mask != NULL );
284 Debug( LDAP_DEBUG_ACL,
285 "=> acl_mask: access to entry \"%s\", attr \"%s\" requested\n",
288 Debug( LDAP_DEBUG_ACL,
289 "=> acl_mask: to value \"%s\" by \"%s\", (%s) \n",
290 val ? val->bv_val : "*",
291 op->o_ndn ? op->o_ndn : "",
292 accessmask2str( *mask, accessmaskbuf ) );
294 for ( i = 1, b = a->acl_access; b != NULL; b = b->a_next, i++ ) {
295 slap_access_mask_t oldmask, modmask;
297 ACL_INVALIDATE( modmask );
299 /* AND <who> clauses */
300 if ( b->a_dn_pat != NULL ) {
301 Debug( LDAP_DEBUG_ACL, "<= check a_dn_pat: %s\n",
304 * if access applies to the entry itself, and the
305 * user is bound as somebody in the same namespace as
306 * the entry, OR the given dn matches the dn pattern
308 if ( strcmp( b->a_dn_pat, "anonymous" ) == 0 ) {
309 if (op->o_ndn != NULL && op->o_ndn[0] != '\0' ) {
313 } else if ( strcmp( b->a_dn_pat, "users" ) == 0 ) {
314 if (op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
318 } else if ( strcmp( b->a_dn_pat, "self" ) == 0 ) {
319 if( op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
323 if ( e->e_dn == NULL || strcmp( e->e_ndn, op->o_ndn ) != 0 ) {
327 } else if ( strcmp( b->a_dn_pat, "*" ) != 0 ) {
328 int ret = regex_matches( b->a_dn_pat,
329 op->o_ndn, e->e_ndn, matches );
337 if ( b->a_sockurl_pat != NULL ) {
338 Debug( LDAP_DEBUG_ACL, "<= check a_sockurl_pat: %s\n",
339 b->a_sockurl_pat, 0, 0 );
341 if ( strcmp( b->a_sockurl_pat, "*" ) != 0 &&
342 !regex_matches( b->a_sockurl_pat, conn->c_listener_url,
343 e->e_ndn, matches ) )
349 if ( b->a_domain_pat != NULL ) {
350 Debug( LDAP_DEBUG_ACL, "<= check a_domain_pat: %s\n",
351 b->a_domain_pat, 0, 0 );
353 if ( strcmp( b->a_domain_pat, "*" ) != 0 &&
354 !regex_matches( b->a_domain_pat, conn->c_peer_domain,
355 e->e_ndn, matches ) )
361 if ( b->a_peername_pat != NULL ) {
362 Debug( LDAP_DEBUG_ACL, "<= check a_peername_path: %s\n",
363 b->a_peername_pat, 0, 0 );
365 if ( strcmp( b->a_peername_pat, "*" ) != 0 &&
366 !regex_matches( b->a_peername_pat, conn->c_peer_name,
367 e->e_ndn, matches ) )
373 if ( b->a_sockname_pat != NULL ) {
374 Debug( LDAP_DEBUG_ACL, "<= check a_sockname_path: %s\n",
375 b->a_sockname_pat, 0, 0 );
377 if ( strcmp( b->a_sockname_pat, "*" ) != 0 &&
378 !regex_matches( b->a_sockname_pat, conn->c_sock_name,
379 e->e_ndn, matches ) )
385 if ( b->a_dn_at != NULL && op->o_ndn != NULL ) {
389 Debug( LDAP_DEBUG_ACL, "<= check a_dn_at: %s\n",
392 bv.bv_val = op->o_ndn;
393 bv.bv_len = strlen( bv.bv_val );
395 /* see if asker is listed in dnattr */
396 if ( (at = attr_find( e->e_attrs, b->a_dn_at )) != NULL &&
397 value_find( at->a_vals, &bv, at->a_syntax, 3 ) == 0 )
400 (val == NULL || value_cmp( &bv, val, at->a_syntax, 2 )) )
405 /* asker not listed in dnattr - check for self access */
406 } else if ( ! b->a_dn_self || val == NULL ||
407 value_cmp( &bv, val, at->a_syntax, 2 ) != 0 )
413 if ( b->a_group_pat != NULL && op->o_ndn != NULL ) {
416 /* b->a_group is an unexpanded entry name, expanded it should be an
417 * entry with objectclass group* and we test to see if odn is one of
418 * the values in the attribute group
420 /* see if asker is listed in dnattr */
421 string_expand(buf, sizeof(buf), b->a_group_pat, e->e_ndn, matches);
422 if ( dn_normalize(buf) == NULL ) {
423 /* did not expand to a valid dn */
427 if (backend_group(be, e, buf, op->o_ndn,
428 b->a_group_oc, b->a_group_at) != 0)
434 #ifdef SLAPD_ACI_ENABLED
435 if ( b->a_aci_at != NULL ) {
437 slap_access_t grant, deny, tgrant, tdeny;
439 /* this case works different from the others above.
440 * since aci's themselves give permissions, we need
441 * to first check b->a_mask, the ACL's access level.
444 if( op->o_ndn == NULL || op->o_ndn[0] == '\0' ) {
448 if ( e->e_dn == NULL ) {
452 /* first check if the right being requested
453 * is allowed by the ACL clause.
455 if ( ! ACL_GRANT( b->a_mask, *mask ) ) {
459 /* get the aci attribute */
460 at = attr_find( e->e_attrs, b->a_aci_at );
465 /* start out with nothing granted, nothing denied */
469 /* the aci is an multi-valued attribute. The
470 * rights are determined by OR'ing the individual
471 * rights given by the acis.
473 for ( i = 0; at->a_vals[i] != NULL; i++ ) {
474 if (aci_mask( be, op,
475 e, attr, val, at->a_vals[i],
476 matches, &grant, &deny ) != 0)
483 /* remove anything that the ACL clause does not allow */
484 tgrant &= b->a_mask & ACL_PRIV_MASK;
485 tdeny &= ACL_PRIV_MASK;
487 /* see if we have anything to contribute */
488 if( ACL_IS_INVALID(tgrant) && ACL_IS_INVALID(tdeny) ) {
492 /* this could be improved by changing acl_mask so that it can deal with
493 * by clauses that return grant/deny pairs. Right now, it does either
494 * additive or subtractive rights, but not both at the same time. So,
495 * we need to combine the grant/deny pair into a single rights mask in
496 * a smart way: if either grant or deny is "empty", then we use the
497 * opposite as is, otherwise we remove any denied rights from the grant
498 * rights mask and construct an additive mask.
500 if (ACL_IS_INVALID(tdeny)) {
501 modmask = tgrant | ACL_PRIV_ADDITIVE;
503 } else if (ACL_IS_INVALID(tgrant)) {
504 modmask = tdeny | ACL_PRIV_SUBSTRACTIVE;
507 modmask = (tgrant & ~tdeny) | ACL_PRIV_ADDITIVE;
517 Debug( LDAP_DEBUG_ACL,
518 "<= acl_mask: [%d] applying %s (%s)\n",
519 i, accessmask2str( modmask, accessmaskbuf ),
520 b->a_type == ACL_CONTINUE
522 : b->a_type == ACL_BREAK
529 if( ACL_IS_ADDITIVE(modmask) ) {
531 ACL_PRIV_SET( *mask, modmask );
534 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
536 } else if( ACL_IS_SUBTRACTIVE(modmask) ) {
537 /* substract privs */
538 ACL_PRIV_CLR( *mask, modmask );
541 ACL_PRIV_CLR( *mask, ~ACL_PRIV_MASK );
548 Debug( LDAP_DEBUG_ACL,
549 "<= acl_mask: [%d] mask: %s\n",
550 i, accessmask2str(*mask, accessmaskbuf), 0 );
552 if( b->a_type == ACL_CONTINUE ) {
555 } else if ( b->a_type == ACL_BREAK ) {
563 Debug( LDAP_DEBUG_ACL,
564 "<= acl_mask: no more <who> clauses, returning %s (stop)\n",
565 accessmask2str(*mask, accessmaskbuf), 0, 0 );
570 * acl_check_modlist - check access control on the given entry to see if
571 * it allows the given modifications by the user associated with op.
572 * returns 1 if mods allowed ok
587 assert( be != NULL );
589 /* short circuit root database access */
590 if ( be_isroot( be, op->o_ndn ) ) {
591 Debug( LDAP_DEBUG_ACL,
592 "<= acl_access_allowed: granted to database root\n",
597 /* use backend default access if no backend acls */
598 if( be != NULL && be->be_acl == NULL ) {
599 Debug( LDAP_DEBUG_ACL,
600 "=> access_allowed: backend default %s access %s to \"%s\"\n",
601 access2str( ACL_WRITE ),
602 be->be_dfltaccess >= ACL_WRITE ? "granted" : "denied", op->o_dn );
604 return be->be_dfltaccess >= ACL_WRITE;
607 /* be is always non-NULL */
608 /* use global default access if no global acls */
609 } else if ( be == NULL && global_acl == NULL ) {
610 Debug( LDAP_DEBUG_ACL,
611 "=> access_allowed: global default %s access %s to \"%s\"\n",
612 access2str( ACL_WRITE ),
613 global_default_access >= ACL_WRITE ? "granted" : "denied", op->o_dn );
615 return global_default_access >= ACL_WRITE;
619 for ( ; mlist != NULL; mlist = mlist->ml_next ) {
620 /* the lastmod attributes are ignored by ACL checking */
621 if ( oc_check_no_usermod_attr( mlist->ml_type ) ) {
622 Debug( LDAP_DEBUG_ACL, "Operational attribute: %s access allowed\n",
623 mlist->ml_type, 0, 0 );
627 switch ( mlist->ml_op & ~LDAP_MOD_BVALUES ) {
628 case LDAP_MOD_REPLACE:
630 if ( mlist->ml_bvalues == NULL ) {
633 for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) {
634 if ( ! access_allowed( be, conn, op, e,
635 mlist->ml_type, mlist->ml_bvalues[i],
643 case LDAP_MOD_DELETE:
644 if ( mlist->ml_bvalues == NULL ) {
645 if ( ! access_allowed( be, conn, op, e,
646 mlist->ml_type, NULL,
653 for ( i = 0; mlist->ml_bvalues[i] != NULL; i++ ) {
654 if ( ! access_allowed( be, conn, op, e,
655 mlist->ml_type, mlist->ml_bvalues[i],
668 #ifdef SLAPD_ACI_ENABLED
670 aci_bvstrdup (struct berval *bv)
674 s = (char *)ch_malloc(bv->bv_len + 1);
676 memcpy(s, bv->bv_val, bv->bv_len);
683 aci_strbvcmp (char *s, struct berval *bv)
687 res = strncasecmp( s, bv->bv_val, bv->bv_len );
691 if (len > (int)bv->bv_len)
693 if (len < (int)bv->bv_len)
699 aci_get_part (struct berval *list, int ix, char sep, struct berval *bv)
710 while (len >= 0 && --ix >= 0) {
711 while (--len >= 0 && *p++ != sep) ;
713 while (len >= 0 && *p == ' ') {
724 while (--len >= 0 && *p != sep) {
728 while (bv->bv_len > 0 && *--p == ' ')
734 aci_list_map_rights (
742 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
745 switch (*bv.bv_val) {
747 ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
750 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt defines
751 * the right 's' to mean "set", but in the examples states
752 * that the right 's' means "search". The latter definition
755 ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
758 ACL_PRIV_SET(mask, ACL_PRIV_READ);
761 ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
764 /* **** NOTE: draft-ietf-ldapext-aci-model-0.3.txt does not
765 * define any equivalent to the AUTH right, so I've just used
768 ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
779 aci_list_has_attr (struct berval *list, char *attr, struct berval *val)
781 struct berval bv, left, right;
784 for (i = 0; aci_get_part(list, i, ',', &bv) >= 0; i++) {
785 if (aci_get_part(&bv, 0, '=', &left) < 0
786 || aci_get_part(&bv, 1, '=', &right) < 0)
788 if (aci_strbvcmp(attr, &bv) == 0)
790 } else if (val == NULL) {
791 if (aci_strbvcmp(attr, &left) == 0)
794 if (aci_strbvcmp(attr, &left) == 0) {
795 /* this is experimental code that implements a
796 * simple (prefix) match of the attribute value.
797 * the ACI draft does not provide for aci's that
798 * apply to specific values, but it would be
799 * nice to have. If the <attr> part of an aci's
800 * rights list is of the form <attr>=<value>,
801 * that means the aci applies only to attrs with
802 * the given value. Furthermore, if the attr is
803 * of the form <attr>=<value>*, then <value> is
804 * treated as a prefix, and the aci applies to
805 * any value with that prefix.
807 * Ideally, this would allow r.e. matches.
809 if (aci_get_part(&right, 0, '*', &left) < 0
810 || right.bv_len <= left.bv_len)
812 if (aci_strbvcmp(val->bv_val, &right) == 0)
814 } else if (val->bv_len >= left.bv_len) {
815 if (strncasecmp( val->bv_val, left.bv_val, left.bv_len ) == 0)
825 aci_list_get_attr_rights (struct berval *list, char *attr, struct berval *val)
831 /* loop through each rights/attr pair, skip first part (action) */
833 for (i = 1; aci_get_part(list, i + 1, ';', &bv) >= 0; i += 2) {
834 if (aci_list_has_attr(&bv, attr, val) == 0)
836 if (aci_get_part(list, i, ';', &bv) < 0)
838 mask |= aci_list_map_rights(&bv);
844 aci_list_get_rights (
848 slap_access_t *grant,
851 struct berval perm, actn;
855 if (attr == NULL || *attr == 0 || strcasecmp(attr, "entry") == 0) {
862 /* loop through each permissions clause */
863 for (i = 0; aci_get_part(list, i, '$', &perm) >= 0; i++) {
864 if (aci_get_part(&perm, 0, ';', &actn) < 0)
866 if (aci_strbvcmp( "grant", &actn ) == 0) {
868 } else if (aci_strbvcmp( "deny", &actn ) == 0) {
875 *mask |= aci_list_get_attr_rights(&perm, attr, val);
876 *mask |= aci_list_get_attr_rights(&perm, "[all]", NULL);
893 char *subjdn, *grpdn;
896 /* format of string is "group/objectClassValue/groupAttrName" */
897 if (aci_get_part(subj, 0, '/', &bv) < 0)
899 subjdn = aci_bvstrdup(&bv);
903 if (aci_get_part(subj, 1, '/', &bv) < 0)
904 grpoc = ch_strdup(grpoc);
906 grpoc = aci_bvstrdup(&bv);
908 if (aci_get_part(subj, 2, '/', &bv) < 0)
909 grpat = ch_strdup(grpat);
911 grpat = aci_bvstrdup(&bv);
913 grpdn = (char *)ch_malloc(1024);
914 if (grpoc != NULL && grpat != NULL && grpdn != NULL) {
915 string_expand(grpdn, 1024, subjdn, e->e_ndn, matches);
916 if ( dn_normalize(grpdn) != NULL ) {
917 rc = (backend_group(be, e, grpdn, op->o_ndn, grpoc, grpat) == 0);
938 slap_access_t *grant,
942 struct berval bv, perms, sdn;
946 /* parse an aci of the form:
947 oid#scope#action;rights;attr;rights;attr$action;rights;attr;rights;attr#dnType#subjectDN
949 See draft-ietf-ldapext-aci-model-0.3.txt section 9.1 for
950 a full description of the format for this attribute.
952 For now, this routine only supports scope=entry.
955 /* check that the aci has all 5 components */
956 if (aci_get_part(aci, 4, '#', NULL) < 0)
959 /* check that the scope is "entry" */
960 if (aci_get_part(aci, 1, '#', &bv) < 0
961 || aci_strbvcmp( "entry", &bv ) != 0)
966 /* get the list of permissions clauses, bail if empty */
967 if (aci_get_part(aci, 2, '#', &perms) <= 0)
970 /* check if any permissions allow desired access */
971 if (aci_list_get_rights(&perms, attr, val, grant, deny) == 0)
974 /* see if we have a DN match */
975 if (aci_get_part(aci, 3, '#', &bv) < 0)
978 if (aci_get_part(aci, 4, '#', &sdn) < 0)
981 if (aci_strbvcmp( "access-id", &bv ) == 0) {
982 subjdn = aci_bvstrdup(&sdn);
986 if ( dn_normalize(subjdn) != NULL )
987 if (strcasecmp(op->o_ndn, subjdn) != 0)
993 if (aci_strbvcmp( "self", &bv ) == 0) {
994 if (strcasecmp(op->o_ndn, e->e_ndn) == 0)
997 } else if (aci_strbvcmp( "group", &bv ) == 0) {
998 if (aci_group_member(&sdn, "groupOfNames", "member", be, e, op, matches))
1001 } else if (aci_strbvcmp( "role", &bv ) == 0) {
1002 if (aci_group_member(&sdn, "organizationalRole", "roleOccupant", be, e, op, matches))
1008 #endif /* SLAPD_ACI_ENABLED */
1016 regmatch_t *matches)
1025 bufsiz--; /* leave space for lone $ */
1028 for ( dp = newbuf, sp = pat; size < bufsiz && *sp ; sp++) {
1029 /* did we previously see a $ */
1034 } else if (*sp >= '0' && *sp <= '9' ) {
1041 i = matches[n].rm_so;
1042 l = matches[n].rm_eo;
1043 for ( ; size < 512 && i < l; size++, i++ ) {
1061 /* must have ended with a single $ */
1068 Debug( LDAP_DEBUG_TRACE, "=> string_expand: pattern: %s\n", pat, 0, 0 );
1069 Debug( LDAP_DEBUG_TRACE, "=> string_expand: expanded: %s\n", newbuf, 0, 0 );
1074 char *pat, /* pattern to expand and match against */
1075 char *str, /* string to match against pattern */
1076 char *buf, /* buffer with $N expansion variables */
1077 regmatch_t *matches /* offsets in buffer for $N expansion variables */
1084 if(str == NULL) str = "";
1086 string_expand(newbuf, sizeof(newbuf), pat, buf, matches);
1087 if (( rc = regcomp(&re, newbuf, REG_EXTENDED|REG_ICASE))) {
1089 regerror(rc, &re, error, sizeof(error));
1091 Debug( LDAP_DEBUG_TRACE,
1092 "compile( \"%s\", \"%s\") failed %s\n",
1097 rc = regexec(&re, str, 0, NULL, 0);
1100 Debug( LDAP_DEBUG_TRACE,
1101 "=> regex_matches: string: %s\n", str, 0, 0 );
1102 Debug( LDAP_DEBUG_TRACE,
1103 "=> regex_matches: rc: %d %s\n",
1104 rc, !rc ? "matches" : "no matches", 0 );