mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-08 08:02:16 -05:00
make unregistered known controls show up as undefined; move LDAPsync cid to frontend; some cleanup
This commit is contained in:
parent
8d0cd119ab
commit
6f182a7547
6 changed files with 45 additions and 31 deletions
|
|
@ -47,11 +47,6 @@ sql_back_initialize(
|
|||
|
||||
Debug( LDAP_DEBUG_TRACE,"==>sql_back_initialize()\n", 0, 0, 0 );
|
||||
|
||||
bi->bi_open = 0;
|
||||
bi->bi_config = 0;
|
||||
bi->bi_close = 0;
|
||||
bi->bi_destroy = 0;
|
||||
|
||||
bi->bi_db_init = backsql_db_init;
|
||||
bi->bi_db_config = backsql_db_config;
|
||||
bi->bi_db_open = backsql_db_open;
|
||||
|
|
@ -78,7 +73,6 @@ sql_back_initialize(
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
backsql_destroy(
|
||||
BackendInfo *bi )
|
||||
|
|
|
|||
|
|
@ -676,14 +676,12 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
|
|||
* TODO: introduce appropriate entryCSN filtering
|
||||
* to support syncrepl as producer...
|
||||
*/
|
||||
#if 0 /* wait until syncprov.c freezes */
|
||||
if ( bsi->bsi_op->o_sync_mode & SLAP_SYNC_PERSIST ) {
|
||||
if ( bsi->bsi_op->o_sync ) {
|
||||
/* unsupported at present... */
|
||||
bsi->bsi_status = LDAP_OTHER;
|
||||
rc = -1;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} else if ( ad == slap_schema.si_ad_hasSubordinates || ad == NULL ) {
|
||||
|
|
|
|||
|
|
@ -74,8 +74,19 @@ static LDAP_SLIST_HEAD(ControlsList, slap_control) controls_list
|
|||
/*
|
||||
* all known request control OIDs should be added to this list
|
||||
*/
|
||||
/*
|
||||
* NOTE: initialize num_known_controls to 1 so that cid = 0 always
|
||||
* addresses an undefined control; this allows to safely test for
|
||||
* well known controls even if they are not registered, e.g. if
|
||||
* they get moved to modules. An example is sc_LDAPsync, which
|
||||
* is implemented in the syncprov overlay and thus, if configured
|
||||
* as dynamic module, may not be registered. One side effect is that
|
||||
* slap_known_controls[0] == NULL, so it should always be used
|
||||
* starting from 1.
|
||||
* FIXME: should we define the "undefined control" oid?
|
||||
*/
|
||||
char *slap_known_controls[SLAP_MAX_CIDS+1];
|
||||
static int num_known_controls;
|
||||
static int num_known_controls = 1;
|
||||
|
||||
static char *proxy_authz_extops[] = {
|
||||
LDAP_EXOP_MODIFY_PASSWD,
|
||||
|
|
@ -169,6 +180,7 @@ register_supported_control(const char *controloid,
|
|||
int *controlcid)
|
||||
{
|
||||
struct slap_control *sc;
|
||||
int i;
|
||||
|
||||
if ( num_known_controls >= SLAP_MAX_CIDS ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Too many controls registered."
|
||||
|
|
@ -179,6 +191,16 @@ register_supported_control(const char *controloid,
|
|||
|
||||
if ( controloid == NULL ) return LDAP_PARAM_ERROR;
|
||||
|
||||
/* sanity check - should never happen */
|
||||
for ( i = 1; slap_known_controls[ i ]; i++ ) {
|
||||
if ( strcmp( controloid, slap_known_controls[ i ] ) == 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"Control %s already registered.\n",
|
||||
controloid, 0, 0 );
|
||||
return LDAP_PARAM_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
sc = (struct slap_control *)SLAP_MALLOC( sizeof( *sc ) );
|
||||
if ( sc == NULL ) return LDAP_NO_MEMORY;
|
||||
|
||||
|
|
@ -353,7 +375,7 @@ slap_find_control_id(
|
|||
const char *oid,
|
||||
int *cid )
|
||||
{
|
||||
slap_control *ctrl = find_ctrl( oid );
|
||||
struct slap_control *ctrl = find_ctrl( oid );
|
||||
if ( ctrl ) {
|
||||
if ( cid ) *cid = ctrl->sc_cid;
|
||||
return LDAP_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -65,17 +65,17 @@ typedef struct syncops {
|
|||
ldap_pvt_thread_mutex_t s_mutex;
|
||||
} syncops;
|
||||
|
||||
static int sync_cid;
|
||||
|
||||
/* A received sync control */
|
||||
typedef struct sync_control {
|
||||
struct sync_cookie sr_state;
|
||||
int sr_rhint;
|
||||
} sync_control;
|
||||
|
||||
#if 0 /* moved back to slap.h */
|
||||
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
|
||||
#endif
|
||||
/* o_sync_mode uses data bits of o_sync */
|
||||
#define o_sync o_ctrlflag[sync_cid]
|
||||
#define o_sync_mode o_ctrlflag[sync_cid]
|
||||
#define o_sync_mode o_ctrlflag[slap_cids.sc_LDAPsync]
|
||||
|
||||
#define SLAP_SYNC_NONE (LDAP_SYNC_NONE<<SLAP_CONTROL_SHIFT)
|
||||
#define SLAP_SYNC_REFRESH (LDAP_SYNC_REFRESH_ONLY<<SLAP_CONTROL_SHIFT)
|
||||
|
|
@ -558,7 +558,7 @@ syncprov_findcsn( Operation *op, int mode )
|
|||
int rc;
|
||||
fpres_cookie pcookie;
|
||||
int locked = 0;
|
||||
sync_control *srs = op->o_controls[sync_cid];
|
||||
sync_control *srs = op->o_controls[slap_cids.sc_LDAPsync];
|
||||
|
||||
if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) {
|
||||
return LDAP_OTHER;
|
||||
|
|
@ -700,9 +700,7 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry *e, int mode
|
|||
e_uuid.e_nname = opc->sndn;
|
||||
rs.sr_entry = &e_uuid;
|
||||
if ( opc->sreference ) {
|
||||
struct berval bv;
|
||||
bv.bv_val = NULL;
|
||||
bv.bv_len = 0;
|
||||
struct berval bv = BER_BVNULL;
|
||||
rs.sr_ref = &bv;
|
||||
send_search_reference( &sop, &rs );
|
||||
} else {
|
||||
|
|
@ -977,7 +975,7 @@ syncprov_op_response( Operation *op, SlapReply *rs )
|
|||
cbuf[0] = '\0';
|
||||
ldap_pvt_thread_mutex_lock( &si->si_csn_mutex );
|
||||
slap_get_commit_csn( op, &maxcsn );
|
||||
if ( maxcsn.bv_val ) {
|
||||
if ( !BER_BVISNULL( &maxcsn ) ) {
|
||||
strcpy( cbuf, maxcsn.bv_val );
|
||||
if ( ber_bvcmp( &maxcsn, &si->si_ctxcsn ) > 0 ) {
|
||||
strcpy( si->si_ctxcsnbuf, cbuf );
|
||||
|
|
@ -1056,7 +1054,7 @@ syncprov_op_compare( Operation *op, SlapReply *rs )
|
|||
e.e_name = op->o_bd->be_suffix[0];
|
||||
e.e_nname = op->o_bd->be_nsuffix[0];
|
||||
|
||||
bv[1].bv_val = NULL;
|
||||
BER_BVZERO( &bv[1] );
|
||||
bv[0] = si->si_ctxcsn;
|
||||
|
||||
a.a_desc = slap_schema.si_ad_contextCSN;
|
||||
|
|
@ -1202,7 +1200,7 @@ syncprov_detach_op( Operation *op, syncops *so )
|
|||
char *ptr;
|
||||
|
||||
/* count the search attrs */
|
||||
for (i=0; op->ors_attrs && op->ors_attrs[i].an_name.bv_val; i++) {
|
||||
for (i=0; op->ors_attrs && !BER_BVISNULL( &op->ors_attrs[i].an_name ); i++) {
|
||||
alen += op->ors_attrs[i].an_name.bv_len + 1;
|
||||
}
|
||||
/* Make a new copy of the operation */
|
||||
|
|
@ -1219,13 +1217,12 @@ syncprov_detach_op( Operation *op, syncops *so )
|
|||
if ( i ) {
|
||||
op2->ors_attrs = (AttributeName *)(op2->o_hdr + 1);
|
||||
ptr = (char *)(op2->ors_attrs+i+1);
|
||||
for (i=0; op->ors_attrs[i].an_name.bv_val; i++) {
|
||||
for (i=0; !BER_BVISNULL( &op->ors_attrs[i].an_name ); i++) {
|
||||
op2->ors_attrs[i] = op->ors_attrs[i];
|
||||
op2->ors_attrs[i].an_name.bv_val = ptr;
|
||||
ptr = lutil_strcopy( ptr, op->ors_attrs[i].an_name.bv_val ) + 1;
|
||||
}
|
||||
op2->ors_attrs[i].an_name.bv_val = NULL;
|
||||
op2->ors_attrs[i].an_name.bv_len = 0;
|
||||
BER_BVZERO( &op2->ors_attrs[i].an_name );
|
||||
} else {
|
||||
ptr = (char *)(op2->o_hdr + 1);
|
||||
}
|
||||
|
|
@ -1257,7 +1254,7 @@ syncprov_search_response( Operation *op, SlapReply *rs )
|
|||
searchstate *ss = op->o_callback->sc_private;
|
||||
slap_overinst *on = ss->ss_on;
|
||||
syncprov_info_t *si = on->on_bi.bi_private;
|
||||
sync_control *srs = op->o_controls[sync_cid];
|
||||
sync_control *srs = op->o_controls[slap_cids.sc_LDAPsync];
|
||||
|
||||
if ( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF ) {
|
||||
int i;
|
||||
|
|
@ -1366,7 +1363,7 @@ syncprov_op_search( Operation *op, SlapReply *rs )
|
|||
return rs->sr_err;
|
||||
}
|
||||
|
||||
srs = op->o_controls[sync_cid];
|
||||
srs = op->o_controls[slap_cids.sc_LDAPsync];
|
||||
|
||||
/* If this is a persistent search, set it up right away */
|
||||
if ( op->o_sync_mode & SLAP_SYNC_PERSIST ) {
|
||||
|
|
@ -1738,7 +1735,7 @@ static int syncprov_parseCtrl (
|
|||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if ( ctrl->ldctl_value.bv_len == 0 ) {
|
||||
if ( BER_BVISEMPTY( &ctrl->ldctl_value ) ) {
|
||||
rs->sr_text = "Sync control value is empty (or absent)";
|
||||
return LDAP_PROTOCOL_ERROR;
|
||||
}
|
||||
|
|
@ -1803,7 +1800,7 @@ static int syncprov_parseCtrl (
|
|||
slap_parse_sync_cookie( &sr->sr_state );
|
||||
}
|
||||
|
||||
op->o_controls[sync_cid] = sr;
|
||||
op->o_controls[slap_cids.sc_LDAPsync] = sr;
|
||||
|
||||
(void) ber_free( ber, 1 );
|
||||
|
||||
|
|
@ -1830,7 +1827,7 @@ syncprov_init()
|
|||
|
||||
rc = register_supported_control( LDAP_CONTROL_SYNC,
|
||||
SLAP_CTRL_HIDE|SLAP_CTRL_SEARCH, NULL,
|
||||
syncprov_parseCtrl, &sync_cid );
|
||||
syncprov_parseCtrl, &slap_cids.sc_LDAPsync );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "Failed to register control %d\n", rc );
|
||||
return rc;
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ slap_sl_free(void *ptr, void *ctx)
|
|||
unsigned long diff;
|
||||
int i, k, inserted = 0;
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "slap_sl_free \n", 0, 0, 0);
|
||||
Debug( LDAP_DEBUG_ANY, "==> slap_sl_free \n", 0, 0, 0);
|
||||
|
||||
if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) {
|
||||
ber_memfree_x(ptr, NULL);
|
||||
|
|
|
|||
|
|
@ -2131,6 +2131,7 @@ struct slap_control_ids {
|
|||
int sc_treeDelete;
|
||||
int sc_searchOptions;
|
||||
int sc_subentries;
|
||||
int sc_LDAPsync;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -2330,6 +2331,8 @@ typedef struct slap_op {
|
|||
#define o_pagedresults o_ctrlflag[slap_cids.sc_pagedResults]
|
||||
#define o_pagedresults_state o_controls[slap_cids.sc_pagedResults]
|
||||
|
||||
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
|
||||
|
||||
#define get_pagedresults(op) ((int)(op)->o_pagedresults)
|
||||
|
||||
#ifdef BDB_PSEARCH
|
||||
|
|
|
|||
Loading…
Reference in a new issue