]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/filterentry.c
Per ITS#419, don't require SLAPD_RLOOKUPS when HAVE_TCPD
[openldap] / servers / slapd / filterentry.c
index 7d429f27c58cab6567651aca4c05fdaca8552cdb..c1abb4555d4b7a2b5d9be305671e0828fd9e664b 100644 (file)
@@ -1,4 +1,9 @@
 /* filterentry.c - apply a filter to an entry */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 
 #include "portable.h"
 
@@ -110,8 +115,9 @@ test_ava_filter(
        int             i, rc;
        Attribute       *a;
 
-       if ( be != NULL && ! access_allowed( be, conn, op, e, ava->ava_type,
-           &ava->ava_value, op->o_dn, ACL_SEARCH ) ) {
+       if ( be != NULL && ! access_allowed( be, conn, op, e,
+               ava->ava_type, &ava->ava_value, ACL_SEARCH ) )
+       {
                return( -2 );
        }
 
@@ -159,8 +165,9 @@ test_presence_filter(
     char       *type
 )
 {
-       if ( be != NULL && ! access_allowed( be, conn, op, e, type, NULL,
-           op->o_dn, ACL_SEARCH ) ) {
+       if ( be != NULL && ! access_allowed( be, conn, op, e,
+               type, NULL, ACL_SEARCH ) )
+       {
                return( -2 );
        }
 
@@ -177,11 +184,12 @@ test_approx_filter(
 )
 {
        char            *w1, *w2, *c1, *c2;
-       int             i, rc, match;
+       int             i;
        Attribute       *a;
 
-       if ( be != NULL && ! access_allowed( be, conn, op, e, ava->ava_type,
-           NULL, op->o_dn, ACL_SEARCH ) ) {
+       if ( be != NULL && ! access_allowed( be, conn, op, e,
+               ava->ava_type, NULL, ACL_SEARCH ) )
+       {
                return( -2 );
        }
 
@@ -253,7 +261,7 @@ test_filter_list(
     int                ftype
 )
 {
-       int     rc, nomatch;
+       int     nomatch;
        Filter  *f;
 
        Debug( LDAP_DEBUG_FILTER, "=> test_filter_list\n", 0, 0, 0 );
@@ -276,18 +284,24 @@ test_filter_list(
 }
 
 static void
-strcpy_special( char *d, char *s )
+strcpy_regex( char *d, char *s )
 {
        for ( ; *s; s++ ) {
                switch ( *s ) {
+               case '^':
                case '.':
-               case '\\':
                case '[':
-               case ']':
+               case ']': /* ? */
+               case '$':
+               case '(':
+               case ')': /* ? */
+               case '|':
                case '*':
                case '+':
-               case '^':
-               case '$':
+               case '?':
+               case '{':
+               case '}': /* ? */
+               case '\\':
                        *d++ = '\\';
                        /* FALL */
                default:
@@ -316,8 +330,9 @@ test_substring_filter(
 
        Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 );
 
-       if ( be != NULL && ! access_allowed( be, conn, op, e, f->f_sub_type,
-           NULL, op->o_dn, ACL_SEARCH ) ) {
+       if ( be != NULL && ! access_allowed( be, conn, op, e,
+               f->f_sub_type, NULL, ACL_SEARCH ) )
+       {
                return( -2 );
        }
 
@@ -348,7 +363,7 @@ test_substring_filter(
                            0, 0, 0 );
                        return( -1 );
                }
-               strcpy_special( p, f->f_sub_initial );
+               strcpy_regex( p, f->f_sub_initial );
                p = strchr( p, '\0' );
        }
        if ( f->f_sub_any != NULL ) {
@@ -361,7 +376,7 @@ test_substring_filter(
                        }
                        strcpy( p, ".*" );
                        p = strchr( p, '\0' );
-                       strcpy_special( p, f->f_sub_any[i] );
+                       strcpy_regex( p, f->f_sub_any[i] );
                        p = strchr( p, '\0' );
                }
        }
@@ -374,7 +389,7 @@ test_substring_filter(
                }
                strcpy( p, ".*" );
                p = strchr( p, '\0' );
-               strcpy_special( p, f->f_sub_final );
+               strcpy_regex( p, f->f_sub_final );
                p = strchr( p, '\0' );
                strcpy( p, "$" );
        }
@@ -382,7 +397,7 @@ test_substring_filter(
        /* compile the regex */
        Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n",
                pat, 0, 0 );
-       if ((rc = regcomp(&re, pat, 0))) {
+       if ((rc = regcomp(&re, pat, REG_EXTENDED|REG_NOSUB))) {
                char error[512];
 
                regerror(rc, &re, error, sizeof(error));