version 1.105, 2003/04/07 02:03:55
|
version 1.106, 2003/04/09 14:52:03
|
Line 1
|
Line 1
|
/* filter.c - routines for parsing and dealing with filters */ |
/* filter.c - routines for parsing and dealing with filters */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.104 2003/04/05 01:35:17 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.105 2003/04/07 02:03:55 kurt Exp $ */ |
/* |
/* |
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. |
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
Line 15
|
Line 15
|
#include "slap.h" |
#include "slap.h" |
|
|
static int get_filter_list( |
static int get_filter_list( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
Filter **f, |
Filter **f, |
const char **text ); |
const char **text ); |
|
|
static int get_ssa( |
static int get_ssa( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
SubstringsAssertion **s, |
SubstringsAssertion **s, |
const char **text ); |
const char **text ); |
|
|
static void simple_vrFilter2bv( |
static void simple_vrFilter2bv( |
|
Operation *op, |
ValuesReturnFilter *f, |
ValuesReturnFilter *f, |
struct berval *fstr ); |
struct berval *fstr ); |
|
|
static int get_simple_vrFilter( |
static int get_simple_vrFilter( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
ValuesReturnFilter **f, |
ValuesReturnFilter **f, |
const char **text ); |
const char **text ); |
|
|
int |
int |
get_filter( |
get_filter( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
Filter **filt, |
Filter **filt, |
const char **text ) |
const char **text ) |
Line 49 get_filter(
|
Line 50 get_filter(
|
Filter f; |
Filter f; |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, "get_filter: conn %d\n", conn->c_connid, 0, 0 ); |
LDAP_LOG( FILTER, ENTRY, "get_filter: conn %d\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "begin get_filter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_filter\n", 0, 0, 0 ); |
#endif |
#endif |
Line 102 get_filter(
|
Line 103 get_filter(
|
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL2, |
LDAP_LOG( FILTER, DETAIL2, |
"get_filter: conn %d EQUALITY\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d EQUALITY\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &f.f_ava, SLAP_MR_EQUALITY, text ); |
err = get_ava( op, ber, &f.f_ava, SLAP_MR_EQUALITY, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 117 get_filter(
|
Line 118 get_filter(
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d SUBSTRINGS\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d SUBSTRINGS\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ssa( conn, ber, &f.f_sub, text ); |
err = get_ssa( op, ber, &f.f_sub, text ); |
if( err != LDAP_SUCCESS ) { |
if( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 131 get_filter(
|
Line 132 get_filter(
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d GE\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d GE\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &f.f_ava, SLAP_MR_ORDERING, text ); |
err = get_ava( op, ber, &f.f_ava, SLAP_MR_ORDERING, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 145 get_filter(
|
Line 146 get_filter(
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d LE\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d LE\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &f.f_ava, SLAP_MR_ORDERING, text ); |
err = get_ava( op, ber, &f.f_ava, SLAP_MR_ORDERING, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 161 get_filter(
|
Line 162 get_filter(
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d PRESENT\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d PRESENT\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); |
#endif |
#endif |
Line 189 get_filter(
|
Line 190 get_filter(
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d APPROX\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d APPROX\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &f.f_ava, SLAP_MR_EQUALITY_APPROX, text ); |
err = get_ava( op, ber, &f.f_ava, SLAP_MR_EQUALITY_APPROX, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 203 get_filter(
|
Line 204 get_filter(
|
case LDAP_FILTER_AND: |
case LDAP_FILTER_AND: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d AND\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d AND\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_filter_list( conn, ber, &f.f_and, text ); |
err = get_filter_list( op, ber, &f.f_and, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 217 get_filter(
|
Line 218 get_filter(
|
case LDAP_FILTER_OR: |
case LDAP_FILTER_OR: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d OR\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d OR\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_filter_list( conn, ber, &f.f_or, text ); |
err = get_filter_list( op, ber, &f.f_or, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 231 get_filter(
|
Line 232 get_filter(
|
case LDAP_FILTER_NOT: |
case LDAP_FILTER_NOT: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d NOT\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d NOT\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); |
#endif |
#endif |
(void) ber_skip_tag( ber, &len ); |
(void) ber_skip_tag( ber, &len ); |
err = get_filter( conn, ber, &f.f_not, text ); |
err = get_filter( op, ber, &f.f_not, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 247 get_filter(
|
Line 248 get_filter(
|
case LDAP_FILTER_EXT: |
case LDAP_FILTER_EXT: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_filter: conn %d EXTENSIBLE\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d EXTENSIBLE\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); |
#endif |
#endif |
|
|
err = get_mra( ber, &f.f_mra, text ); |
err = get_mra( op, ber, &f.f_mra, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 265 get_filter(
|
Line 266 get_filter(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ERR, |
LDAP_LOG( FILTER, ERR, |
"get_filter: conn %d unknown filter type=%lu\n", |
"get_filter: conn %d unknown filter type=%lu\n", |
conn->c_connid, f.f_choice, 0 ); |
op->o_connid, f.f_choice, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", |
Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", |
f.f_choice, 0, 0 ); |
f.f_choice, 0, 0 ); |
Line 283 get_filter(
|
Line 284 get_filter(
|
} |
} |
|
|
if ( err == LDAP_SUCCESS ) { |
if ( err == LDAP_SUCCESS ) { |
*filt = ch_malloc( sizeof(f) ); |
*filt = op->o_tmpalloc( sizeof(f), op->o_tmpmemctx ); |
**filt = f; |
**filt = f; |
} |
} |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL2, |
LDAP_LOG( FILTER, DETAIL2, |
"get_filter: conn %d exit\n", conn->c_connid, 0, 0 ); |
"get_filter: conn %d exit\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "end get_filter %d\n", err, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_filter %d\n", err, 0, 0 ); |
#endif |
#endif |
Line 298 get_filter(
|
Line 299 get_filter(
|
} |
} |
|
|
static int |
static int |
get_filter_list( Connection *conn, BerElement *ber, |
get_filter_list( Operation *op, BerElement *ber, |
Filter **f, |
Filter **f, |
const char **text ) |
const char **text ) |
{ |
{ |
Line 310 get_filter_list( Connection *conn, BerEl
|
Line 311 get_filter_list( Connection *conn, BerEl
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_filter_list: conn %d start\n", conn->c_connid, 0, 0 ); |
"get_filter_list: conn %d start\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); |
#endif |
#endif |
Line 319 get_filter_list( Connection *conn, BerEl
|
Line 320 get_filter_list( Connection *conn, BerEl
|
tag != LBER_DEFAULT; |
tag != LBER_DEFAULT; |
tag = ber_next_element( ber, &len, last ) ) |
tag = ber_next_element( ber, &len, last ) ) |
{ |
{ |
err = get_filter( conn, ber, new, text ); |
err = get_filter( op, ber, new, text ); |
if ( err != LDAP_SUCCESS ) |
if ( err != LDAP_SUCCESS ) |
return( err ); |
return( err ); |
new = &(*new)->f_next; |
new = &(*new)->f_next; |
Line 328 get_filter_list( Connection *conn, BerEl
|
Line 329 get_filter_list( Connection *conn, BerEl
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_filter_list: conn %d exit\n", conn->c_connid, 0, 0 ); |
"get_filter_list: conn %d exit\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "end get_filter_list\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_filter_list\n", 0, 0, 0 ); |
#endif |
#endif |
Line 337 get_filter_list( Connection *conn, BerEl
|
Line 338 get_filter_list( Connection *conn, BerEl
|
|
|
static int |
static int |
get_ssa( |
get_ssa( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
SubstringsAssertion **out, |
SubstringsAssertion **out, |
const char **text ) |
const char **text ) |
Line 353 get_ssa(
|
Line 354 get_ssa(
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_ssa: conn %d begin\n", conn->c_connid, 0, 0 ); |
"get_ssa: conn %d begin\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "begin get_ssa\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_ssa\n", 0, 0, 0 ); |
#endif |
#endif |
Line 412 get_ssa(
|
Line 413 get_ssa(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ERR, |
LDAP_LOG( FILTER, ERR, |
"get_filter_substring: conn %d unknown substring choice=%ld\n", |
"get_filter_substring: conn %d unknown substring choice=%ld\n", |
conn->c_connid, (long)tag, 0 ); |
op->o_connid, (long)tag, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, |
Debug( LDAP_DEBUG_FILTER, |
" unknown substring choice=%ld\n", |
" unknown substring choice=%ld\n", |
Line 438 get_ssa(
|
Line 439 get_ssa(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_ssa: conn %d INITIAL\n", |
"get_ssa: conn %d INITIAL\n", |
conn->c_connid, 0, 0 ); |
op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); |
#endif |
#endif |
Line 458 get_ssa(
|
Line 459 get_ssa(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_ssa: conn %d ANY\n", |
"get_ssa: conn %d ANY\n", |
conn->c_connid, 0, 0 ); |
op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); |
#endif |
#endif |
Line 468 get_ssa(
|
Line 469 get_ssa(
|
goto return_error; |
goto return_error; |
} |
} |
|
|
|
#ifdef notyet |
|
ber_bvarray_add_x( &ssa.sa_any, &nvalue, op->o_tmpmemctx ); |
|
#else |
ber_bvarray_add( &ssa.sa_any, &nvalue ); |
ber_bvarray_add( &ssa.sa_any, &nvalue ); |
|
#endif |
break; |
break; |
|
|
case LDAP_SUBSTRING_FINAL: |
case LDAP_SUBSTRING_FINAL: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_ssa: conn %d FINAL\n", |
"get_ssa: conn %d FINAL\n", |
conn->c_connid, 0, 0 ); |
op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); |
#endif |
#endif |
Line 492 get_ssa(
|
Line 497 get_ssa(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, INFO, |
LDAP_LOG( FILTER, INFO, |
"get_ssa: conn %d unknown substring type %ld\n", |
"get_ssa: conn %d unknown substring type %ld\n", |
conn->c_connid, (long)tag, 0 ); |
op->o_connid, (long)tag, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, |
Debug( LDAP_DEBUG_FILTER, |
" unknown substring type=%ld\n", |
" unknown substring type=%ld\n", |
Line 506 return_error:
|
Line 511 return_error:
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, INFO, |
LDAP_LOG( FILTER, INFO, |
"get_ssa: conn %d error %ld\n", |
"get_ssa: conn %d error %ld\n", |
conn->c_connid, (long)rc, 0 ); |
op->o_connid, (long)rc, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " error=%ld\n", |
Debug( LDAP_DEBUG_FILTER, " error=%ld\n", |
(long) rc, 0, 0 ); |
(long) rc, 0, 0 ); |
Line 521 return_error:
|
Line 526 return_error:
|
} |
} |
|
|
if( rc == LDAP_SUCCESS ) { |
if( rc == LDAP_SUCCESS ) { |
*out = ch_malloc( sizeof( ssa ) ); |
*out = op->o_tmpalloc( sizeof( ssa ), op->o_tmpmemctx ); |
**out = ssa; |
**out = ssa; |
} |
} |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_ssa: conn %d exit\n", conn->c_connid, 0, 0 ); |
"get_ssa: conn %d exit\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "end get_ssa\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_ssa\n", 0, 0, 0 ); |
#endif |
#endif |
Line 536 return_error:
|
Line 541 return_error:
|
} |
} |
|
|
void |
void |
filter_free( Filter *f ) |
filter_free_x( Operation *op, Filter *f ) |
{ |
{ |
Filter *p, *next; |
Filter *p, *next; |
|
|
Line 552 filter_free( Filter *f )
|
Line 557 filter_free( Filter *f )
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
ava_free( f->f_ava, 1 ); |
ava_free( op, f->f_ava, 1 ); |
break; |
break; |
|
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
if ( f->f_sub_initial.bv_val != NULL ) { |
if ( f->f_sub_initial.bv_val != NULL ) { |
free( f->f_sub_initial.bv_val ); |
#ifdef notyet |
|
op->o_tmpfree( f->f_sub_initial.bv_val, op->o_tmpmemctx ); |
|
#else |
|
ch_free( f->f_sub_initial.bv_val ); |
|
#endif |
} |
} |
ber_bvarray_free( f->f_sub_any ); |
ber_bvarray_free( f->f_sub_any ); |
if ( f->f_sub_final.bv_val != NULL ) { |
if ( f->f_sub_final.bv_val != NULL ) { |
free( f->f_sub_final.bv_val ); |
#ifdef notyet |
|
op->o_tmpfree( f->f_sub_final.bv_val, op->o_tmpmemctx ); |
|
#else |
|
ch_free( f->f_sub_final.bv_val ); |
|
#endif |
} |
} |
ch_free( f->f_sub ); |
op->o_tmpfree( f->f_sub, op->o_tmpmemctx ); |
break; |
break; |
|
|
case LDAP_FILTER_AND: |
case LDAP_FILTER_AND: |
Line 571 filter_free( Filter *f )
|
Line 584 filter_free( Filter *f )
|
case LDAP_FILTER_NOT: |
case LDAP_FILTER_NOT: |
for ( p = f->f_list; p != NULL; p = next ) { |
for ( p = f->f_list; p != NULL; p = next ) { |
next = p->f_next; |
next = p->f_next; |
filter_free( p ); |
filter_free_x( op, p ); |
} |
} |
break; |
break; |
|
|
case LDAP_FILTER_EXT: |
case LDAP_FILTER_EXT: |
mra_free( f->f_mra, 1 ); |
mra_free( op, f->f_mra, 1 ); |
break; |
break; |
|
|
case SLAPD_FILTER_COMPUTED: |
case SLAPD_FILTER_COMPUTED: |
Line 593 filter_free( Filter *f )
|
Line 606 filter_free( Filter *f )
|
break; |
break; |
} |
} |
|
|
free( f ); |
op->o_tmpfree( f, op->o_tmpmemctx ); |
} |
} |
|
|
void |
void |
filter2bv( Filter *f, struct berval *fstr ) |
filter_free( Filter *f ) |
|
{ |
|
Operation op; |
|
|
|
op.o_tmpmemctx = NULL; |
|
op.o_tmpfree = (BER_MEMFREE_FN *)ch_free; |
|
filter_free_x( &op, f ); |
|
} |
|
|
|
void |
|
filter2bv_x( Filter *f, struct berval *fstr, void *ctx ) |
{ |
{ |
int i; |
int i; |
Filter *p; |
Filter *p; |
struct berval tmp; |
struct berval tmp; |
ber_len_t len; |
ber_len_t len; |
|
BER_MEMALLOC_FN *alloc = ctx ? sl_malloc : (BER_MEMALLOC_FN *)ch_malloc; |
|
BER_MEMREALLOC_FN *reallo = ctx ? sl_realloc : (BER_MEMREALLOC_FN *)ch_realloc; |
|
|
if ( f == NULL ) { |
if ( f == NULL ) { |
ber_str2bv( "No filter!", sizeof("No filter!")-1, 1, fstr ); |
ber_str2bv_x( "No filter!", sizeof("No filter!")-1, 1, fstr, ctx ); |
return; |
return; |
} |
} |
|
|
switch ( f->f_choice ) { |
switch ( f->f_choice ) { |
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
filter_escape_value( &f->f_av_value, &tmp ); |
filter_escape_value_x( &f->f_av_value, &tmp, ctx ); |
|
|
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(=)") - 1 ); |
tmp.bv_len + ( sizeof("(=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = alloc( fstr->bv_len + 1, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)", |
f->f_av_desc->ad_cname.bv_val, |
f->f_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
break; |
break; |
|
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
filter_escape_value( &f->f_av_value, &tmp ); |
filter_escape_value_x( &f->f_av_value, &tmp, ctx ); |
|
|
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(>=)") - 1 ); |
tmp.bv_len + ( sizeof("(>=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = alloc( fstr->bv_len + 1, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)", |
f->f_av_desc->ad_cname.bv_val, |
f->f_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
break; |
break; |
|
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
filter_escape_value( &f->f_av_value, &tmp ); |
filter_escape_value_x( &f->f_av_value, &tmp, ctx ); |
|
|
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(<=)") - 1 ); |
tmp.bv_len + ( sizeof("(<=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = alloc( fstr->bv_len + 1, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)", |
f->f_av_desc->ad_cname.bv_val, |
f->f_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
break; |
break; |
|
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
filter_escape_value( &f->f_av_value, &tmp ); |
filter_escape_value_x( &f->f_av_value, &tmp, ctx ); |
|
|
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(~=)") - 1 ); |
tmp.bv_len + ( sizeof("(~=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = alloc( fstr->bv_len + 1, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)", |
f->f_av_desc->ad_cname.bv_val, |
f->f_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
break; |
break; |
|
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
fstr->bv_len = f->f_sub_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_sub_desc->ad_cname.bv_len + |
( sizeof("(=*)") - 1 ); |
( sizeof("(=*)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 128 ); |
fstr->bv_val = alloc( fstr->bv_len + 128, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
f->f_sub_desc->ad_cname.bv_val ); |
f->f_sub_desc->ad_cname.bv_val ); |
Line 676 filter2bv( Filter *f, struct berval *fst
|
Line 701 filter2bv( Filter *f, struct berval *fst
|
if ( f->f_sub_initial.bv_val != NULL ) { |
if ( f->f_sub_initial.bv_val != NULL ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
|
|
filter_escape_value( &f->f_sub_initial, &tmp ); |
filter_escape_value_x( &f->f_sub_initial, &tmp, ctx ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, ctx ); |
|
|
snprintf( &fstr->bv_val[len-2], tmp.bv_len+3, |
snprintf( &fstr->bv_val[len-2], tmp.bv_len+3, |
/* "(attr=" */ "%s*)", |
/* "(attr=" */ "%s*)", |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
} |
} |
|
|
if ( f->f_sub_any != NULL ) { |
if ( f->f_sub_any != NULL ) { |
for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) { |
for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
filter_escape_value( &f->f_sub_any[i], &tmp ); |
filter_escape_value_x( &f->f_sub_any[i], &tmp, ctx ); |
|
|
fstr->bv_len += tmp.bv_len + 1; |
fstr->bv_len += tmp.bv_len + 1; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, ctx ); |
|
|
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
/* "(attr=[init]*[any*]" */ "%s*)", |
/* "(attr=[init]*[any*]" */ "%s*)", |
tmp.bv_val ); |
tmp.bv_val ); |
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
} |
} |
} |
} |
|
|
if ( f->f_sub_final.bv_val != NULL ) { |
if ( f->f_sub_final.bv_val != NULL ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
|
|
filter_escape_value( &f->f_sub_final, &tmp ); |
filter_escape_value_x( &f->f_sub_final, &tmp, ctx ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, ctx ); |
|
|
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
/* "(attr=[init*][any*]" */ "%s)", |
/* "(attr=[init*][any*]" */ "%s)", |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
} |
} |
|
|
break; |
break; |
Line 723 filter2bv( Filter *f, struct berval *fst
|
Line 748 filter2bv( Filter *f, struct berval *fst
|
case LDAP_FILTER_PRESENT: |
case LDAP_FILTER_PRESENT: |
fstr->bv_len = f->f_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_desc->ad_cname.bv_len + |
( sizeof("(=*)") - 1 ); |
( sizeof("(=*)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = alloc( fstr->bv_len + 1, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
f->f_desc->ad_cname.bv_val ); |
f->f_desc->ad_cname.bv_val ); |
Line 733 filter2bv( Filter *f, struct berval *fst
|
Line 758 filter2bv( Filter *f, struct berval *fst
|
case LDAP_FILTER_OR: |
case LDAP_FILTER_OR: |
case LDAP_FILTER_NOT: |
case LDAP_FILTER_NOT: |
fstr->bv_len = sizeof("(%)") - 1; |
fstr->bv_len = sizeof("(%)") - 1; |
fstr->bv_val = ch_malloc( fstr->bv_len + 128 ); |
fstr->bv_val = alloc( fstr->bv_len + 128, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)", |
f->f_choice == LDAP_FILTER_AND ? '&' : |
f->f_choice == LDAP_FILTER_AND ? '&' : |
Line 745 filter2bv( Filter *f, struct berval *fst
|
Line 770 filter2bv( Filter *f, struct berval *fst
|
filter2bv( p, &tmp ); |
filter2bv( p, &tmp ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, ctx ); |
|
|
snprintf( &fstr->bv_val[len-1], tmp.bv_len + 2, |
snprintf( &fstr->bv_val[len-1], tmp.bv_len + 2, |
/*"("*/ "%s)", tmp.bv_val ); |
/*"("*/ "%s)", tmp.bv_val ); |
Line 757 filter2bv( Filter *f, struct berval *fst
|
Line 782 filter2bv( Filter *f, struct berval *fst
|
|
|
case LDAP_FILTER_EXT: { |
case LDAP_FILTER_EXT: { |
struct berval ad; |
struct berval ad; |
filter_escape_value( &f->f_mr_value, &tmp ); |
filter_escape_value_x( &f->f_mr_value, &tmp, ctx ); |
|
|
if ( f->f_mr_desc ) { |
if ( f->f_mr_desc ) { |
ad = f->f_mr_desc->ad_cname; |
ad = f->f_mr_desc->ad_cname; |
Line 770 filter2bv( Filter *f, struct berval *fst
|
Line 795 filter2bv( Filter *f, struct berval *fst
|
( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) + |
( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) + |
( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) + |
( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) + |
tmp.bv_len + ( sizeof("(:=)") - 1 ); |
tmp.bv_len + ( sizeof("(:=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = alloc( fstr->bv_len + 1, ctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)", |
ad.bv_val, |
ad.bv_val, |
Line 778 filter2bv( Filter *f, struct berval *fst
|
Line 803 filter2bv( Filter *f, struct berval *fst
|
f->f_mr_rule_text.bv_len ? ":" : "", |
f->f_mr_rule_text.bv_len ? ":" : "", |
f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "", |
f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "", |
tmp.bv_val ); |
tmp.bv_val ); |
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, ctx ); |
} break; |
} break; |
|
|
case SLAPD_FILTER_COMPUTED: |
case SLAPD_FILTER_COMPUTED: |
ber_str2bv( |
ber_str2bv_x( |
f->f_result == LDAP_COMPARE_FALSE ? "(?=false)" : |
f->f_result == LDAP_COMPARE_FALSE ? "(?=false)" : |
f->f_result == LDAP_COMPARE_TRUE ? "(?=true)" : |
f->f_result == LDAP_COMPARE_TRUE ? "(?=true)" : |
f->f_result == SLAPD_COMPARE_UNDEFINED ? "(?=undefined)" : |
f->f_result == SLAPD_COMPARE_UNDEFINED ? "(?=undefined)" : |
Line 791 filter2bv( Filter *f, struct berval *fst
|
Line 816 filter2bv( Filter *f, struct berval *fst
|
f->f_result == LDAP_COMPARE_TRUE ? sizeof("(?=true)")-1 : |
f->f_result == LDAP_COMPARE_TRUE ? sizeof("(?=true)")-1 : |
f->f_result == SLAPD_COMPARE_UNDEFINED ? sizeof("(?=undefined)")-1 : |
f->f_result == SLAPD_COMPARE_UNDEFINED ? sizeof("(?=undefined)")-1 : |
sizeof("(?=error)")-1, |
sizeof("(?=error)")-1, |
1, fstr ); |
1, fstr, ctx ); |
break; |
break; |
|
|
default: |
default: |
ber_str2bv( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr ); |
ber_str2bv_x( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr, ctx ); |
break; |
break; |
} |
} |
} |
} |
|
|
|
void |
|
filter2bv( Filter *f, struct berval *fstr ) |
|
{ |
|
filter2bv_x( f, fstr, NULL ); |
|
} |
|
|
int |
int |
filter_escape_value( |
filter_escape_value_x( |
struct berval *in, |
struct berval *in, |
struct berval *out ) |
struct berval *out, |
|
void *ctx ) |
{ |
{ |
ber_len_t i; |
ber_len_t i; |
assert( in ); |
assert( in ); |
assert( out ); |
assert( out ); |
|
|
out->bv_val = (char *) ch_malloc( ( in->bv_len * 3 ) + 1 ); |
i = in->bv_len * 3 + 1; |
|
out->bv_val = ctx ? sl_malloc( i, ctx ) : ch_malloc( i ); |
out->bv_len = 0; |
out->bv_len = 0; |
|
|
for( i=0; i < in->bv_len ; i++ ) { |
for( i=0; i < in->bv_len ; i++ ) { |
Line 826 filter_escape_value(
|
Line 859 filter_escape_value(
|
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
|
|
|
int |
|
filter_escape_value( |
|
struct berval *in, |
|
struct berval *out ) |
|
{ |
|
return filter_escape_value_x( in, out, NULL ); |
|
} |
|
|
static int |
static int |
get_simple_vrFilter( |
get_simple_vrFilter( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
ValuesReturnFilter **filt, |
ValuesReturnFilter **filt, |
const char **text ) |
const char **text ) |
Line 840 get_simple_vrFilter(
|
Line 881 get_simple_vrFilter(
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_simple_vrFilter: conn %d\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "begin get_simple_vrFilter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_simple_vrFilter\n", 0, 0, 0 ); |
#endif |
#endif |
Line 861 get_simple_vrFilter(
|
Line 902 get_simple_vrFilter(
|
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL2, |
LDAP_LOG( FILTER, DETAIL2, |
"get_simple_vrFilter: conn %d EQUALITY\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d EQUALITY\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &vrf.vrf_ava, SLAP_MR_EQUALITY, text ); |
err = get_ava( op, ber, &vrf.vrf_ava, SLAP_MR_EQUALITY, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 876 get_simple_vrFilter(
|
Line 917 get_simple_vrFilter(
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_simple_vrFilter: conn %d SUBSTRINGS\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d SUBSTRINGS\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "SUBSTRINGS\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ssa( conn, ber, &vrf.vrf_sub, text ); |
err = get_ssa( op, ber, &vrf.vrf_sub, text ); |
break; |
break; |
|
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_simple_vrFilter: conn %d GE\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d GE\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &vrf.vrf_ava, SLAP_MR_ORDERING, text ); |
err = get_ava( op, ber, &vrf.vrf_ava, SLAP_MR_ORDERING, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 899 get_simple_vrFilter(
|
Line 940 get_simple_vrFilter(
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_simple_vrFilter: conn %d LE\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d LE\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &vrf.vrf_ava, SLAP_MR_ORDERING, text ); |
err = get_ava( op, ber, &vrf.vrf_ava, SLAP_MR_ORDERING, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 914 get_simple_vrFilter(
|
Line 955 get_simple_vrFilter(
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_simple_vrFilter: conn %d PRESENT\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d PRESENT\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); |
#endif |
#endif |
Line 939 get_simple_vrFilter(
|
Line 980 get_simple_vrFilter(
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_simple_vrFilter: conn %d APPROX\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d APPROX\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); |
#endif |
#endif |
err = get_ava( ber, &vrf.vrf_ava, SLAP_MR_EQUALITY_APPROX, text ); |
err = get_ava( op, ber, &vrf.vrf_ava, SLAP_MR_EQUALITY_APPROX, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 952 get_simple_vrFilter(
|
Line 993 get_simple_vrFilter(
|
case LDAP_FILTER_EXT: |
case LDAP_FILTER_EXT: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_simple_vrFilter: conn %d EXTENSIBLE\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d EXTENSIBLE\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "EXTENSIBLE\n", 0, 0, 0 ); |
#endif |
#endif |
|
|
err = get_mra( ber, &vrf.vrf_mra, text ); |
err = get_mra( op, ber, &vrf.vrf_mra, text ); |
if ( err != LDAP_SUCCESS ) { |
if ( err != LDAP_SUCCESS ) { |
break; |
break; |
} |
} |
Line 970 get_simple_vrFilter(
|
Line 1011 get_simple_vrFilter(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ERR, |
LDAP_LOG( FILTER, ERR, |
"get_simple_vrFilter: conn %d unknown filter type=%lu\n", |
"get_simple_vrFilter: conn %d unknown filter type=%lu\n", |
conn->c_connid, vrf.vrf_choice, 0 ); |
op->o_connid, vrf.vrf_choice, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_ANY, "get_simple_vrFilter: unknown filter type=%lu\n", |
Debug( LDAP_DEBUG_ANY, "get_simple_vrFilter: unknown filter type=%lu\n", |
vrf.vrf_choice, 0, 0 ); |
vrf.vrf_choice, 0, 0 ); |
Line 994 get_simple_vrFilter(
|
Line 1035 get_simple_vrFilter(
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL2, |
LDAP_LOG( FILTER, DETAIL2, |
"get_simple_vrFilter: conn %d exit\n", conn->c_connid, 0, 0 ); |
"get_simple_vrFilter: conn %d exit\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "end get_simple_vrFilter %d\n", err, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_simple_vrFilter %d\n", err, 0, 0 ); |
#endif |
#endif |
Line 1003 get_simple_vrFilter(
|
Line 1044 get_simple_vrFilter(
|
} |
} |
|
|
int |
int |
get_vrFilter( Connection *conn, BerElement *ber, |
get_vrFilter( Operation *op, BerElement *ber, |
ValuesReturnFilter **vrf, |
ValuesReturnFilter **vrf, |
const char **text ) |
const char **text ) |
{ |
{ |
Line 1043 get_vrFilter( Connection *conn, BerEleme
|
Line 1084 get_vrFilter( Connection *conn, BerEleme
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_vrFilter: conn %d start\n", conn->c_connid, 0, 0 ); |
"get_vrFilter: conn %d start\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "begin get_vrFilter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_vrFilter\n", 0, 0, 0 ); |
#endif |
#endif |
Line 1065 get_vrFilter( Connection *conn, BerEleme
|
Line 1106 get_vrFilter( Connection *conn, BerEleme
|
tag != LBER_DEFAULT; |
tag != LBER_DEFAULT; |
tag = ber_next_element( ber, &len, last ) ) |
tag = ber_next_element( ber, &len, last ) ) |
{ |
{ |
int err = get_simple_vrFilter( conn, ber, n, text ); |
int err = get_simple_vrFilter( op, ber, n, text ); |
|
|
if ( err != LDAP_SUCCESS ) return( err ); |
if ( err != LDAP_SUCCESS ) return( err ); |
|
|
Line 1075 get_vrFilter( Connection *conn, BerEleme
|
Line 1116 get_vrFilter( Connection *conn, BerEleme
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_vrFilter: conn %d exit\n", conn->c_connid, 0, 0 ); |
"get_vrFilter: conn %d exit\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "end get_vrFilter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_vrFilter\n", 0, 0, 0 ); |
#endif |
#endif |
Line 1083 get_vrFilter( Connection *conn, BerEleme
|
Line 1124 get_vrFilter( Connection *conn, BerEleme
|
} |
} |
|
|
void |
void |
vrFilter_free( ValuesReturnFilter *vrf ) |
vrFilter_free( Operation *op, ValuesReturnFilter *vrf ) |
{ |
{ |
ValuesReturnFilter *p, *next; |
ValuesReturnFilter *p, *next; |
|
|
Line 1102 vrFilter_free( ValuesReturnFilter *vrf )
|
Line 1143 vrFilter_free( ValuesReturnFilter *vrf )
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
ava_free( vrf->vrf_ava, 1 ); |
ava_free( op, vrf->vrf_ava, 1 ); |
break; |
break; |
|
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
if ( vrf->vrf_sub_initial.bv_val != NULL ) { |
if ( vrf->vrf_sub_initial.bv_val != NULL ) { |
free( vrf->vrf_sub_initial.bv_val ); |
#ifdef notyet |
|
op->o_tmpfree( vrf->vrf_sub_initial.bv_val, op->o_tmpmemctx ); |
|
#else |
|
ch_free( vrf->vrf_sub_initial.bv_val ); |
|
#endif |
} |
} |
ber_bvarray_free( vrf->vrf_sub_any ); |
ber_bvarray_free_x( vrf->vrf_sub_any, op->o_tmpmemctx ); |
if ( vrf->vrf_sub_final.bv_val != NULL ) { |
if ( vrf->vrf_sub_final.bv_val != NULL ) { |
free( vrf->vrf_sub_final.bv_val ); |
#ifdef notyet |
|
op->o_tmpfree( vrf->vrf_sub_final.bv_val, op->o_tmpmemctx ); |
|
#else |
|
ch_free( vrf->vrf_sub_final.bv_val ); |
|
#endif |
} |
} |
ch_free( vrf->vrf_sub ); |
op->o_tmpfree( vrf->vrf_sub, op->o_tmpmemctx ); |
break; |
break; |
|
|
case LDAP_FILTER_EXT: |
case LDAP_FILTER_EXT: |
mra_free( vrf->vrf_mra, 1 ); |
mra_free( op, vrf->vrf_mra, 1 ); |
break; |
break; |
|
|
case SLAPD_FILTER_COMPUTED: |
case SLAPD_FILTER_COMPUTED: |
Line 1134 vrFilter_free( ValuesReturnFilter *vrf )
|
Line 1183 vrFilter_free( ValuesReturnFilter *vrf )
|
break; |
break; |
} |
} |
|
|
free( vrf ); |
op->o_tmpfree( vrf, op->o_tmpmemctx ); |
} |
} |
} |
} |
|
|
|
|
void |
void |
vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr ) |
vrFilter2bv( Operation *op, ValuesReturnFilter *vrf, struct berval *fstr ) |
{ |
{ |
ValuesReturnFilter *p; |
ValuesReturnFilter *p; |
struct berval tmp; |
struct berval tmp; |
ber_len_t len; |
ber_len_t len; |
|
BER_MEMREALLOC_FN *reallo = op->o_tmpmemctx ? sl_realloc : |
|
(BER_MEMREALLOC_FN *)ch_realloc; |
|
|
if ( vrf == NULL ) { |
if ( vrf == NULL ) { |
ber_str2bv( "No filter!", sizeof("No filter!")-1, 1, fstr ); |
ber_str2bv_x( "No filter!", sizeof("No filter!")-1, 1, fstr, op->o_tmpmemctx ); |
return; |
return; |
} |
} |
|
|
fstr->bv_len = sizeof("()") - 1; |
fstr->bv_len = sizeof("()") - 1; |
fstr->bv_val = ch_malloc( fstr->bv_len + 128 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "()"); |
snprintf( fstr->bv_val, fstr->bv_len + 1, "()"); |
|
|
for ( p = vrf; p != NULL; p = p->vrf_next ) { |
for ( p = vrf; p != NULL; p = p->vrf_next ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
|
|
simple_vrFilter2bv( p, &tmp ); |
simple_vrFilter2bv( op, p, &tmp ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( &fstr->bv_val[len-1], tmp.bv_len + 2, |
snprintf( &fstr->bv_val[len-1], tmp.bv_len + 2, |
/*"("*/ "%s)", tmp.bv_val ); |
/*"("*/ "%s)", tmp.bv_val ); |
|
|
ch_free( tmp.bv_val ); |
op->o_tmpfree( tmp.bv_val, op->o_tmpmemctx ); |
} |
} |
} |
} |
|
|
static void |
static void |
simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr ) |
simple_vrFilter2bv( Operation *op, ValuesReturnFilter *vrf, struct berval *fstr ) |
{ |
{ |
struct berval tmp; |
struct berval tmp; |
ber_len_t len; |
ber_len_t len; |
|
BER_MEMREALLOC_FN *reallo = op->o_tmpmemctx ? sl_realloc : |
|
(BER_MEMREALLOC_FN *) ch_realloc; |
|
|
if ( vrf == NULL ) { |
if ( vrf == NULL ) { |
ber_str2bv( "No filter!", sizeof("No filter!")-1, 1, fstr ); |
ber_str2bv_x( "No filter!", sizeof("No filter!")-1, 1, fstr, op->o_tmpmemctx ); |
return; |
return; |
} |
} |
|
|
switch ( vrf->vrf_choice ) { |
switch ( vrf->vrf_choice ) { |
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
filter_escape_value( &vrf->vrf_av_value, &tmp ); |
filter_escape_value_x( &vrf->vrf_av_value, &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(=)") - 1 ); |
tmp.bv_len + ( sizeof("(=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)", |
vrf->vrf_av_desc->ad_cname.bv_val, |
vrf->vrf_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
break; |
break; |
|
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
filter_escape_value( &vrf->vrf_av_value, &tmp ); |
filter_escape_value_x( &vrf->vrf_av_value, &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(>=)") - 1 ); |
tmp.bv_len + ( sizeof("(>=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)", |
vrf->vrf_av_desc->ad_cname.bv_val, |
vrf->vrf_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
break; |
break; |
|
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
filter_escape_value( &vrf->vrf_av_value, &tmp ); |
filter_escape_value_x( &vrf->vrf_av_value, &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(<=)") - 1 ); |
tmp.bv_len + ( sizeof("(<=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)", |
vrf->vrf_av_desc->ad_cname.bv_val, |
vrf->vrf_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
break; |
break; |
|
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
filter_escape_value( &vrf->vrf_av_value, &tmp ); |
filter_escape_value_x( &vrf->vrf_av_value, &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len + |
tmp.bv_len + ( sizeof("(~=)") - 1 ); |
tmp.bv_len + ( sizeof("(~=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)", |
vrf->vrf_av_desc->ad_cname.bv_val, |
vrf->vrf_av_desc->ad_cname.bv_val, |
tmp.bv_val ); |
tmp.bv_val ); |
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
break; |
break; |
|
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
fstr->bv_len = vrf->vrf_sub_desc->ad_cname.bv_len + |
fstr->bv_len = vrf->vrf_sub_desc->ad_cname.bv_len + |
( sizeof("(=*)") - 1 ); |
( sizeof("(=*)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 128 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
vrf->vrf_sub_desc->ad_cname.bv_val ); |
vrf->vrf_sub_desc->ad_cname.bv_val ); |
Line 1249 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1301 simple_vrFilter2bv( ValuesReturnFilter *
|
if ( vrf->vrf_sub_initial.bv_val != NULL ) { |
if ( vrf->vrf_sub_initial.bv_val != NULL ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
|
|
filter_escape_value( &vrf->vrf_sub_initial, &tmp ); |
filter_escape_value_x( &vrf->vrf_sub_initial, &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( &fstr->bv_val[len-2], tmp.bv_len+3, |
snprintf( &fstr->bv_val[len-2], tmp.bv_len+3, |
/* "(attr=" */ "%s*)", |
/* "(attr=" */ "%s*)", |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
} |
} |
|
|
if ( vrf->vrf_sub_any != NULL ) { |
if ( vrf->vrf_sub_any != NULL ) { |
int i; |
int i; |
for ( i = 0; vrf->vrf_sub_any[i].bv_val != NULL; i++ ) { |
for ( i = 0; vrf->vrf_sub_any[i].bv_val != NULL; i++ ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
filter_escape_value( &vrf->vrf_sub_any[i], &tmp ); |
filter_escape_value_x( &vrf->vrf_sub_any[i], &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len += tmp.bv_len + 1; |
fstr->bv_len += tmp.bv_len + 1; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
/* "(attr=[init]*[any*]" */ "%s*)", |
/* "(attr=[init]*[any*]" */ "%s*)", |
tmp.bv_val ); |
tmp.bv_val ); |
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
} |
} |
} |
} |
|
|
if ( vrf->vrf_sub_final.bv_val != NULL ) { |
if ( vrf->vrf_sub_final.bv_val != NULL ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
|
|
filter_escape_value( &vrf->vrf_sub_final, &tmp ); |
filter_escape_value_x( &vrf->vrf_sub_final, &tmp, op->o_tmpmemctx ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); |
fstr->bv_val = reallo( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
snprintf( &fstr->bv_val[len-1], tmp.bv_len+3, |
/* "(attr=[init*][any*]" */ "%s)", |
/* "(attr=[init*][any*]" */ "%s)", |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
} |
} |
|
|
break; |
break; |
Line 1297 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1349 simple_vrFilter2bv( ValuesReturnFilter *
|
case LDAP_FILTER_PRESENT: |
case LDAP_FILTER_PRESENT: |
fstr->bv_len = vrf->vrf_desc->ad_cname.bv_len + |
fstr->bv_len = vrf->vrf_desc->ad_cname.bv_len + |
( sizeof("(=*)") - 1 ); |
( sizeof("(=*)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)", |
vrf->vrf_desc->ad_cname.bv_val ); |
vrf->vrf_desc->ad_cname.bv_val ); |
Line 1305 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1357 simple_vrFilter2bv( ValuesReturnFilter *
|
|
|
case LDAP_FILTER_EXT: { |
case LDAP_FILTER_EXT: { |
struct berval ad; |
struct berval ad; |
filter_escape_value( &vrf->vrf_mr_value, &tmp ); |
filter_escape_value_x( &vrf->vrf_mr_value, &tmp, op->o_tmpmemctx ); |
|
|
if ( vrf->vrf_mr_desc ) { |
if ( vrf->vrf_mr_desc ) { |
ad = vrf->vrf_mr_desc->ad_cname; |
ad = vrf->vrf_mr_desc->ad_cname; |
Line 1318 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1370 simple_vrFilter2bv( ValuesReturnFilter *
|
( vrf->vrf_mr_dnattrs ? sizeof(":dn")-1 : 0 ) + |
( vrf->vrf_mr_dnattrs ? sizeof(":dn")-1 : 0 ) + |
( vrf->vrf_mr_rule_text.bv_len ? vrf->vrf_mr_rule_text.bv_len+1 : 0 ) + |
( vrf->vrf_mr_rule_text.bv_len ? vrf->vrf_mr_rule_text.bv_len+1 : 0 ) + |
tmp.bv_len + ( sizeof("(:=)") - 1 ); |
tmp.bv_len + ( sizeof("(:=)") - 1 ); |
fstr->bv_val = ch_malloc( fstr->bv_len + 1 ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)", |
ad.bv_val, |
ad.bv_val, |
Line 1327 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1379 simple_vrFilter2bv( ValuesReturnFilter *
|
vrf->vrf_mr_rule_text.bv_len ? vrf->vrf_mr_rule_text.bv_val : "", |
vrf->vrf_mr_rule_text.bv_len ? vrf->vrf_mr_rule_text.bv_val : "", |
tmp.bv_val ); |
tmp.bv_val ); |
|
|
ber_memfree( tmp.bv_val ); |
ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); |
} break; |
} break; |
|
|
case SLAPD_FILTER_COMPUTED: |
case SLAPD_FILTER_COMPUTED: |
ber_str2bv( |
ber_str2bv_x( |
vrf->vrf_result == LDAP_COMPARE_FALSE ? "(?=false)" : |
vrf->vrf_result == LDAP_COMPARE_FALSE ? "(?=false)" : |
vrf->vrf_result == LDAP_COMPARE_TRUE ? "(?=true)" : |
vrf->vrf_result == LDAP_COMPARE_TRUE ? "(?=true)" : |
vrf->vrf_result == SLAPD_COMPARE_UNDEFINED ? "(?=undefined)" : |
vrf->vrf_result == SLAPD_COMPARE_UNDEFINED ? "(?=undefined)" : |
Line 1340 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1392 simple_vrFilter2bv( ValuesReturnFilter *
|
vrf->vrf_result == LDAP_COMPARE_TRUE ? sizeof("(?=true)")-1 : |
vrf->vrf_result == LDAP_COMPARE_TRUE ? sizeof("(?=true)")-1 : |
vrf->vrf_result == SLAPD_COMPARE_UNDEFINED ? sizeof("(?=undefined)")-1 : |
vrf->vrf_result == SLAPD_COMPARE_UNDEFINED ? sizeof("(?=undefined)")-1 : |
sizeof("(?=error)")-1, |
sizeof("(?=error)")-1, |
1, fstr ); |
1, fstr, op->o_tmpmemctx ); |
break; |
break; |
|
|
default: |
default: |
ber_str2bv( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr ); |
ber_str2bv_x( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr, op->o_tmpmemctx ); |
break; |
break; |
} |
} |
} |
} |
Line 1352 simple_vrFilter2bv( ValuesReturnFilter *
|
Line 1404 simple_vrFilter2bv( ValuesReturnFilter *
|
#if 0 /* unused */ |
#if 0 /* unused */ |
static int |
static int |
get_substring_vrFilter( |
get_substring_vrFilter( |
Connection *conn, |
Operation *op, |
BerElement *ber, |
BerElement *ber, |
ValuesReturnFilter *vrf, |
ValuesReturnFilter *vrf, |
const char **text ) |
const char **text ) |
Line 1367 get_substring_vrFilter(
|
Line 1419 get_substring_vrFilter(
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_substring_filter: conn %d begin\n", conn->c_connid, 0, 0 ); |
"get_substring_filter: conn %d begin\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); |
#endif |
#endif |
Line 1426 get_substring_vrFilter(
|
Line 1478 get_substring_vrFilter(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ERR, |
LDAP_LOG( FILTER, ERR, |
"get_filter_substring: conn %d unknown substring choice=%ld\n", |
"get_filter_substring: conn %d unknown substring choice=%ld\n", |
conn->c_connid, (long)tag, 0 ); |
op->o_connid, (long)tag, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, |
Debug( LDAP_DEBUG_FILTER, |
" unknown substring choice=%ld\n", |
" unknown substring choice=%ld\n", |
Line 1452 get_substring_vrFilter(
|
Line 1504 get_substring_vrFilter(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_substring_filter: conn %d INITIAL\n", |
"get_substring_filter: conn %d INITIAL\n", |
conn->c_connid, 0, 0 ); |
op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); |
#endif |
#endif |
Line 1471 get_substring_vrFilter(
|
Line 1523 get_substring_vrFilter(
|
case LDAP_SUBSTRING_ANY: |
case LDAP_SUBSTRING_ANY: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_substring_filter: conn %d ANY\n", conn->c_connid, 0, 0 ); |
"get_substring_filter: conn %d ANY\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); |
#endif |
#endif |
Line 1487 get_substring_vrFilter(
|
Line 1539 get_substring_vrFilter(
|
case LDAP_SUBSTRING_FINAL: |
case LDAP_SUBSTRING_FINAL: |
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, DETAIL1, |
LDAP_LOG( FILTER, DETAIL1, |
"get_substring_filter: conn %d FINAL\n", conn->c_connid, 0, 0 ); |
"get_substring_filter: conn %d FINAL\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); |
#endif |
#endif |
Line 1504 get_substring_vrFilter(
|
Line 1556 get_substring_vrFilter(
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, INFO, |
LDAP_LOG( FILTER, INFO, |
"get_substring_filter: conn %d unknown substring type %ld\n", |
"get_substring_filter: conn %d unknown substring type %ld\n", |
conn->c_connid, (long)tag, 0 ); |
op->o_connid, (long)tag, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, |
Debug( LDAP_DEBUG_FILTER, |
" unknown substring type=%ld\n", |
" unknown substring type=%ld\n", |
Line 1517 return_error:
|
Line 1569 return_error:
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, INFO, |
LDAP_LOG( FILTER, INFO, |
"get_substring_filter: conn %d error %ld\n", |
"get_substring_filter: conn %d error %ld\n", |
conn->c_connid, (long)rc, 0 ); |
op->o_connid, (long)rc, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, " error=%ld\n", |
Debug( LDAP_DEBUG_FILTER, " error=%ld\n", |
(long) rc, 0, 0 ); |
(long) rc, 0, 0 ); |
Line 1532 return_error:
|
Line 1584 return_error:
|
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( FILTER, ENTRY, |
LDAP_LOG( FILTER, ENTRY, |
"get_substring_filter: conn %d exit\n", conn->c_connid, 0, 0 ); |
"get_substring_filter: conn %d exit\n", op->o_connid, 0, 0 ); |
#else |
#else |
Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); |
#endif |
#endif |