mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
Changed AttributeName back into an array instead of a linked list.
Fixed bug in do_search eating up controls.
This commit is contained in:
parent
7a853f3030
commit
bcdfdb968f
8 changed files with 55 additions and 62 deletions
|
|
@ -1275,9 +1275,10 @@ acl_free( AccessControl *a )
|
|||
filter_free( a->acl_filter );
|
||||
if ( a->acl_dn_pat.bv_len )
|
||||
free ( a->acl_dn_pat.bv_val );
|
||||
for (; a->acl_attrs; a->acl_attrs = an) {
|
||||
an = a->acl_attrs->an_next;
|
||||
free( a->acl_attrs->an_name.bv_val );
|
||||
if ( a->acl_attrs ) {
|
||||
for ( an = a->acl_attrs; an->an_name.bv_val; an++ ) {
|
||||
free( an->an_name.bv_val );
|
||||
}
|
||||
free( a->acl_attrs );
|
||||
}
|
||||
for (; a->acl_access; a->acl_access = n) {
|
||||
|
|
@ -1489,7 +1490,7 @@ print_acl( Backend *be, AccessControl *a )
|
|||
to++;
|
||||
|
||||
fprintf( stderr, " attrs=" );
|
||||
for ( an = a->acl_attrs; an; an=an->an_next ) {
|
||||
for ( an = a->acl_attrs; an && an->an_name.bv_val; an++ ) {
|
||||
if ( ! first ) {
|
||||
fprintf( stderr, "," );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,9 @@ int ad_inlist(
|
|||
AttributeDescription *desc,
|
||||
AttributeName *attrs )
|
||||
{
|
||||
for( ; attrs; attrs=attrs->an_next ) {
|
||||
if (! attrs ) return 0;
|
||||
|
||||
for( ; attrs->an_name.bv_val; attrs++ ) {
|
||||
ObjectClass *oc;
|
||||
int rc;
|
||||
|
||||
|
|
@ -415,7 +417,7 @@ an_find(
|
|||
{
|
||||
if( a == NULL ) return 0;
|
||||
|
||||
for ( ; a; a=a->an_next ) {
|
||||
for ( ; a->an_name.bv_val; a++ ) {
|
||||
if ( a->an_name.bv_len != s->bv_len) continue;
|
||||
if ( strcasecmp( s->bv_val, a->an_name.bv_val ) == 0 ) {
|
||||
return( 1 );
|
||||
|
|
@ -434,31 +436,36 @@ str2anlist( AttributeName *an, const char *in, const char *brkstr )
|
|||
char *str;
|
||||
char *s;
|
||||
char *lasts;
|
||||
int i, j;
|
||||
const char *text;
|
||||
AttributeName *a, *anew;
|
||||
AttributeName *anew;
|
||||
|
||||
/* find last element in list */
|
||||
for (i = 0; an && an[i].an_name.bv_val; i++);
|
||||
|
||||
/* protect the input string from strtok */
|
||||
str = ch_strdup( in );
|
||||
|
||||
/* find last element in list */
|
||||
for (a = an; a && a->an_next; a=a->an_next);
|
||||
|
||||
/* Count words in string */
|
||||
j=1;
|
||||
for ( s = str; *s; s++ ) {
|
||||
if ( strchr( brkstr, *s ) != NULL ) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
an = ch_realloc( an, ( i + j + 1 ) * sizeof( AttributeName ) );
|
||||
anew = an + i;
|
||||
for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
|
||||
s != NULL;
|
||||
s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
|
||||
{
|
||||
anew = ch_malloc( sizeof( AttributeName ) );
|
||||
anew->an_next = NULL;
|
||||
anew->an_desc = NULL;
|
||||
ber_str2bv(s, 0, 1, &anew->an_name);
|
||||
slap_bv2ad(&anew->an_name, &anew->an_desc, &text);
|
||||
if (!an) {
|
||||
an = anew;
|
||||
} else {
|
||||
a->an_next = anew;
|
||||
}
|
||||
a = anew;
|
||||
anew++;
|
||||
}
|
||||
anew->an_name.bv_val = NULL;
|
||||
|
||||
free( str );
|
||||
return( an );
|
||||
|
|
|
|||
|
|
@ -438,19 +438,18 @@ ldap_back_map_filter(
|
|||
char **
|
||||
ldap_back_map_attrs(
|
||||
struct ldapmap *at_map,
|
||||
AttributeName *a,
|
||||
AttributeName *an,
|
||||
int remap
|
||||
)
|
||||
{
|
||||
int i;
|
||||
char **na;
|
||||
AttributeName *an;
|
||||
struct berval mapped;
|
||||
|
||||
if (a == NULL)
|
||||
if (an == NULL)
|
||||
return(NULL);
|
||||
|
||||
for (i = 0, an=a; an; an=an->an_next, i++) {
|
||||
for (i = 0; an[i].an_name.bv_val; i++) {
|
||||
/* */
|
||||
}
|
||||
|
||||
|
|
@ -458,8 +457,8 @@ ldap_back_map_attrs(
|
|||
if (na == NULL)
|
||||
return(NULL);
|
||||
|
||||
for (i = 0, an=a; an; an=an->an_next) {
|
||||
ldap_back_map(at_map, &an->an_name, &mapped, remap);
|
||||
for (i = 0; an[i].an_name.bv_val; i++) {
|
||||
ldap_back_map(at_map, &an[i].an_name, &mapped, remap);
|
||||
if (mapped.bv_val != NULL) {
|
||||
na[i] = mapped.bv_val;
|
||||
i++;
|
||||
|
|
|
|||
|
|
@ -225,11 +225,10 @@ ldap_back_search(
|
|||
|
||||
mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, 0);
|
||||
if ( mapped_attrs == NULL && attrs) {
|
||||
AttributeName *an;
|
||||
for (count=0, an=attrs; an; an=an->an_next,count++);
|
||||
for (count=0; attrs[count].an_name.bv_val; count++);
|
||||
mapped_attrs = ch_malloc( (count+1) * sizeof(char *));
|
||||
for (count=0, an=attrs; an; an=an->an_next,count++) {
|
||||
mapped_attrs[count] = an->an_name.bv_val;
|
||||
for (count=0; attrs[count].an_name.bv_val; count++) {
|
||||
mapped_attrs[count] = attrs[count].an_name.bv_val;
|
||||
}
|
||||
mapped_attrs[count] = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,9 +352,9 @@ meta_back_search(
|
|||
attrs, 0 );
|
||||
if ( mapped_attrs == NULL && attrs) {
|
||||
AttributeName *an;
|
||||
for ( count=0, an=attrs; an; an=an->an_next, count++ );
|
||||
for ( count=0, an=attrs; an->an_name.bv_val; an++, count++ );
|
||||
mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *));
|
||||
for ( count=0, an=attrs; an; an=an->an_next, count++ ) {
|
||||
for ( count=0, an=attrs; an->an_name.bv_val; an++, count++ ) {
|
||||
mapped_attrs[ count ] = an->an_name.bv_val;
|
||||
}
|
||||
mapped_attrs[ count ] = NULL;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ shell_back_search(
|
|||
fprintf( wfp, "filter: %s\n", filterstr );
|
||||
fprintf( wfp, "attrsonly: %d\n", attrsonly ? 1 : 0 );
|
||||
fprintf( wfp, "attrs:%s", attrs == NULL ? " all" : "" );
|
||||
for ( an = attrs; an; an=an->an_next ) {
|
||||
for ( an = attrs; an && an->an_name.bv_val; an++ ) {
|
||||
fprintf( wfp, " %s", an->an_name.bv_val );
|
||||
}
|
||||
fprintf( wfp, "\n" );
|
||||
|
|
|
|||
|
|
@ -37,9 +37,11 @@ do_search(
|
|||
struct berval nbase = { 0, NULL };
|
||||
struct berval fstr = { 0, NULL };
|
||||
Filter *filter = NULL;
|
||||
AttributeName an, *al = NULL, *alast, *anew;
|
||||
AttributeName *an;
|
||||
ber_len_t siz, off;
|
||||
Backend *be;
|
||||
int rc;
|
||||
int i;
|
||||
const char *text;
|
||||
int manageDSAit;
|
||||
|
||||
|
|
@ -156,30 +158,17 @@ do_search(
|
|||
|
||||
|
||||
/* attributes */
|
||||
if ( ber_scanf( op->o_ber, "{" /*}*/ ) == LBER_ERROR ) {
|
||||
siz = sizeof(AttributeName);
|
||||
off = 0;
|
||||
if ( ber_scanf( op->o_ber, "{w}}", &an, &siz, off ) == LBER_ERROR ) {
|
||||
send_ldap_disconnect( conn, op,
|
||||
LDAP_PROTOCOL_ERROR, "decoding attrs error" );
|
||||
rc = SLAPD_DISCONNECT;
|
||||
goto return_results;
|
||||
}
|
||||
while ( ber_scanf( op->o_ber, "o", &an.an_name ) != LBER_ERROR) {
|
||||
anew = ch_malloc(sizeof(AttributeName));
|
||||
anew->an_next = NULL;
|
||||
anew->an_name = an.an_name;
|
||||
anew->an_desc = NULL;
|
||||
slap_bv2ad( &anew->an_name, &anew->an_desc, &text );
|
||||
if (!al) {
|
||||
al = anew;
|
||||
} else {
|
||||
alast->an_next = anew;
|
||||
}
|
||||
alast = anew;
|
||||
}
|
||||
if ( ber_scanf( op->o_ber, /*{{*/ "}}" ) == LBER_ERROR ) {
|
||||
send_ldap_disconnect( conn, op,
|
||||
LDAP_PROTOCOL_ERROR, "decoding attrs error" );
|
||||
rc = SLAPD_DISCONNECT;
|
||||
goto return_results;
|
||||
for ( i=0; i<siz; i++ ) {
|
||||
an[i].an_desc = NULL;
|
||||
slap_bv2ad(&an[i].an_name, &an[i].an_desc, &text);
|
||||
}
|
||||
|
||||
if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
|
||||
|
|
@ -204,13 +193,13 @@ do_search(
|
|||
#endif
|
||||
|
||||
|
||||
if ( al != NULL ) {
|
||||
for ( anew = al; anew; anew=anew->an_next ) {
|
||||
if ( siz != 0 ) {
|
||||
for ( i = 0; i<siz; i++ ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
|
||||
"do_search: %s", anew->an_name.bv_val ));
|
||||
"do_search: %s", an[i].an_name.bv_val ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ARGS, " %s", anew->an_name.bv_val, 0, 0 );
|
||||
Debug( LDAP_DEBUG_ARGS, " %s", an[i].an_name.bv_val, 0, 0 );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -274,7 +263,7 @@ do_search(
|
|||
|
||||
if( rc == LDAP_COMPARE_TRUE ) {
|
||||
send_search_entry( NULL, conn, op,
|
||||
entry, al, attrsonly, NULL );
|
||||
entry, an, attrsonly, NULL );
|
||||
}
|
||||
entry_free( entry );
|
||||
|
||||
|
|
@ -330,7 +319,7 @@ do_search(
|
|||
if ( be->be_search ) {
|
||||
(*be->be_search)( be, conn, op, &pbase, &nbase,
|
||||
scope, deref, sizelimit,
|
||||
timelimit, filter, &fstr, al, attrsonly );
|
||||
timelimit, filter, &fstr, an, attrsonly );
|
||||
} else {
|
||||
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
|
||||
NULL, "operation not supported within namingContext", NULL, NULL );
|
||||
|
|
@ -343,11 +332,10 @@ return_results:;
|
|||
|
||||
if( fstr.bv_val != NULL) free( fstr.bv_val );
|
||||
if( filter != NULL) filter_free( filter );
|
||||
for (; al; al=anew ) {
|
||||
anew = al->an_next;
|
||||
free(al->an_name.bv_val);
|
||||
free(al);
|
||||
for (i = 0; i<siz; i++ ) {
|
||||
free(an[i].an_name.bv_val);
|
||||
}
|
||||
free(an);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -457,7 +457,6 @@ typedef struct slap_attr_desc {
|
|||
} AttributeDescription;
|
||||
|
||||
typedef struct slap_attr_name {
|
||||
struct slap_attr_name *an_next;
|
||||
struct berval an_name;
|
||||
AttributeDescription *an_desc;
|
||||
} AttributeName;
|
||||
|
|
|
|||
Loading…
Reference in a new issue