/* 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"
#include "slap.h"
-extern Attribute *attr_find();
-extern char *first_word();
-extern char *next_word();
-extern char *phonetic();
-
-static int test_filter_list();
-static int test_substring_filter();
-static int test_ava_filter();
-static int test_approx_filter();
-static int test_presence_filter();
+static int test_filter_list(Backend *be, Connection *conn, Operation *op, Entry *e, Filter *flist, int ftype);
+static int test_substring_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Filter *f);
+static int test_ava_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Ava *ava, int type);
+static int test_approx_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Ava *ava);
+static int test_presence_filter(Backend *be, Connection *conn, Operation *op, Entry *e, char *type);
/*
* test_filter - test a filter against a single entry.
break;
default:
- Debug( LDAP_DEBUG_ANY, " unknown filter type %d\n",
+ Debug( LDAP_DEBUG_ANY, " unknown filter type %lu\n",
f->f_choice, 0, 0 );
rc = -1;
}
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 );
}
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 );
}
)
{
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 );
}
int ftype
)
{
- int rc, nomatch;
+ int nomatch;
Filter *f;
Debug( LDAP_DEBUG_FILTER, "=> test_filter_list\n", 0, 0, 0 );
}
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:
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 );
}
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 ) {
}
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' );
}
}
}
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, "$" );
}
/* 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));