Commit 743c4022 authored by Howard Chu's avatar Howard Chu
Browse files

Changed search attrs from struct berval ** to AttributeName *

parent 94057614
......@@ -202,7 +202,7 @@ parse_acl(
}
} else if ( strncasecmp( left, "attr", 4 ) == 0 ) {
a->acl_attrs = str2bvec( a->acl_attrs,
a->acl_attrs = str2anlist( a->acl_attrs,
right, "," );
} else {
fprintf( stderr,
......@@ -1271,13 +1271,17 @@ void
acl_free( AccessControl *a )
{
Access *n;
AttributeName *an;
if ( a->acl_filter )
filter_free( a->acl_filter );
if ( a->acl_dn_pat.bv_len )
free ( a->acl_dn_pat.bv_val );
if ( a->acl_attrs )
ber_bvecfree( a->acl_attrs );
for (; a->acl_attrs; a->acl_attrs = an) {
an = a->acl_attrs->an_next;
free( a->acl_attrs->an_name.bv_val );
free( a->acl_attrs );
}
for (; a->acl_access; a->acl_access = n) {
n = a->acl_access->a_next;
access_free( a->acl_access );
......@@ -1482,15 +1486,16 @@ print_acl( Backend *be, AccessControl *a )
}
if ( a->acl_attrs != NULL ) {
int i, first = 1;
int first = 1;
AttributeName *an;
to++;
fprintf( stderr, " attrs=" );
for ( i = 0; a->acl_attrs[i] != NULL; i++ ) {
for ( an = a->acl_attrs; an; an=an->an_next ) {
if ( ! first ) {
fprintf( stderr, "," );
}
fputs( a->acl_attrs[i]->bv_val, stderr );
fputs( an->an_name.bv_val, stderr );
first = 0;
}
fprintf( stderr, "\n" );
......
......@@ -282,27 +282,25 @@ int is_ad_subtype(
int ad_inlist(
AttributeDescription *desc,
struct berval **attrs )
AttributeName *attrs )
{
int i;
for( i=0; attrs[i] != NULL; i++ ) {
for( ; attrs; attrs=attrs->an_next ) {
ObjectClass *oc;
AttributeDescription *ad = NULL;
const char *text;
int rc;
rc = slap_bv2ad( attrs[i], &ad, &text );
if( rc == LDAP_SUCCESS ) {
rc = is_ad_subtype( desc, ad );
if( rc ) return 1;
if ( attrs->an_desc ) {
if ( is_ad_subtype( desc, attrs->an_desc ))
return 1;
continue;
}
/*
* EXTENSION: see if requested description is an object class
* if so, return attributes which the class requires/allows
*/
oc = oc_bvfind( attrs[i] );
oc = oc_bvfind( &attrs->an_name );
if( oc != NULL ) {
if ( oc == slap_schema.si_oc_extensibleObject ) {
/* extensibleObject allows the return of anything */
......@@ -399,3 +397,60 @@ int slap_bv2undef_ad(
return LDAP_SUCCESS;
}
int
an_find(
AttributeName *a,
struct berval *s
)
{
if( a == NULL ) return 0;
for ( ; a; a=a->an_next ) {
if ( a->an_name.bv_len != s->bv_len) continue;
if ( strcasecmp( s->bv_val, a->an_name.bv_val ) == 0 ) {
return( 1 );
}
}
return( 0 );
}
/* Convert a delimited string into a list of AttributeNames; Add on
* to an existing list if it was given.
*/
AttributeName *
str2anlist( AttributeName *an, const char *in, const char *brkstr )
{
char *str;
char *s;
char *lasts;
const char *text;
AttributeName *a, *anew;
/* 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);
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;
}
free( str );
return( an );
}
......@@ -40,7 +40,7 @@ bdb_search(
int tlimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
......
......@@ -30,7 +30,7 @@ dnssrv_back_search(
int time,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly )
{
int i;
......
......@@ -112,7 +112,7 @@ ldap_back_map_filter(
char **
ldap_back_map_attrs(
struct ldapmap *at_map,
struct berval **a,
AttributeName *a,
int remap
);
......
......@@ -429,29 +429,30 @@ ldap_back_map_filter(
char **
ldap_back_map_attrs(
struct ldapmap *at_map,
struct berval **a,
AttributeName *a,
int remap
)
{
int i, j, count;
int i;
char *mapped, **na;
AttributeName *an;
if (a == NULL)
return(NULL);
for (count = 0; a[count] != NULL; count++) {
for (i = 0, an=a; an; an=an->an_next, i++) {
/* */
}
na = (char **)ch_calloc( count + 1, sizeof(char *) );
na = (char **)ch_calloc( i + 1, sizeof(char *) );
if (na == NULL)
return(NULL);
for (i = 0, j = 0; i < count; i++) {
mapped = ldap_back_map(at_map, a[i]->bv_val, remap);
for (i = 0, an=a; an; an=an->an_next) {
mapped = ldap_back_map(at_map, an->an_name.bv_val, remap);
if (mapped != NULL) {
na[j] = mapped;
j++;
na[i] = mapped;
i++;
}
}
return(na);
......
......@@ -47,7 +47,7 @@
#include "back-ldap.h"
static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc,
LDAPMessage *e, struct berval **attrs, int attrsonly );
LDAPMessage *e, AttributeName *attrs, int attrsonly );
int
ldap_back_search(
......@@ -62,7 +62,7 @@ ldap_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......@@ -223,10 +223,11 @@ ldap_back_search(
mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, 0);
if ( mapped_attrs == NULL && attrs) {
for (count=0; attrs[count]; count++);
AttributeName *an;
for (count=0, an=attrs; an; an=an->an_next,count++);
mapped_attrs = ch_malloc( (count+1) * sizeof(char *));
for (count=0; attrs[count]; count++) {
mapped_attrs[count] = attrs[count]->bv_val;
for (count=0, an=attrs; an; an=an->an_next,count++) {
mapped_attrs[count] = an->an_name.bv_val;
}
mapped_attrs[count] = NULL;
}
......@@ -365,7 +366,7 @@ ldap_send_entry(
Operation *op,
struct ldapconn *lc,
LDAPMessage *e,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......
......@@ -25,7 +25,7 @@ ldbm_back_operational(
Connection *conn,
Operation *op,
Entry *e,
struct berval **attrs,
AttributeName *attrs,
int opattrs,
Attribute **a )
{
......
......@@ -37,7 +37,7 @@ ldbm_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
......
......@@ -84,7 +84,7 @@ meta_send_entry(
struct metaconn *lc,
int i,
LDAPMessage *e,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
);
......@@ -107,7 +107,7 @@ meta_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......@@ -351,10 +351,11 @@ meta_back_search(
mapped_attrs = ldap_back_map_attrs( &li->targets[ i ]->at_map,
attrs, 0 );
if ( mapped_attrs == NULL && attrs) {
for ( count = 0; attrs[ count ]; count++ );
AttributeName *an;
for ( count=0, an=attrs; an; an=an->an_next, count++ );
mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *));
for ( count = 0; attrs[ count ]; count++ ) {
mapped_attrs[ count ] = attrs[ count ]->bv_val;
for ( count=0, an=attrs; an; an=an->an_next, count++ ) {
mapped_attrs[ count ] = an->an_name.bv_val;
}
mapped_attrs[ count ] = NULL;
}
......@@ -572,7 +573,7 @@ meta_send_entry(
struct metaconn *lc,
int target,
LDAPMessage *e,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......
......@@ -330,8 +330,8 @@ conn_create(
c->c_currentber ? "r" : "",
c->c_writewaiter ? "w" : "",
c->c_ops != NULL ? "x" : "",
c->c_pending_ops != NULL ? "p" : "",
STAILQ_EMPTY( &c->c_ops ) ? "" : "x",
STAILQ_EMPTY( &c->c_pending_ops ) ? "" : "p",
connection_state2str( c->c_conn_state ),
c->c_sasl_bind_in_progress ? "S" : "",
......
......@@ -25,7 +25,7 @@ monitor_back_operational(
Connection *conn,
Operation *op,
Entry *e,
struct berval **attrs,
AttributeName *attrs,
int opattrs,
Attribute **a )
{
......
......@@ -51,7 +51,7 @@ monitor_send_children(
Connection *conn,
Operation *op,
Filter *filter,
struct berval **attrs,
AttributeName *attrs,
int attrsonly,
Entry *e_parent,
int sub,
......@@ -150,7 +150,7 @@ monitor_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......
......@@ -34,7 +34,7 @@ passwd_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......
......@@ -39,7 +39,7 @@ perl_back_search(
int timelimit,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......@@ -48,6 +48,7 @@ perl_back_search(
int err = 0;
char *matched = NULL, *info = NULL;
PerlBackend *perl_back = (PerlBackend *)be->be_private;
AttributeName *an;
Entry *e;
char *buf;
int i;
......@@ -65,8 +66,8 @@ perl_back_search(
XPUSHs(sv_2mortal(newSViv( timelimit )));
XPUSHs(sv_2mortal(newSViv( attrsonly )));
for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
XPUSHs(sv_2mortal(newSVpv( attrs[i]->bv_val , 0)));
for ( an = attrs; an; an = an->an_next ) {
XPUSHs(sv_2mortal(newSVpv( an->an_name.bv_val , 0)));
}
PUTBACK;
......
......@@ -33,14 +33,14 @@ shell_back_abandon(
if ( si->si_abandon == NULL ) {
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
pid = -1;
for ( o = conn->c_ops; o != NULL; o = o->o_next ) {
STAILQ_FOREACH( o, &conn->c_ops, o_next ) {
if ( o->o_msgid == msgid ) {
pid = (pid_t) o->o_private;
break;
}
}
if( pid == -1 ) {
for ( o = conn->c_pending_ops; o != NULL; o = o->o_next ) {
STAILQ_FOREACH( o, &conn->c_pending_ops, o_next ) {
if ( o->o_msgid == msgid ) {
pid = (pid_t) o->o_private;
break;
......
......@@ -23,7 +23,7 @@ read_and_send_results(
Connection *conn,
Operation *op,
FILE *fp,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
......
......@@ -28,13 +28,14 @@ shell_back_search(
int time,
Filter *filter,
const char *filterstr,
struct berval **attrs,
AttributeName *attrs,
int attrsonly
)
{
struct shellinfo *si = (struct shellinfo *) be->be_private;
int i;
FILE *rfp, *wfp;
AttributeName *an;
if ( si->si_search == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
......@@ -61,8 +62,8 @@ 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 ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
fprintf( wfp, " %s", attrs[i]->bv_val );
for ( an = attrs; an; an=an->an_next ) {
fprintf( wfp, " %s", an->an_name.bv_val );
}
fprintf( wfp, "\n" );
fclose( wfp );
......
......@@ -42,7 +42,7 @@ extern int read_and_send_results LDAP_P((
struct slap_conn *conn,
struct slap_op *op,
FILE *fp,
struct berval **attrs,
AttributeName *attrs,
int attrsonly));
LDAP_END_DECL
......
......@@ -46,9 +46,9 @@ int backsql_attrlist_add(backsql_srch_info *bsi,char *at_name)
void backsql_init_search(backsql_srch_info *bsi,backsql_info *bi,char *nbase,int scope,
int slimit,int tlimit,time_t stoptime,Filter *filter,
SQLHDBC dbh,BackendDB *be,Connection *conn,Operation *op,struct berval **attrs)
SQLHDBC dbh,BackendDB *be,Connection *conn,Operation *op,AttributeName *attrs)
{
struct berval **p;
AttributeName *p;
bsi->base_dn=nbase;
bsi->scope=scope;
bsi->slimit=slimit;
......@@ -62,11 +62,11 @@ void backsql_init_search(backsql_srch_info *bsi,backsql_info *bi,char *nbase,int
{
bsi->attrs=(char**)ch_calloc(1,sizeof(char*));
bsi->attrs[0]=NULL;
for(p=attrs;*p!=NULL;p++)
backsql_attrlist_add(bsi,(*p)->bv_val);
for(p=attrs;p!=NULL;p=p->an_next)
backsql_attrlist_add(bsi,p->an_name.bv_val);
}
else
bsi->attrs=attrs;
bsi->attrs=NULL;
bsi->abandon=0;
bsi->id_list=NULL;
bsi->stoptime=stoptime;
......@@ -518,7 +518,7 @@ SQL_SUCCESS)
int backsql_search(BackendDB *be,Connection *conn,Operation *op,
const char *base, const char *nbase, int scope,int deref,int slimit,int tlimit,
Filter *filter, const char *filterstr,struct berval **attrs,int attrsonly)
Filter *filter, const char *filterstr,AttributeName *attrs,int attrsonly)
{
backsql_info *bi=(backsql_info*)be->be_private;
SQLHDBC dbh;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment