}
} 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",
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 );
if ( ! first ) {
fprintf( stderr, "," );
}
- fprintf( stderr, a->acl_attrs[i] );
+ fputs( a->acl_attrs[i]->bv_val, stderr );
first = 0;
}
fprintf( stderr, "\n" );
int ad_inlist(
AttributeDescription *desc,
- char **attrs )
+ struct berval **attrs )
{
int i;
for( i=0; attrs[i] != NULL; i++ ) {
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;
* 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 */
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 }
LDAP_BEGIN_DECL
-extern int bdb_initialize LDAP_P(( BackendInfo *bi ));
-
-extern int bdb_db_config LDAP_P(( BackendDB *bd,
- const char *fname, int lineno,
- int argc, char **argv ));
-
-extern int bdb_add LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, Entry *e ));
-
-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 int bdb_compare LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn,
- AttributeAssertion *ava ));
-
-extern int bdb_delete LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn ));
-
-extern int bdb_abandon LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, ber_int_t msgid ));
-
-extern int bdb_modify LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn, Modifications *ml ));
-
-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 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 int bdb_unbind LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op ));
-
-extern int bdb_referrals(
- BackendDB *be,
- Connection *conn,
- Operation *op,
- const char *dn,
- const char *ndn,
- const char **text );
+extern BI_init bdb_initialize;
+
+extern BI_db_config bdb_db_config;
+
+extern BI_op_add bdb_add;
+
+extern BI_op_bind bdb_bind;
+
+extern BI_op_compare bdb_compare;
+
+extern BI_op_delete bdb_delete;
+
+extern BI_op_abandon bdb_abandon;
+
+extern BI_op_modify bdb_modify;
+
+extern BI_op_modrdn bdb_modrdn;
+
+extern BI_op_search bdb_search;
+
+extern BI_op_unbind bdb_unbind;
+
+extern BI_chk_referrals bdb_referrals;
LDAP_END_DECL
* 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
* 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
* 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
/*
* 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
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int time,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly )
{
int i;
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 int ldap_back_db_init LDAP_P(( BackendDB *bd ));
-extern int ldap_back_db_destroy LDAP_P(( BackendDB *bd ));
-
-extern int ldap_back_db_config LDAP_P(( BackendDB *bd,
- const char *fname, int lineno, int argc, char **argv ));
-
-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 int ldap_back_conn_destroy LDAP_P(( BackendDB *bd,
- Connection *conn ));
-
-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 int ldap_back_compare LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn,
- AttributeAssertion *ava ));
-
-extern int ldap_back_modify LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn, Modifications *ml ));
-
-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 int ldap_back_add LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, Entry *e ));
-
-extern int ldap_back_delete LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn ));
-
-extern int ldap_back_abandon LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, int msgid ));
-
-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 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_init ldap_back_initialize;
+extern BI_open ldap_back_open;
+extern BI_close ldap_back_close;
+extern BI_destroy ldap_back_destroy;
+
+extern BI_db_init ldap_back_db_init;
+extern BI_db_destroy ldap_back_db_destroy;
+
+extern BI_db_config ldap_back_db_config;
+
+extern BI_op_bind ldap_back_bind;
+
+extern BI_connection_destroy ldap_back_conn_destroy;
+
+extern BI_op_search ldap_back_search;
+
+extern BI_op_compare ldap_back_compare;
+
+extern BI_op_modify ldap_back_modify;
+
+extern BI_op_modrdn ldap_back_modrdn;
+
+extern BI_op_add ldap_back_add;
+
+extern BI_op_delete ldap_back_delete;
+
+extern BI_op_abandon ldap_back_abandon;
+
+extern BI_acl_group ldap_back_group;
+
+extern BI_acl_attribute ldap_back_attribute;
LDAP_END_DECL
#endif /* _LDAP_EXTERNAL_H */
-
#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(
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
Operation *op,
struct ldapconn *lc,
LDAPMessage *e,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
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 }
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 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 int ldbm_back_db_config LDAP_P(( BackendDB *bd,
- const char *fname, int lineno,
- int argc, char **argv ));
-
-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 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 int ldbm_back_unbind LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op ));
-
-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 int ldbm_back_compare LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn,
- AttributeAssertion *ava ));
-
-extern int ldbm_back_modify LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn, Modifications *ml ));
-
-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 int ldbm_back_add LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, Entry *e ));
-
-extern int ldbm_back_delete LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *dn, const char *ndn ));
-
-extern int ldbm_back_abandon LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op, ber_int_t msgid ));
-
-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 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 int ldbm_back_operational LDAP_P((BackendDB *bd,
- Connection *conn, Operation *op,
- Entry *e,
- char **attrs,
- int opattrs,
- Attribute **a ));
+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 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 BI_db_config ldbm_back_db_config;
+
+extern BI_op_extended ldbm_back_extended;
+
+extern BI_op_bind ldbm_back_bind;
+
+extern BI_op_unbind ldbm_back_unbind;
+
+extern BI_op_search ldbm_back_search;
+
+extern BI_op_compare ldbm_back_compare;
+
+extern BI_op_modify ldbm_back_modify;
+
+extern BI_op_modrdn ldbm_back_modrdn;
+
+extern BI_op_add ldbm_back_add;
+
+extern BI_op_delete ldbm_back_delete;
+
+extern BI_op_abandon ldbm_back_abandon;
+
+extern BI_acl_group ldbm_back_group;
+
+extern BI_acl_attribute ldbm_back_attribute;
+
+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 */
-
Connection *conn,
Operation *op,
Entry *e,
- char **attrs,
+ struct berval **attrs,
int opattrs,
Attribute **a )
{
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
struct metaconn *lc,
int i,
LDAPMessage *e,
- char **attrs,
+ struct berval **attrs,
int attrsonly
);
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
struct metaconn *lc,
int target,
LDAPMessage *e,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
Connection *conn,
Operation *op,
Filter *filter,
- char **attrs,
+ struct berval **attrs,
int attrsonly,
Entry *e_parent,
int sub,
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
int timelimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
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;
int time,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
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 );
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;
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;
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;
Connection *conn,
Operation *op,
Entry *e,
- char **attrs,
+ struct berval **attrs,
int opattrs )
{
Attribute *a = NULL, **ap = &a;
int tlimit,
Filter *filter,
const char *filterstr,
- char **attrs,
+ struct berval **attrs,
int attrsonly
)
{
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 )
{
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 )
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 *,
Connection *conn,
Operation *op,
Entry *e,
- char **attrs,
+ struct berval **attrs,
int opattrs );
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 ));
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,
}
}
+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(
Connection *conn,
Operation *op,
Entry *e,
- char **attrs,
+ struct berval **attrs,
int attrsonly,
LDAPControl **ctrls
)
}
}
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 ) {
/* 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;
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",
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;
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,
{
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 )
struct berval *nbase = NULL;
char *fstr = NULL;
Filter *filter = NULL;
- char **attrs = NULL;
+ struct berval **attrs = NULL;
Backend *be;
int rc;
const char *text;
/* 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;
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
}
if( fstr != NULL) free( fstr );
if( filter != NULL) filter_free( filter );
if ( attrs != NULL ) {
- charray_free( attrs );
+ ber_bvecfree( attrs );
}
return rc;
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;
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,
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 */
* 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:
* 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));
-
- 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_entry_release_rw *bi_entry_release_rw;
+ BI_chk_referrals *bi_chk_referrals;
- 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_acl_group *bi_acl_group;
+ BI_acl_attribute *bi_acl_attribute;
- int (*bi_operational) LDAP_P((Backend *bd,
- struct slap_conn *c, struct slap_op *o,
- Entry *e, char **attrs, int opattrs, Attribute **a ));
+ BI_operational *bi_operational;
- 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
Connection *conn,
Operation *op,
Entry *e,
- char **attrs,
+ struct berval **attrs,
int attrsonly,
LDAPControl **ctrls
)