Changed search attrs to struct berval **.

Use typedefs for all backend functions, to minimize work in future API
updates. (back-*/external.h will never need updating in the future.)
This commit is contained in:
Howard Chu 2001-12-26 08:17:44 +00:00
parent 65977a0f83
commit 68b1bbb89d
28 changed files with 328 additions and 360 deletions

View File

@ -210,12 +210,8 @@ parse_acl(
}
} else if ( strncasecmp( left, "attr", 4 ) == 0 ) {
char **alist;
alist = str2charray( right, "," );
charray_merge( &a->acl_attrs, alist );
charray_free( alist );
a->acl_attrs = str2bvec( a->acl_attrs,
right, "," );
} else {
fprintf( stderr,
"%s: line %d: expecting <what> got \"%s\"\n",
@ -1281,7 +1277,7 @@ acl_free( AccessControl *a )
if ( a->acl_dn_pat.bv_len )
free ( a->acl_dn_pat.bv_val );
if ( a->acl_attrs )
charray_free( a->acl_attrs );
ber_bvecfree( a->acl_attrs );
for (; a->acl_access; a->acl_access = n) {
n = a->acl_access->a_next;
access_free( a->acl_access );
@ -1494,7 +1490,7 @@ print_acl( Backend *be, AccessControl *a )
if ( ! first ) {
fprintf( stderr, "," );
}
fprintf( stderr, a->acl_attrs[i] );
fputs( a->acl_attrs[i]->bv_val, stderr );
first = 0;
}
fprintf( stderr, "\n" );

View File

@ -266,7 +266,7 @@ int is_ad_subtype(
int ad_inlist(
AttributeDescription *desc,
char **attrs )
struct berval **attrs )
{
int i;
for( i=0; attrs[i] != NULL; i++ ) {
@ -275,7 +275,7 @@ int ad_inlist(
const char *text;
int rc;
rc = slap_str2ad( attrs[i], &ad, &text );
rc = slap_bv2ad( attrs[i], &ad, &text );
if( rc == LDAP_SUCCESS ) {
rc = is_ad_subtype( desc, ad );
if( rc ) return 1;
@ -286,7 +286,7 @@ int ad_inlist(
* EXTENSION: see if requested description is an object class
* if so, return attributes which the class requires/allows
*/
oc = oc_find( attrs[i] );
oc = oc_bvfind( attrs[i] );
if( oc != NULL ) {
if ( oc == slap_schema.si_oc_extensibleObject ) {
/* extensibleObject allows the return of anything */

View File

@ -15,7 +15,7 @@
static struct exop {
char *oid;
SLAP_EXTENDED_FN extended;
BI_op_extended *extended;
} exop_table[] = {
{ LDAP_EXOP_X_MODIFY_PASSWD, bdb_exop_passwd },
{ NULL, NULL }

View File

@ -9,59 +9,29 @@
LDAP_BEGIN_DECL
extern int bdb_initialize LDAP_P(( BackendInfo *bi ));
extern BI_init bdb_initialize;
extern int bdb_db_config LDAP_P(( BackendDB *bd,
const char *fname, int lineno,
int argc, char **argv ));
extern BI_db_config bdb_db_config;
extern int bdb_add LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, Entry *e ));
extern BI_op_add bdb_add;
extern int bdb_bind LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, int method,
struct berval *cred, char** edn ));
extern BI_op_bind bdb_bind;
extern int bdb_compare LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
AttributeAssertion *ava ));
extern BI_op_compare bdb_compare;
extern int bdb_delete LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn ));
extern BI_op_delete bdb_delete;
extern int bdb_abandon LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, ber_int_t msgid ));
extern BI_op_abandon bdb_abandon;
extern int bdb_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, Modifications *ml ));
extern BI_op_modify bdb_modify;
extern int bdb_modrdn LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
const char* newrdn, int deleteoldrdn,
const char *newSuperior ));
extern BI_op_modrdn bdb_modrdn;
extern int bdb_search LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *base, const char *nbase,
int scope, int deref, int sizelimit, int timelimit,
Filter *filter, const char *filterstr,
char **attrs, int attrsonly ));
extern BI_op_search bdb_search;
extern int bdb_unbind LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op ));
extern BI_op_unbind bdb_unbind;
extern int bdb_referrals(
BackendDB *be,
Connection *conn,
Operation *op,
const char *dn,
const char *ndn,
const char **text );
extern BI_chk_referrals bdb_referrals;
LDAP_END_DECL

View File

@ -43,10 +43,7 @@ void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
* attribute.c
*/
int
bdb_attribute LDAP_P(( Backend *be, Connection *conn, Operation *op,
Entry *target, const char *entry_ndn, AttributeDescription *entry_at,
struct berval ***vals ));
BI_acl_attribute bdb_attribute;
/*
* dbcache.c
@ -107,7 +104,7 @@ bdb_dn2idl(
* entry.c
*/
int bdb_entry_return( BackendDB *be, Entry *e );
int bdb_entry_release( BackendDB *, Connection *, Operation *, Entry *, int );
BI_entry_release_rw bdb_entry_release;
/*
* error.c
@ -127,15 +124,7 @@ int bdb_filter_candidates(
* group.c
*/
int bdb_group(
Backend *be,
Connection *conn,
Operation *op,
Entry *target,
const char *gr_ndn,
const char *op_ndn,
ObjectClass *group_oc,
AttributeDescription *group_at);
BI_acl_group bdb_group;
/*
* id2entry
@ -286,28 +275,17 @@ int bdb_modify_internal(
/*
* passwd.c
*/
int
bdb_exop_passwd(
Backend *be,
Connection *conn,
Operation *op,
const char *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
LDAPControl *** rspctrls,
const char **text,
struct berval *** refs );
BI_op_extended bdb_exop_passwd;
/*
* tools.c
*/
int bdb_tool_entry_open( BackendDB *be, int mode );
int bdb_tool_entry_close( BackendDB *be );
ID bdb_tool_entry_next( BackendDB *be );
Entry* bdb_tool_entry_get( BackendDB *be, ID id );
ID bdb_tool_entry_put( BackendDB *be, Entry *e );
int bdb_tool_entry_reindex( BackendDB *be, ID id );
BI_tool_entry_open bdb_tool_entry_open;
BI_tool_entry_close bdb_tool_entry_close;
BI_tool_entry_next bdb_tool_entry_next;
BI_tool_entry_get bdb_tool_entry_get;
BI_tool_entry_put bdb_tool_entry_put;
BI_tool_entry_reindex bdb_tool_entry_reindex;
LDAP_END_DECL

View File

@ -40,7 +40,7 @@ bdb_search(
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;

View File

@ -30,7 +30,7 @@ dnssrv_back_search(
int time,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly )
{
int i;

View File

@ -9,74 +9,38 @@
LDAP_BEGIN_DECL
extern int ldap_back_initialize LDAP_P(( BackendInfo *bi ));
extern int ldap_back_open LDAP_P(( BackendInfo *bi ));
extern int ldap_back_close LDAP_P(( BackendInfo *bi ));
extern int ldap_back_destroy LDAP_P(( BackendInfo *bi ));
extern BI_init ldap_back_initialize;
extern BI_open ldap_back_open;
extern BI_close ldap_back_close;
extern BI_destroy ldap_back_destroy;
extern int ldap_back_db_init LDAP_P(( BackendDB *bd ));
extern int ldap_back_db_destroy LDAP_P(( BackendDB *bd ));
extern BI_db_init ldap_back_db_init;
extern BI_db_destroy ldap_back_db_destroy;
extern int ldap_back_db_config LDAP_P(( BackendDB *bd,
const char *fname, int lineno, int argc, char **argv ));
extern BI_db_config ldap_back_db_config;
extern int ldap_back_bind LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, int method,
struct berval *cred, char** edn ));
extern BI_op_bind ldap_back_bind;
extern int ldap_back_conn_destroy LDAP_P(( BackendDB *bd,
Connection *conn ));
extern BI_connection_destroy ldap_back_conn_destroy;
extern int ldap_back_search LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *base, const char *nbase,
int scope, int deref, int sizelimit, int timelimit,
Filter *filter, const char *filterstr,
char **attrs, int attrsonly ));
extern BI_op_search ldap_back_search;
extern int ldap_back_compare LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
AttributeAssertion *ava ));
extern BI_op_compare ldap_back_compare;
extern int ldap_back_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, Modifications *ml ));
extern BI_op_modify ldap_back_modify;
extern int ldap_back_modrdn LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
const char *newrdn, int deleteoldrdn,
const char *newSuperior ));
extern BI_op_modrdn ldap_back_modrdn;
extern int ldap_back_add LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, Entry *e ));
extern BI_op_add ldap_back_add;
extern int ldap_back_delete LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn ));
extern BI_op_delete ldap_back_delete;
extern int ldap_back_abandon LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, int msgid ));
extern BI_op_abandon ldap_back_abandon;
extern int ldap_back_group LDAP_P(( BackendDB *bd,
Connection *conn,
Operation *op,
Entry *target,
const char* gr_ndn,
const char* op_ndn,
ObjectClass* group_oc,
AttributeDescription* group_at));
extern BI_acl_group ldap_back_group;
extern int ldap_back_attribute LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
Entry *target,
const char* ndn,
AttributeDescription* entry_at,
struct berval ***vals));
extern BI_acl_attribute ldap_back_attribute;
LDAP_END_DECL
#endif /* _LDAP_EXTERNAL_H */

View File

@ -47,7 +47,7 @@
#include "back-ldap.h"
static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc,
LDAPMessage *e, char **attrs, int attrsonly );
LDAPMessage *e, struct berval **attrs, int attrsonly );
int
ldap_back_search(
@ -62,7 +62,7 @@ ldap_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{
@ -363,7 +363,7 @@ ldap_send_entry(
Operation *op,
struct ldapconn *lc,
LDAPMessage *e,
char **attrs,
struct berval **attrs,
int attrsonly
)
{

View File

@ -18,7 +18,7 @@
struct exop {
char *oid;
SLAP_EXTENDED_FN extended;
BI_op_extended *extended;
} exop_table[] = {
{ LDAP_EXOP_X_MODIFY_PASSWD, ldbm_back_exop_passwd },
{ NULL, NULL }

View File

@ -9,109 +9,57 @@
LDAP_BEGIN_DECL
extern int ldbm_back_initialize LDAP_P(( BackendInfo *bi ));
extern int ldbm_back_open LDAP_P(( BackendInfo *bi ));
extern int ldbm_back_close LDAP_P(( BackendInfo *bi ));
extern int ldbm_back_destroy LDAP_P(( BackendInfo *bi ));
extern BI_init ldbm_back_initialize;
extern BI_open ldbm_back_open;
extern BI_close ldbm_back_close;
extern BI_destroy ldbm_back_destroy;
extern int ldbm_back_db_init LDAP_P(( BackendDB *bd ));
extern int ldbm_back_db_open LDAP_P(( BackendDB *bd ));
extern int ldbm_back_db_close LDAP_P(( BackendDB *bd ));
extern int ldbm_back_db_destroy LDAP_P(( BackendDB *bd ));
extern BI_db_init ldbm_back_db_init;
extern BI_db_open ldbm_back_db_open;
extern BI_db_close ldbm_back_db_close;
extern BI_db_destroy ldbm_back_db_destroy;
extern int ldbm_back_db_config LDAP_P(( BackendDB *bd,
const char *fname, int lineno,
int argc, char **argv ));
extern BI_db_config ldbm_back_db_config;
extern int ldbm_back_extended LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *reqoid,
struct berval *reqdata,
char **rspoid,
struct berval **rspdata,
LDAPControl *** rspctrls,
const char **text,
struct berval *** refs ));
extern BI_op_extended ldbm_back_extended;
extern int ldbm_back_bind LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, int method,
struct berval *cred, char** edn ));
extern BI_op_bind ldbm_back_bind;
extern int ldbm_back_unbind LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op ));
extern BI_op_unbind ldbm_back_unbind;
extern int ldbm_back_search LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *base, const char *nbase,
int scope, int deref, int sizelimit, int timelimit,
Filter *filter, const char *filterstr,
char **attrs, int attrsonly ));
extern BI_op_search ldbm_back_search;
extern int ldbm_back_compare LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
AttributeAssertion *ava ));
extern BI_op_compare ldbm_back_compare;
extern int ldbm_back_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn, Modifications *ml ));
extern BI_op_modify ldbm_back_modify;
extern int ldbm_back_modrdn LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
const char* newrdn, int deleteoldrdn,
const char *newSuperior ));
extern BI_op_modrdn ldbm_back_modrdn;
extern int ldbm_back_add LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, Entry *e ));
extern BI_op_add ldbm_back_add;
extern int ldbm_back_delete LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn ));
extern BI_op_delete ldbm_back_delete;
extern int ldbm_back_abandon LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, ber_int_t msgid ));
extern BI_op_abandon ldbm_back_abandon;
extern int ldbm_back_group LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
Entry *target,
const char* gr_ndn,
const char* op_ndn,
ObjectClass* group_oc,
AttributeDescription* group_at));
extern BI_acl_group ldbm_back_group;
extern int ldbm_back_attribute LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
Entry *target,
const char* entry_ndn,
AttributeDescription* entry_at,
struct berval ***vals));
extern BI_acl_attribute ldbm_back_attribute;
extern int ldbm_back_operational LDAP_P((BackendDB *bd,
Connection *conn, Operation *op,
Entry *e,
char **attrs,
int opattrs,
Attribute **a ));
extern BI_operational ldbm_back_operational;
/* hooks for slap tools */
extern int ldbm_tool_entry_open LDAP_P(( BackendDB *be, int mode ));
extern int ldbm_tool_entry_close LDAP_P(( BackendDB *be ));
extern ID ldbm_tool_entry_first LDAP_P(( BackendDB *be ));
extern ID ldbm_tool_entry_next LDAP_P(( BackendDB *be ));
extern Entry* ldbm_tool_entry_get LDAP_P(( BackendDB *be, ID id ));
extern ID ldbm_tool_entry_put LDAP_P(( BackendDB *be, Entry *e ));
extern BI_tool_entry_open ldbm_tool_entry_open;
extern BI_tool_entry_close ldbm_tool_entry_close;
extern BI_tool_entry_first ldbm_tool_entry_first;
extern BI_tool_entry_next ldbm_tool_entry_next;
extern BI_tool_entry_get ldbm_tool_entry_get;
extern BI_tool_entry_put ldbm_tool_entry_put;
extern int ldbm_tool_entry_reindex LDAP_P(( BackendDB *be, ID id ));
extern int ldbm_tool_sync LDAP_P(( BackendDB *be ));
extern BI_tool_entry_reindex ldbm_tool_entry_reindex;
extern BI_tool_sync ldbm_tool_sync;
extern int ldbm_back_referrals LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
const char *dn, const char *ndn,
const char **text ));
extern BI_chk_referrals ldbm_back_referrals;
LDAP_END_DECL
#endif /* _LDBM_EXTERNAL_H */

View File

@ -25,7 +25,7 @@ ldbm_back_operational(
Connection *conn,
Operation *op,
Entry *e,
char **attrs,
struct berval **attrs,
int opattrs,
Attribute **a )
{

View File

@ -37,7 +37,7 @@ ldbm_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;

View File

@ -84,7 +84,7 @@ meta_send_entry(
struct metaconn *lc,
int i,
LDAPMessage *e,
char **attrs,
struct berval **attrs,
int attrsonly
);
@ -107,7 +107,7 @@ meta_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{
@ -569,7 +569,7 @@ meta_send_entry(
struct metaconn *lc,
int target,
LDAPMessage *e,
char **attrs,
struct berval **attrs,
int attrsonly
)
{

View File

@ -51,7 +51,7 @@ monitor_send_children(
Connection *conn,
Operation *op,
Filter *filter,
char **attrs,
struct berval **attrs,
int attrsonly,
Entry *e_parent,
int sub,
@ -149,7 +149,7 @@ monitor_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{

View File

@ -34,7 +34,7 @@ passwd_back_search(
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{

View File

@ -39,7 +39,7 @@ perl_back_search(
int timelimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{
@ -66,7 +66,7 @@ perl_back_search(
XPUSHs(sv_2mortal(newSViv( attrsonly )));
for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
XPUSHs(sv_2mortal(newSVpv( attrs[i] , 0)));
XPUSHs(sv_2mortal(newSVpv( attrs[i]->bv_val , 0)));
}
PUTBACK;

View File

@ -28,7 +28,7 @@ shell_back_search(
int time,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{
@ -62,7 +62,7 @@ shell_back_search(
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] );
fprintf( wfp, " %s", attrs[i]->bv_val );
}
fprintf( wfp, "\n" );
fclose( wfp );

View File

@ -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,char **attrs)
SQLHDBC dbh,BackendDB *be,Connection *conn,Operation *op,struct berval **attrs)
{
char **p;
struct berval **p;
bsi->base_dn=nbase;
bsi->scope=scope;
bsi->slimit=slimit;
@ -63,7 +63,7 @@ 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);
backsql_attrlist_add(bsi,(*p)->bv_val);
}
else
bsi->attrs=attrs;
@ -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,char **attrs,int attrsonly)
Filter *filter, const char *filterstr,struct berval **attrs,int attrsonly)
{
backsql_info *bi=(backsql_info*)be->be_private;
SQLHDBC dbh;

View File

@ -1086,7 +1086,7 @@ Attribute *backend_operational(
Connection *conn,
Operation *op,
Entry *e,
char **attrs,
struct berval **attrs,
int opattrs )
{
Attribute *a = NULL, **ap = &a;

View File

@ -260,7 +260,7 @@ glue_back_search (
int tlimit,
Filter *filter,
const char *filterstr,
char **attrs,
struct berval **attrs,
int attrsonly
)
{

View File

@ -124,6 +124,26 @@ charray_inlist(
return( 0 );
}
int
bvec_inlist(
struct berval **a,
struct berval *s
)
{
int i;
if( a == NULL ) return 0;
for ( i = 0; a[i] != NULL; i++ ) {
if ( a[i]->bv_len != s->bv_len) continue;
if ( strcasecmp( s->bv_val, a[i]->bv_val ) == 0 ) {
return( 1 );
}
}
return( 0 );
}
char **
charray_dup( char **a )
{
@ -179,6 +199,52 @@ str2charray( const char *str_in, const char *brkstr )
return( res );
}
/* Convert a delimited string into an array of bervals; Add on
* to an existing array if it was given.
*/
struct berval **
str2bvec( struct berval **vec, const char *in, const char *brkstr )
{
char *str;
struct berval **res;
char *s;
char *lasts;
int i, old;
/* protect the input string from strtok */
str = ch_strdup( in );
for (old = 0; vec && vec[old]; old++);
i = 1;
for ( s = str; *s; s++ ) {
if ( strchr( brkstr, *s ) != NULL ) {
i++;
}
}
if (vec) {
res = (struct berval **) ch_realloc( vec, (old + i + 1) * sizeof(struct berval *) );
vec = res + old;
} else {
res = (struct berval **) ch_malloc( (i + 1) * sizeof(struct berval *) );
vec = res;
}
i = 0;
for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
s != NULL;
s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
{
vec[i++] = ber_bvstrdup( s );
}
vec[i] = NULL;
free( str );
return( res );
}
int
charray_strcmp( const char **a1, const char **a2 )

View File

@ -37,7 +37,7 @@ LDAP_SLAPD_F (int) is_ad_subtype LDAP_P((
LDAP_SLAPD_F (int) ad_inlist LDAP_P((
AttributeDescription *desc,
char **attrs ));
struct berval **attrs ));
LDAP_SLAPD_F (int) slap_str2undef_ad LDAP_P((
const char *,
@ -225,7 +225,7 @@ LDAP_SLAPD_F (Attribute *) backend_operational(
Connection *conn,
Operation *op,
Entry *e,
char **attrs,
struct berval **attrs,
int opattrs );
@ -271,6 +271,7 @@ LDAP_SLAPD_F (void) charray_free LDAP_P(( char **array ));
LDAP_SLAPD_F (int) charray_inlist LDAP_P(( char **a, const char *s ));
LDAP_SLAPD_F (char **) charray_dup LDAP_P(( char **a ));
LDAP_SLAPD_F (char **) str2charray LDAP_P(( const char *str, const char *brkstr ));
LDAP_SLAPD_F (struct berval **) str2bvec LDAP_P(( struct berval **vec, const char *str, const char *brkstr ));
LDAP_SLAPD_F (int) charray_strcmp LDAP_P(( const char **a1, const char **a2 ));
LDAP_SLAPD_F (int) charray_strcasecmp LDAP_P(( const char **a1, const char **a2 ));
@ -635,7 +636,7 @@ LDAP_SLAPD_F (int) send_search_reference LDAP_P((
LDAP_SLAPD_F (int) send_search_entry LDAP_P((
Backend *be, Connection *conn, Operation *op,
Entry *e, char **attrs, int attrsonly,
Entry *e, struct berval **attrs, int attrsonly,
LDAPControl **ctrls ));
LDAP_SLAPD_F (int) str2result LDAP_P(( char *s,

View File

@ -618,6 +618,10 @@ send_search_result(
}
}
static struct berval AllUser = { sizeof(LDAP_ALL_USER_ATTRIBUTES)-1,
LDAP_ALL_USER_ATTRIBUTES };
static struct berval AllOper = { sizeof(LDAP_ALL_OPERATIONAL_ATTRIBUTES)-1,
LDAP_ALL_OPERATIONAL_ATTRIBUTES };
int
send_search_entry(
@ -625,7 +629,7 @@ send_search_entry(
Connection *conn,
Operation *op,
Entry *e,
char **attrs,
struct berval **attrs,
int attrsonly,
LDAPControl **ctrls
)
@ -701,13 +705,13 @@ send_search_entry(
}
}
if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
rc = ber_printf( ber, "{is{t{s{" /*}}}*/,
op->o_msgid, "", LDAP_RES_SEARCH_ENTRY, e->e_dn );
rc = ber_printf( ber, "{is{t{O{" /*}}}*/,
op->o_msgid, "", LDAP_RES_SEARCH_ENTRY, &e->e_name );
} else
#endif
{
rc = ber_printf( ber, "{it{s{" /*}}}*/, op->o_msgid,
LDAP_RES_SEARCH_ENTRY, e->e_dn );
rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
LDAP_RES_SEARCH_ENTRY, &e->e_name );
}
if ( rc == -1 ) {
@ -727,24 +731,23 @@ send_search_entry(
/* check for special all user attributes ("*") type */
userattrs = ( attrs == NULL ) ? 1
: charray_inlist( attrs, LDAP_ALL_USER_ATTRIBUTES );
: bvec_inlist( attrs, &AllUser );
/* check for special all operational attributes ("+") type */
opattrs = ( attrs == NULL ) ? 0
: charray_inlist( attrs, LDAP_ALL_OPERATIONAL_ATTRIBUTES );
: bvec_inlist( attrs, &AllOper );
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
AttributeDescription *desc = a->a_desc;
char *type = desc->ad_cname.bv_val;
if ( attrs == NULL ) {
/* all addrs request, skip operational attributes */
/* all attrs request, skip operational attributes */
if( is_at_operational( desc->ad_type ) ) {
continue;
}
} else {
/* specific addrs requested */
/* specific attrs requested */
if ( is_at_operational( desc->ad_type ) ) {
if( !opattrs && !ad_inlist( desc, attrs ) ) {
continue;
@ -770,7 +773,7 @@ send_search_entry(
continue;
}
if (( rc = ber_printf( ber, "{s[" /*]}*/ , type )) == -1 ) {
if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
"send_search_entry: conn %d ber_printf failed\n",
@ -845,13 +848,13 @@ send_search_entry(
AttributeDescription *desc = a->a_desc;
if ( attrs == NULL ) {
/* all addrs request, skip operational attributes */
/* all attrs request, skip operational attributes */
if( is_at_operational( desc->ad_type ) ) {
continue;
}
} else {
/* specific addrs requested */
/* specific attrs requested */
if( is_at_operational( desc->ad_type ) ) {
if( !opattrs && !ad_inlist( desc, attrs ) ) {
continue;
@ -877,7 +880,7 @@ send_search_entry(
continue;
}
rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname.bv_val );
rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname );
if ( rc == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,

View File

@ -65,29 +65,28 @@ schema_info( Entry **entry, const char **text )
{
int rc;
AttributeDescription *desc = NULL;
char *rdn = ch_strdup( SLAPD_SCHEMA_DN );
val.bv_val = strchr( rdn, '=' );
struct berval rdn = { sizeof(SLAPD_SCHEMA_DN)-1,
SLAPD_SCHEMA_DN };
val.bv_val = strchr( rdn.bv_val, '=' );
if( val.bv_val == NULL ) {
free( rdn );
*text = "improperly configured subschema subentry";
return LDAP_OTHER;
}
*val.bv_val = '\0';
val.bv_len = strlen( ++val.bv_val );
val.bv_val++;
val.bv_len = rdn.bv_len - (val.bv_val - rdn.bv_val);
rdn.bv_len -= val.bv_len + 1;
rc = slap_str2ad( rdn, &desc, text );
rc = slap_bv2ad( &rdn, &desc, text );
if( rc != LDAP_SUCCESS ) {
free( rdn );
entry_free( e );
*text = "improperly configured subschema subentry";
return LDAP_OTHER;
}
attr_merge( e, desc, vals );
free( rdn );
}
if ( syn_schema_info( e )

View File

@ -38,7 +38,7 @@ do_search(
struct berval *nbase = NULL;
char *fstr = NULL;
Filter *filter = NULL;
char **attrs = NULL;
struct berval **attrs = NULL;
Backend *be;
int rc;
const char *text;
@ -172,7 +172,7 @@ do_search(
/* attributes */
if ( ber_scanf( op->o_ber, /*{*/ "{v}}", &attrs ) == LBER_ERROR ) {
if ( ber_scanf( op->o_ber, /*{*/ "{V}}", &attrs ) == LBER_ERROR ) {
send_ldap_disconnect( conn, op,
LDAP_PROTOCOL_ERROR, "decoding attrs error" );
rc = SLAPD_DISCONNECT;
@ -205,9 +205,9 @@ do_search(
for ( i = 0; attrs[i] != NULL; i++ ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
"do_search: %s", attrs[i] ));
"do_search: %s", attrs[i]->bv_val ));
#else
Debug( LDAP_DEBUG_ARGS, " %s", attrs[i], 0, 0 );
Debug( LDAP_DEBUG_ARGS, " %s", attrs[i]->bv_val, 0, 0 );
#endif
}
@ -343,7 +343,7 @@ return_results:;
if( fstr != NULL) free( fstr );
if( filter != NULL) filter_free( filter );
if ( attrs != NULL ) {
charray_free( attrs );
ber_bvecfree( attrs );
}
return rc;

View File

@ -823,7 +823,7 @@ typedef struct slap_acl {
slap_style_t acl_dn_style;
regex_t acl_dn_re;
struct berval acl_dn_pat;
char **acl_attrs;
struct berval **acl_attrs;
/* "by" part: list of who has what access to the entries */
Access *acl_access;
@ -1016,7 +1016,57 @@ struct slap_backend_db {
struct slap_conn;
struct slap_op;
typedef int (*SLAP_EXTENDED_FN) LDAP_P((
/* Backend function typedefs */
typedef int (BI_init) LDAP_P((BackendInfo *bi));
typedef int (BI_config) LDAP_P((BackendInfo *bi, const char *fname,
int lineno, int argc, char **argv));
typedef int (BI_open) LDAP_P((BackendInfo *bi));
typedef int (BI_close) LDAP_P((BackendInfo *bi));
typedef int (BI_destroy) LDAP_P((BackendInfo *bi));
typedef int (BI_db_init) LDAP_P((Backend *bd));
typedef int (BI_db_config) LDAP_P((Backend *bd, const char *fname,
int lineno, int argc, char **argv));
typedef int (BI_db_open) LDAP_P((Backend *bd));
typedef int (BI_db_close) LDAP_P((Backend *bd));
typedef int (BI_db_destroy) LDAP_P((Backend *bd));
typedef int (BI_op_bind) LDAP_P(( BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn, int method,
struct berval *cred, char** edn ));
typedef int (BI_op_unbind) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o ));
typedef int (BI_op_search) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *base, const char *nbase,
int scope, int deref,
int slimit, int tlimit,
Filter *f, const char *filterstr,
struct berval **attrs, int attrsonly));
typedef int (BI_op_compare)LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
AttributeAssertion *ava));
typedef int (BI_op_modify) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn, Modifications *m));
typedef int (BI_op_modrdn) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
const char *newrdn, int deleteoldrdn,
const char *newSuperior));
typedef int (BI_op_add) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e));
typedef int (BI_op_delete) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn));
typedef int (BI_op_abandon) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
ber_int_t msgid));
typedef int (BI_op_extended) LDAP_P((
BackendDB *be,
struct slap_conn *conn,
struct slap_op *op,
@ -1028,6 +1078,44 @@ typedef int (*SLAP_EXTENDED_FN) LDAP_P((
const char ** text,
struct berval *** refs ));
typedef int (BI_entry_release_rw) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, int rw));
typedef int (BI_chk_referrals) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
const char **text ));
typedef int (BI_acl_group) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, const char *bdn, const char *edn,
ObjectClass *group_oc,
AttributeDescription *group_at ));
typedef int (BI_acl_attribute) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, const char *edn,
AttributeDescription *entry_at,
struct berval ***vals ));
typedef int (BI_operational) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, struct berval **attrs, int opattrs, Attribute **a ));
typedef int (BI_connection_init) LDAP_P((BackendDB *bd,
struct slap_conn *c));
typedef int (BI_connection_destroy) LDAP_P((BackendDB *bd,
struct slap_conn *c));
typedef int (BI_tool_entry_open) LDAP_P(( BackendDB *be, int mode ));
typedef int (BI_tool_entry_close) LDAP_P(( BackendDB *be ));
typedef ID (BI_tool_entry_first) LDAP_P(( BackendDB *be ));
typedef ID (BI_tool_entry_next) LDAP_P(( BackendDB *be ));
typedef Entry* (BI_tool_entry_get) LDAP_P(( BackendDB *be, ID id ));
typedef ID (BI_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e ));
typedef int (BI_tool_entry_reindex) LDAP_P(( BackendDB *be, ID id ));
typedef int (BI_tool_sync) LDAP_P(( BackendDB *be ));
struct slap_backend_info {
char *bi_type; /* type of backend */
@ -1051,12 +1139,11 @@ struct slap_backend_info {
* once during shutdown after all bi_db_destroy calls.
* bi_destory() is called from backend_destroy()
*/
int (*bi_init) LDAP_P((BackendInfo *bi));
int (*bi_config) LDAP_P((BackendInfo *bi,
const char *fname, int lineno, int argc, char **argv ));
int (*bi_open) LDAP_P((BackendInfo *bi));
int (*bi_close) LDAP_P((BackendInfo *bi));
int (*bi_destroy) LDAP_P((BackendInfo *bi));
BI_init *bi_init;
BI_config *bi_config;
BI_open *bi_open;
BI_close *bi_close;
BI_destroy *bi_destroy;
/*
* per database routines:
@ -1079,91 +1166,47 @@ struct slap_backend_info {
* bi_close calls but before bi_destory calls.
* called only by backend_destory()
*/
int (*bi_db_init) LDAP_P((Backend *bd));
int (*bi_db_config) LDAP_P((Backend *bd,
const char *fname, int lineno, int argc, char **argv ));
int (*bi_db_open) LDAP_P((Backend *bd));
int (*bi_db_close) LDAP_P((Backend *bd));
int (*bi_db_destroy) LDAP_P((Backend *db));
BI_db_init *bi_db_init;
BI_db_config *bi_db_config;
BI_db_open *bi_db_open;
BI_db_close *bi_db_close;
BI_db_destroy *bi_db_destroy;
/* LDAP Operations Handling Routines */
int (*bi_op_bind) LDAP_P(( BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn, int method,
struct berval *cred, char** edn ));
int (*bi_op_unbind) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o ));
int (*bi_op_search) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *base, const char *nbase,
int scope, int deref,
int slimit, int tlimit,
Filter *f, const char *filterstr,
char **attrs, int attrsonly));
int (*bi_op_compare)LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
AttributeAssertion *ava));
int (*bi_op_modify) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn, Modifications *m));
int (*bi_op_modrdn) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
const char *newrdn, int deleteoldrdn,
const char *newSuperior));
int (*bi_op_add) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e));
int (*bi_op_delete) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn));
int (*bi_op_abandon) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
ber_int_t msgid));
BI_op_bind *bi_op_bind;
BI_op_unbind *bi_op_unbind;
BI_op_search *bi_op_search;
BI_op_compare *bi_op_compare;
BI_op_modify *bi_op_modify;
BI_op_modrdn *bi_op_modrdn;
BI_op_add *bi_op_add;
BI_op_delete *bi_op_delete;
BI_op_abandon *bi_op_abandon;
/* Extended Operations Helper */
SLAP_EXTENDED_FN bi_extended;
BI_op_extended *bi_extended;
/* Auxilary Functions */
int (*bi_entry_release_rw) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, int rw));
BI_entry_release_rw *bi_entry_release_rw;
BI_chk_referrals *bi_chk_referrals;
int (*bi_chk_referrals) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
const char *dn, const char *ndn,
const char **text ));
BI_acl_group *bi_acl_group;
BI_acl_attribute *bi_acl_attribute;
int (*bi_acl_group) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, const char *bdn, const char *edn,
ObjectClass *group_oc,
AttributeDescription *group_at ));
int (*bi_acl_attribute) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, const char *edn,
AttributeDescription *entry_at,
struct berval ***vals ));
BI_operational *bi_operational;
int (*bi_operational) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
Entry *e, char **attrs, int opattrs, Attribute **a ));
int (*bi_connection_init) LDAP_P((BackendDB *bd,
struct slap_conn *c));
int (*bi_connection_destroy) LDAP_P((BackendDB *bd,
struct slap_conn *c));
BI_connection_init *bi_connection_init;
BI_connection_destroy *bi_connection_destroy;
/* hooks for slap tools */
int (*bi_tool_entry_open) LDAP_P(( BackendDB *be, int mode ));
int (*bi_tool_entry_close) LDAP_P(( BackendDB *be ));
ID (*bi_tool_entry_first) LDAP_P(( BackendDB *be ));
ID (*bi_tool_entry_next) LDAP_P(( BackendDB *be ));
Entry* (*bi_tool_entry_get) LDAP_P(( BackendDB *be, ID id ));
ID (*bi_tool_entry_put) LDAP_P(( BackendDB *be, Entry *e ));
int (*bi_tool_entry_reindex) LDAP_P(( BackendDB *be, ID id ));
int (*bi_tool_sync) LDAP_P(( BackendDB *be ));
BI_tool_entry_open *bi_tool_entry_open;
BI_tool_entry_close *bi_tool_entry_close;
BI_tool_entry_first *bi_tool_entry_first;
BI_tool_entry_next *bi_tool_entry_next;
BI_tool_entry_get *bi_tool_entry_get;
BI_tool_entry_put *bi_tool_entry_put;
BI_tool_entry_reindex *bi_tool_entry_reindex;
BI_tool_sync *bi_tool_sync;
#define SLAP_INDEX_ADD_OP 0x0001
#define SLAP_INDEX_DELETE_OP 0x0002

View File

@ -108,7 +108,7 @@ send_search_entry(
Connection *conn,
Operation *op,
Entry *e,
char **attrs,
struct berval **attrs,
int attrsonly,
LDAPControl **ctrls
)