.SM ldap_unbind_ext(3)
synchronously unbind from the LDAP server and close the connection
.TP
-.SM ldap_unbind_ext_s(3)
+.SM ldap_unbind(3) and ldap_unbind_s(3) are
equivalent to
.BR ldap_unbind_ext (3)
.TP
int nmatch, regmatch_t *matches);
typedef struct AclSetCookie {
- Operation *op;
- Entry *e;
+ SetCookie asc_cookie;
+#define asc_op asc_cookie.set_op
+ Entry *asc_e;
} AclSetCookie;
SLAP_SET_GATHER acl_set_gather;
{
assert( maskp != NULL );
- ACL_PRIV_SET( *maskp, ACL_ACCESS2PRIV( access ) );
+ /* assign all */
+ ACL_LVL_ASSIGN_MANAGE( *maskp );
return 1;
}
assert( attr != NULL );
+ ACL_INIT( mask );
+
/* grant database root access */
if ( be_isroot( op ) ) {
Debug( LDAP_DEBUG_ACL, "<= root access granted\n", 0, 0, 0 );
* if we get here it means a non-root user is trying to
* manage data, so we need to check its privileges.
*/
- if ( access_level == ACL_WRITE && is_at_no_user_mod( desc->ad_type )
+ if ( access_level == ACL_WRITE
+ && is_at_no_user_mod( desc->ad_type )
&& desc != slap_schema.si_ad_entry
&& desc != slap_schema.si_ad_children )
{
}
rdnlen = dn_rdnlen( NULL, opndn );
- if ( rdnlen != odnlen - patlen - 1 ) {
+ if ( rdnlen - ( odnlen - patlen - 1 ) != 0 ) {
goto dn_match_cleanup;
}
}
} else if ( b->a_style == ACL_STYLE_LEVEL ) {
- int level;
- struct berval ndn;
+ int level = b->a_level;
+ struct berval ndn;
if ( odnlen <= patlen ) {
goto dn_match_cleanup;
goto dn_match_cleanup;
}
- level = b->a_level;
ndn = *opndn;
for ( ; level > 0; level-- ) {
if ( BER_BVISEMPTY( &ndn ) ) {
/* Grab the searchbase and see if an appropriate database can be found */
ber_str2bv( ludp->lud_dn, 0, 0, &op2.o_req_dn );
rc = dnNormalize( 0, NULL, NULL, &op2.o_req_dn,
- &op2.o_req_ndn, cp->op->o_tmpmemctx );
+ &op2.o_req_ndn, cp->asc_op->o_tmpmemctx );
BER_BVZERO( &op2.o_req_dn );
if ( rc != LDAP_SUCCESS ) {
goto url_done;
/* Grab the filter */
if ( ludp->lud_filter ) {
ber_str2bv_x( ludp->lud_filter, 0, 0, &op2.ors_filterstr,
- cp->op->o_tmpmemctx );
+ cp->asc_op->o_tmpmemctx );
} else {
op2.ors_filterstr = defaultFilter_bv;
}
- op2.ors_filter = str2filter_x( cp->op, op2.ors_filterstr.bv_val );
+ op2.ors_filter = str2filter_x( cp->asc_op, op2.ors_filterstr.bv_val );
if ( op2.ors_filter == NULL ) {
rc = LDAP_PROTOCOL_ERROR;
goto url_done;
;
anlistp = slap_sl_malloc( sizeof( AttributeName ) * ( nattrs + 2 ),
- cp->op->o_tmpmemctx );
+ cp->asc_op->o_tmpmemctx );
for ( ; ludp->lud_attrs[ nattrs ]; nattrs++ ) {
ber_str2bv( ludp->lud_attrs[ nattrs ], 0, 0, &anlistp[ nattrs ].an_name );
p.cookie = cookie;
- op2.o_hdr = cp->op->o_hdr;
+ op2.o_hdr = cp->asc_op->o_hdr;
op2.o_tag = LDAP_REQ_SEARCH;
op2.o_ndn = op2.o_bd->be_rootndn;
op2.o_callback = &cb;
op2.o_time = slap_get_time();
op2.o_do_not_cache = 1;
op2.o_is_auth_check = 0;
- ber_dupbv_x( &op2.o_req_dn, &op2.o_req_ndn, cp->op->o_tmpmemctx );
+ ber_dupbv_x( &op2.o_req_dn, &op2.o_req_ndn, cp->asc_op->o_tmpmemctx );
op2.ors_slimit = SLAP_NO_LIMIT;
op2.ors_tlimit = SLAP_NO_LIMIT;
op2.ors_attrs = anlistp;
op2.ors_attrsonly = 0;
- op2.o_private = cp->op->o_private;
+ op2.o_private = cp->asc_op->o_private;
cb.sc_private = &p;
url_done:;
if ( op2.ors_filter ) {
- filter_free_x( cp->op, op2.ors_filter );
+ filter_free_x( cp->asc_op, op2.ors_filter );
}
if ( !BER_BVISNULL( &op2.o_req_ndn ) ) {
- slap_sl_free( op2.o_req_ndn.bv_val, cp->op->o_tmpmemctx );
+ slap_sl_free( op2.o_req_ndn.bv_val, cp->asc_op->o_tmpmemctx );
}
if ( !BER_BVISNULL( &op2.o_req_dn ) ) {
- slap_sl_free( op2.o_req_dn.bv_val, cp->op->o_tmpmemctx );
+ slap_sl_free( op2.o_req_dn.bv_val, cp->asc_op->o_tmpmemctx );
}
if ( ludp ) {
ldap_free_urldesc( ludp );
}
if ( anlistp && anlistp != anlist ) {
- slap_sl_free( anlistp, cp->op->o_tmpmemctx );
+ slap_sl_free( anlistp, cp->asc_op->o_tmpmemctx );
}
return p.bvals;
* plain strings, since syntax is not known. It should
* also return the syntax or some "comparison cookie".
*/
- rc = dnNormalize( 0, NULL, NULL, name, &ndn, cp->op->o_tmpmemctx );
+ rc = dnNormalize( 0, NULL, NULL, name, &ndn, cp->asc_op->o_tmpmemctx );
if ( rc == LDAP_SUCCESS ) {
if ( desc == slap_schema.si_ad_entryDN ) {
bvals = (BerVarray)slap_sl_malloc( sizeof( BerValue ) * 2,
- cp->op->o_tmpmemctx );
+ cp->asc_op->o_tmpmemctx );
bvals[ 0 ] = ndn;
BER_BVZERO( &bvals[ 1 ] );
BER_BVZERO( &ndn );
} else {
- backend_attribute( cp->op,
- cp->e, &ndn, desc, &bvals, ACL_NONE );
+ backend_attribute( cp->asc_op,
+ cp->asc_e, &ndn, desc, &bvals, ACL_NONE );
}
if ( !BER_BVISNULL( &ndn ) ) {
- slap_sl_free( ndn.bv_val, cp->op->o_tmpmemctx );
+ slap_sl_free( ndn.bv_val, cp->asc_op->o_tmpmemctx );
}
}
}
if ( !BER_BVISNULL( &set ) ) {
- cookie.op = op;
- cookie.e = e;
- rc = ( slap_set_filter( acl_set_gather, (SetCookie *)&cookie, &set,
+ cookie.asc_op = op;
+ cookie.asc_e = e;
+ rc = ( slap_set_filter(
+ acl_set_gather,
+ (SetCookie *)&cookie, &set,
&op->o_ndn, &e->e_nname, NULL ) > 0 );
slap_sl_free( set.bv_val, op->o_tmpmemctx );
}
desc.ad_cname = *bv;
name = bv->bv_val;
options = strchr( name, ';' );
- if ( options != NULL && ( options - name ) < bv->bv_len ) {
+ if ( options != NULL && (unsigned) ( options - name ) < bv->bv_len ) {
/* don't go past the end of the berval! */
desc.ad_cname.bv_len = options - name;
} else {
rc = strncasecmp( opt, tags[i].bv_val,
(unsigned) optlen < tags[i].bv_len
- ? optlen : tags[i].bv_len );
+ ? (unsigned) optlen : tags[i].bv_len );
if( rc == 0 && (unsigned)optlen == tags[i].bv_len ) {
/* duplicate (ignore) */
if( lp != desc.ad_tags.bv_val ) {
*cp++ = ';';
j = (lp
- ? lp - desc.ad_tags.bv_val - 1
+ ? (unsigned) (lp - desc.ad_tags.bv_val - 1)
: strlen( desc.ad_tags.bv_val ));
cp = lutil_strncopy(cp, desc.ad_tags.bv_val, j);
}
}
} else {
- /* short-circuit this search next time around */
- if (!slap_schema.si_at_undefined->sat_ad) {
- const char *text;
- slap_bv2undef_ad(&attrs->an_name,
- &attrs->an_desc, &text, 0);
- } else {
- attrs->an_desc =
- slap_schema.si_at_undefined->sat_ad;
- }
+ const char *text;
+
+ /* give it a chance of being retrieved by a proxy... */
+ (void)slap_bv2undef_ad( &attrs->an_name,
+ &attrs->an_desc, &text,
+ SLAP_AD_PROXIED|SLAP_AD_NOINSERT );
}
}
desc->ad_next = desc->ad_type->sat_ad;
desc->ad_type->sat_ad = desc;
ldap_pvt_thread_mutex_unlock( &ad_undef_mutex );
+
+ Debug( LDAP_DEBUG_ANY,
+ "%s attributeDescription \"%s\" inserted.\n",
+ ( flags & SLAP_AD_PROXIED ) ? "PROXIED" : "UNKNOWN",
+ desc->ad_cname.bv_val, 0 );
}
if( !*ad ) {
open_env = 0;
} else {
/* Create a new env that can take the desired settings */
+ bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
+ bdb->bi_dbenv = NULL;
rc = db_env_create( &bdb->bi_dbenv, 0 );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
* Rewrite the matched portion of the search base, if required
*/
if ( !BER_BVISNULL( &match ) && !BER_BVISEMPTY( &match ) ) {
- rs->sr_matched = match.bv_val;
+ struct berval pmatch;
+
+ if ( dnPretty( NULL, &match, &pmatch, op->o_tmpmemctx ) == LDAP_SUCCESS ) {
+ rs->sr_matched = pmatch.bv_val;
+
+ } else {
+ rs->sr_matched = match.bv_val;
+ }
}
if ( rs->sr_v2ref ) {
rs->sr_ctrls = NULL;
}
- if ( match.bv_val ) {
+ if ( rs->sr_matched != NULL ) {
+ if ( rs->sr_matched != match.bv_val ) {
+ ber_memfree_x( (char *)rs->sr_matched, op->o_tmpmemctx );
+
+ } else {
+ LDAP_FREE( match.bv_val );
+ }
rs->sr_matched = NULL;
- LDAP_FREE( match.bv_val );
}
if ( !BER_BVISNULL( &filter ) && filter.bv_val != op->ors_filterstr.bv_val ) {
ldap_back_release_conn( op, rs, lc );
}
- return rc;
+ return rs->sr_err;
}
static int
rerr = LDAP_SUCCESS;
char *rmsg = NULL;
char *rmatch = NULL;
- int free_rmsg = 0,
- free_rmatch = 0;
if ( candidate != META_TARGET_NONE ) {
metasingleconn_t *msc = &mc->mc_conns[ candidate ];
*/
ldap_get_option( msc->msc_ld,
LDAP_OPT_ERROR_STRING, &rmsg );
+ if ( rmsg != NULL && rmsg[ 0 ] == '\0' ) {
+ ldap_memfree( rmsg );
+ rmsg = NULL;
+ }
+
ldap_get_option( msc->msc_ld,
LDAP_OPT_MATCHED_DN, &rmatch );
- rerr = rs->sr_err = slap_map_api2result( rs );
-
- if ( rmsg ) {
- free_rmsg = 1;
- }
- if ( rmatch ) {
- free_rmatch = 1;
+ if ( rmatch != NULL && rmatch[ 0 ] == '\0' ) {
+ ldap_memfree( rmatch );
+ rmatch = NULL;
}
+ rerr = rs->sr_err = slap_map_api2result( rs );
+
Debug(LDAP_DEBUG_ANY,
"==> meta_back_op_result: target"
" <%d> sending msg \"%s\""
*/
ldap_get_option( msc->msc_ld,
LDAP_OPT_ERROR_STRING, &msg );
+ if ( msg != NULL && msg[ 0 ] == '\0' ) {
+ ldap_memfree( msg );
+ msg = NULL;
+ }
+
ldap_get_option( msc->msc_ld,
LDAP_OPT_MATCHED_DN, &match );
+ if ( match != NULL && match[ 0 ] == '\0' ) {
+ ldap_memfree( match );
+ match = NULL;
+ }
+
rs->sr_err = slap_map_api2result( rs );
Debug(LDAP_DEBUG_ANY,
switch ( rs->sr_err ) {
default:
rerr = rs->sr_err;
- if ( rmsg ) {
- ber_memfree( rmsg );
+ if ( msg != NULL ) {
+ if ( rmsg ) {
+ ldap_memfree( rmsg );
+ }
+ rmsg = msg;
+ msg = NULL;
}
- rmsg = msg;
- free_rmsg = 1;
- msg = NULL;
- if ( rmatch ) {
- ber_memfree( rmatch );
+ if ( match != NULL ) {
+ if ( rmatch ) {
+ ldap_memfree( rmatch );
+ }
+ rmatch = match;
+ match = NULL;
}
- rmatch = match;
- free_rmatch = 1;
- match = NULL;
break;
}
+
+ if ( msg ) {
+ ldap_memfree( msg );
+ }
- /* better test the pointers before freeing? */
if ( match ) {
- free( match );
- }
- if ( msg ) {
- free( msg );
+ ldap_memfree( match );
}
}
}
rs->sr_err = rerr;
rs->sr_text = rmsg;
- rs->sr_matched = rmatch;
+ if ( rmatch != NULL ) {
+ struct berval dn, pdn;
+
+ ber_str2bv( rmatch, 0, 0, &dn );
+ if ( dnPretty( NULL, &dn, &pdn, op->o_tmpmemctx ) == LDAP_SUCCESS ) {
+ rs->sr_matched = pdn.bv_val;
+ ldap_memfree( rmatch );
+ rmatch = NULL;
+ } else {
+ rs->sr_matched = rmatch;
+ }
+
+ } else {
+ rs->sr_matched = NULL;
+ }
send_ldap_result( op, rs );
- if ( free_rmsg ) {
+ if ( rmsg != NULL ) {
ber_memfree( rmsg );
}
- if ( free_rmatch ) {
- ber_memfree( rmatch );
+ if ( rs->sr_matched != NULL ) {
+ if ( rmatch == NULL ) {
+ ber_memfree_x( rs->sr_matched, op->o_tmpmemctx );
+
+ } else {
+ ldap_memfree( rmatch );
+ }
+ rs->sr_matched = NULL;
}
rs->sr_text = NULL;
- rs->sr_matched = NULL;
return ( ( rerr == LDAP_SUCCESS ) ? 0 : -1 );
}
* At least one compare failed with matched portion,
* and none was successful
*/
- } else if ( match != NULL && match[0] != '\0' ) {
- struct berval matched;
+ } else if ( match != NULL && match[ 0 ] != '\0' ) {
+ struct berval matched, pmatched;
ber_str2bv( match, 0, 0, &matched );
dc.ctx = "matchedDN";
ldap_back_dn_massage( &dc, &matched, &mmatch );
+ if ( dnPretty( NULL, &mmatch, &pmatched, NULL ) == LDAP_SUCCESS ) {
+ if ( mmatch.bv_val != match ) {
+ free( mmatch.bv_val );
+ }
+ mmatch = pmatched;
+ }
}
if ( rres != LDAP_SUCCESS ) {
}
} else if ( sres == LDAP_NO_SUCH_OBJECT ) {
- matched = ch_strdup( op->o_bd->be_suffix[ 0 ].bv_val );
+ matched = op->o_bd->be_suffix[ 0 ].bv_val;
}
#if 0
rs->sr_ref = NULL;
finish:;
- if ( matched ) {
+ if ( matched && matched != op->o_bd->be_suffix[ 0 ].bv_val ) {
op->o_tmpfree( matched, op->o_tmpmemctx );
}
ch_free( c->tline );
if ( fp_parse_line( c ) ) {
rc = 1;
- goto leave;
+ goto done;
}
if ( c->argc < 1 ) {
c->log, 0, 0);
#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
rc = 1;
- goto leave;
+ goto done;
#else /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
continue;
#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%s>\n",
c->log, c->argv[0], 0);
rc = 1;
- goto leave;
+ goto done;
} else if ( rc == ARG_BAD_CONF ) {
rc = 1;
- goto leave;
+ goto done;
}
} else if ( c->bi && !c->be ) {
#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
default:
rc = 1;
- goto leave;
+ goto done;
}
}
#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
default:
rc = 1;
- goto leave;
+ goto done;
}
}
#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
default:
rc = 1;
- goto leave;
+ goto done;
}
}
c->log, *c->argv, 0);
#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
rc = 1;
- goto leave;
+ goto done;
#else /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
continue;
#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */
rc = 0;
-leave:
+done:
ch_free(c->tline);
fclose(fp);
ch_free(c->argv);
ber_tag_t tag;
if ( ctrl->ldctl_value.bv_len == 0 ) {
- rs->sr_text = "searchOptions control value not empty";
+ rs->sr_text = "searchOptions control value is empty (or absent)";
return LDAP_PROTOCOL_ERROR;
}
* including:
* LDAP_SEARCH_FLAG_PHANTOM_ROOM
*/
- rs->sr_text = "searchOptions contained unrecongized flag";
+ rs->sr_text = "searchOptions contained unrecognized flag";
return LDAP_UNWILLING_TO_PERFORM;
}
assert( mode );
if ( slapMode != SLAP_UNDEFINED_MODE ) {
+ /* Make sure we write something to stderr */
+ ldap_debug |= 1;
Debug( LDAP_DEBUG_ANY,
"%s init: init called twice (old=%d, new=%d)\n",
name, slapMode, mode );
slapMode = mode;
+#ifdef SLAPD_MODULES
+ if ( module_init() != 0 ) {
+ ldap_debug |= 1;
+ Debug( LDAP_DEBUG_ANY,
+ "%s: module_init failed\n",
+ name, 0, 0 );
+ return 1;
+ }
+#endif
+
+ if ( slap_schema_init( ) != 0 ) {
+ ldap_debug |= 1;
+ Debug( LDAP_DEBUG_ANY,
+ "%s: slap_schema_init failed\n",
+ name, 0, 0 );
+ return 1;
+ }
+
+
switch ( slapMode & SLAP_MODE ) {
case SLAP_SERVER_MODE:
ldap_pvt_thread_pool_init( &connection_pool,
break;
default:
+ ldap_debug |= 1;
Debug( LDAP_DEBUG_ANY,
"%s init: undefined mode (%d).\n", name, mode, 0 );
break;
}
+ if ( slap_controls_init( ) != 0 ) {
+ ldap_debug |= 1;
+ Debug( LDAP_DEBUG_ANY,
+ "%s: slap_controls_init failed\n",
+ name, 0, 0 );
+ return 1;
+ }
+
+#ifdef HAVE_TLS
+ /* Library defaults to full certificate checking. This is correct when
+ * a client is verifying a server because all servers should have a
+ * valid cert. But few clients have valid certs, so we want our default
+ * to be no checking. The config file can override this as usual.
+ */
+ rc = 0;
+ (void) ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc );
+#endif
+
+ if ( frontend_init() ) {
+ ldap_debug |= 1;
+ Debug( LDAP_DEBUG_ANY,
+ "%s: frontend_init failed\n",
+ name, 0, 0 );
+ return 1;
+ }
+
+ if ( overlay_init() ) {
+ ldap_debug |= 1;
+ Debug( LDAP_DEBUG_ANY,
+ "%s: overlay_init failed\n",
+ name, 0, 0 );
+ return 1;
+ }
+
+#ifdef SLAP_DYNACL
+ if ( acl_init() ) {
+ ldap_debug |= 1;
+ Debug( LDAP_DEBUG_ANY,
+ "%s: acl_init failed\n",
+ name, 0, 0 );
+ return 1;
+ }
+#endif /* SLAP_DYNACL */
return rc;
}
lutil_passwd_init();
slap_op_init();
-#ifdef SLAPD_MODULES
- if ( module_init() != 0 ) {
- rc = 1;
- SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 17 );
- goto destroy;
- }
-#endif
-
- if ( slap_schema_init( ) != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "schema initialization error\n",
- 0, 0, 0 );
-
- goto destroy;
- }
-
- if ( slap_init( serverMode, serverName ) != 0 ) {
- rc = 1;
+ rc = slap_init( serverMode, serverName );
+ if ( rc ) {
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 18 );
goto destroy;
}
- if ( slap_controls_init( ) != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "controls initialization error\n",
- 0, 0, 0 );
-
- goto destroy;
- }
-
-#ifdef HAVE_TLS
- /* Library defaults to full certificate checking. This is correct when
- * a client is verifying a server because all servers should have a
- * valid cert. But few clients have valid certs, so we want our default
- * to be no checking. The config file can override this as usual.
- */
- rc = 0;
- (void) ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc );
-#endif
-
- if ( frontend_init() ) {
- goto destroy;
- }
-
- if ( overlay_init() ) {
- goto destroy;
- }
-
-#ifdef SLAP_DYNACL
- if ( acl_init() ) {
- goto destroy;
- }
-#endif /* SLAP_DYNACL */
-
if ( read_config( configfile, configdir ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
agebv->bv_len = ptr - agebv->bv_val;
}
-static slap_callback nullsc = { NULL, slap_null_cb, NULL, NULL };
+static slap_callback nullsc = { NULL, NULL, NULL, NULL };
#define PURGE_INCREMENT 100
vals[i].bv_len = m->sml_desc->ad_cname.bv_len + 2;
vals[i].bv_val = ch_malloc( vals[i].bv_len+1 );
ptr = lutil_strcopy( vals[i].bv_val,
- a->a_desc->ad_cname.bv_val );
+ m->sml_desc->ad_cname.bv_val );
*ptr++ = ':';
*ptr++ = '-';
*ptr = '\0';
accesslog.on_bi.bi_cf_ocs = log_cfocs;
+ nullsc.sc_response = slap_null_cb;
+
rc = config_register_schema( log_cfats, log_cfocs );
if ( rc ) return rc;
{
slap_overinst *on = (slap_overinst *) be->bd_info;
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private;
- int i;
if ( slapMode & SLAP_TOOL_MODE ) {
return 0;
up->next = ud->attrs;
ud->attrs = up;
}
- Debug(LDAP_DEBUG_ANY, "%s: line %d: new attribute <%s>\n",
+ Debug(LDAP_DEBUG_CONFIG, "%s: line %d: new attribute <%s>\n",
fname, lineno, argv[i]);
}
} else if(!strcasecmp(*argv, "unique_strict")) {
ber_str2bv( argv[1], 0, 0, &bv );
ch_free(ud->dn.bv_val);
dnNormalize(0, NULL, NULL, &bv, &ud->dn, NULL);
- Debug(LDAP_DEBUG_ANY, "%s: line %d: new base dn <%s>\n",
+ Debug(LDAP_DEBUG_CONFIG, "%s: line %d: new base dn <%s>\n",
fname, lineno, argv[1]);
} else {
return(SLAP_CONF_UNKNOWN);
valsort_info *vi;
Attribute *a;
- /* We only want search responses */
- if ( rs->sr_type != REP_SEARCH ) return SLAP_CB_CONTINUE;
-
- /* If this is a syncrepl response, pass thru unmodified */
- if ( op->o_sync > SLAP_CONTROL_IGNORED ) return SLAP_CB_CONTINUE;
+ /* If this is not a search response, or it is a syncrepl response,
+ * or the valsort control wants raw results, pass thru unmodified.
+ */
+ if ( rs->sr_type != REP_SEARCH ||
+ ( _SCM(op->o_sync) > SLAP_CONTROL_IGNORED ) ||
+ ( op->o_ctrlflag[valsort_cid] & SLAP_CONTROL_DATA0))
+ return SLAP_CB_CONTINUE;
on = (slap_overinst *) op->o_bd->bd_info;
vi = on->on_bi.bi_private;
return SLAP_CB_CONTINUE;
}
+static int
+valsort_db_open(
+ BackendDB *be
+)
+{
+ return overlay_register_control( be, LDAP_CONTROL_VALSORT );
+}
+
static int
valsort_destroy(
BackendDB *be
SlapReply *rs,
LDAPControl *ctrl )
{
- if ( ctrl->ldctl_value.bv_len ) {
- rs->sr_text = "valSort control value not empty";
+ ber_tag_t tag;
+ BerElementBuffer berbuf;
+ BerElement *ber = (BerElement *)&berbuf;
+ ber_int_t flag = 0;
+
+ if ( ctrl->ldctl_value.bv_len == 0 ) {
+ rs->sr_text = "valSort control value is empty (or absent)";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ ber_init2( ber, &ctrl->ldctl_value, 0 );
+ if (( tag = ber_scanf( ber, "{b}", &flag )) == LBER_ERROR ) {
+ rs->sr_text = "valSort control: flag decoding error";
return LDAP_PROTOCOL_ERROR;
}
+
op->o_ctrlflag[valsort_cid] = ctrl->ldctl_iscritical ?
SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
+ if ( flag )
+ op->o_ctrlflag[valsort_cid] |= SLAP_CONTROL_DATA0;
return LDAP_SUCCESS;
}
int valsort_init()
{
- int i, rc;
+ int rc;
valsort.on_bi.bi_type = "valsort";
valsort.on_bi.bi_db_destroy = valsort_destroy;
+ valsort.on_bi.bi_db_open = valsort_db_open;
valsort.on_bi.bi_op_add = valsort_add;
valsort.on_bi.bi_op_modify = valsort_modify;
{
if ( flags & SLAP_SET_REFVAL ) {
if ( ! ( flags & SLAP_SET_REFARR ) ) {
- cp->op->o_tmpfree( set, cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpfree( set, cp->set_op->o_tmpmemctx );
}
} else {
- ber_bvarray_free_x( set, cp->op->o_tmpmemctx );
+ ber_bvarray_free_x( set, cp->set_op->o_tmpmemctx );
}
}
for ( i = 0; !BER_BVISNULL( &set[ i ] ); i++ )
;
- newset = cp->op->o_tmpcalloc( i + 1,
+ newset = cp->set_op->o_tmpcalloc( i + 1,
sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpmemctx );
if ( newset == NULL ) {
return NULL;
}
if ( flags & SLAP_SET_REFVAL ) {
for ( i = 0; !BER_BVISNULL( &set[ i ] ); i++ ) {
ber_dupbv_x( &newset[ i ], &set[ i ],
- cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpmemctx );
}
} else {
if ( lset == NULL || BER_BVISNULL( lset ) ) {
if ( rset == NULL ) {
if ( lset == NULL ) {
- set = cp->op->o_tmpcalloc( 1,
+ set = cp->set_op->o_tmpcalloc( 1,
sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpmemctx );
BER_BVZERO( set );
return set;
}
}
i = slap_set_size( lset ) + slap_set_size( rset ) + 1;
- set = cp->op->o_tmpcalloc( i, sizeof(struct berval), cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( i, sizeof(struct berval), cp->set_op->o_tmpmemctx );
if ( set != NULL ) {
/* set_chase() depends on this routine to
* keep the first elements of the result
*/
for ( i = 0; !BER_BVISNULL( &lset[ i ] ); i++ ) {
if ( op_flags & SLAP_SET_LREFVAL ) {
- ber_dupbv_x( &set[ i ], &lset[ i ], cp->op->o_tmpmemctx );
+ ber_dupbv_x( &set[ i ], &lset[ i ], cp->set_op->o_tmpmemctx );
} else {
set[ i ] = lset[ i ];
if ( bvmatch( &rset[ i ], &set[ j ] ) )
{
if ( !( op_flags & SLAP_SET_RREFVAL ) ) {
- cp->op->o_tmpfree( rset[ i ].bv_val, cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpfree( rset[ i ].bv_val, cp->set_op->o_tmpmemctx );
BER_BVZERO( &rset[ i ] );
}
exists = 1;
if ( !exists ) {
if ( op_flags & SLAP_SET_RREFVAL ) {
- ber_dupbv_x( &set[ last ], &rset[ i ], cp->op->o_tmpmemctx );
+ ber_dupbv_x( &set[ last ], &rset[ i ], cp->set_op->o_tmpmemctx );
} else {
set[ last ] = rset[ i ];
if ( lset == NULL || BER_BVISNULL( lset )
|| rset == NULL || BER_BVISNULL( rset ) )
{
- set = cp->op->o_tmpcalloc( 1, sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( 1, sizeof(struct berval),
+ cp->set_op->o_tmpmemctx );
BER_BVZERO( set );
} else {
}
if ( BER_BVISNULL( &rset[ j ] ) ) {
- cp->op->o_tmpfree( set[ i ].bv_val, cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpfree( set[ i ].bv_val, cp->set_op->o_tmpmemctx );
set[ i ] = set[ last ];
BER_BVZERO( &set[ last ] );
last--;
i = slap_set_size( rset );
j = slap_set_size( lset );
- set = cp->op->o_tmpcalloc( i * j + 1, sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( i * j + 1, sizeof(struct berval),
+ cp->set_op->o_tmpmemctx );
if ( set == NULL ) {
break;
}
long k;
bv.bv_len = lset[ i ].bv_len + rset[ j ].bv_len;
- bv.bv_val = cp->op->o_tmpalloc( bv.bv_len + 1,
- cp->op->o_tmpmemctx );
+ bv.bv_val = cp->set_op->o_tmpalloc( bv.bv_len + 1,
+ cp->set_op->o_tmpmemctx );
if ( bv.bv_val == NULL ) {
slap_set_dispose( cp, set, 0 );
set = NULL;
for ( k = 0; k < last; k++ ) {
if ( bvmatch( &set[ k ], &bv ) ) {
- cp->op->o_tmpfree( bv.bv_val, cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpfree( bv.bv_val, cp->set_op->o_tmpmemctx );
break;
}
}
done:;
if ( !( op_flags & SLAP_SET_LREFARR ) && lset != NULL ) {
- cp->op->o_tmpfree( lset, cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpfree( lset, cp->set_op->o_tmpmemctx );
}
if ( !( op_flags & SLAP_SET_RREFARR ) && rset != NULL ) {
- cp->op->o_tmpfree( rset, cp->op->o_tmpmemctx );
+ cp->set_op->o_tmpfree( rset, cp->set_op->o_tmpmemctx );
}
return set;
int i;
if ( set == NULL ) {
- set = cp->op->o_tmpcalloc( 1, sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( 1, sizeof(struct berval),
+ cp->set_op->o_tmpmemctx );
BER_BVZERO( set );
return set;
}
return set;
}
- nset = cp->op->o_tmpcalloc( 1, sizeof(struct berval), cp->op->o_tmpmemctx );
+ nset = cp->set_op->o_tmpcalloc( 1, sizeof(struct berval), cp->set_op->o_tmpmemctx );
if ( nset == NULL ) {
slap_set_dispose( cp, set, 0 );
return NULL;
BerVarray set, lset;
BerVarray stack[ STACK_SIZE ] = { 0 };
int len, rc, stp;
- unsigned op;
+ unsigned long op;
char c, *filter = fbv->bv_val;
if ( results ) {
set = NULL;
} else if ( IS_OP( SF_TOP() ) ) {
- op = (unsigned)SF_POP();
+ op = (unsigned long)SF_POP();
lset = SF_POP();
SF_POP();
set = slap_set_join( cp, lset, op, set );
set = NULL;
} else if ( IS_OP( SF_TOP() ) ) {
- op = (unsigned)SF_POP();
+ op = (unsigned long)SF_POP();
lset = SF_POP();
set = slap_set_join( cp, lset, op, set );
if ( set == NULL ) {
SF_ERROR(syntax);
}
- set = cp->op->o_tmpcalloc( 2, sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( 2, sizeof(struct berval),
+ cp->set_op->o_tmpmemctx );
if ( set == NULL ) {
SF_ERROR(memory);
}
- set->bv_val = cp->op->o_tmpcalloc( len + 1, sizeof(char),
- cp->op->o_tmpmemctx );
+ set->bv_val = cp->set_op->o_tmpcalloc( len + 1, sizeof(char),
+ cp->set_op->o_tmpmemctx );
if ( BER_BVISNULL( set ) ) {
SF_ERROR( memory );
}
if ( ( SF_TOP() == (void *)'/' ) || IS_SET( SF_TOP() ) ) {
SF_ERROR( syntax );
}
- set = cp->op->o_tmpcalloc( 2, sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( 2, sizeof(struct berval),
+ cp->set_op->o_tmpmemctx );
if ( set == NULL ) {
SF_ERROR( memory );
}
- ber_dupbv_x( set, target, cp->op->o_tmpmemctx );
+ ber_dupbv_x( set, target, cp->set_op->o_tmpmemctx );
if ( BER_BVISNULL( set ) ) {
SF_ERROR( memory );
}
if ( ( SF_TOP() == (void *)'/' ) || IS_SET( SF_TOP() ) ) {
SF_ERROR( syntax );
}
- set = cp->op->o_tmpcalloc( 2, sizeof(struct berval),
- cp->op->o_tmpmemctx );
+ set = cp->set_op->o_tmpcalloc( 2, sizeof(struct berval),
+ cp->set_op->o_tmpmemctx );
if ( set == NULL ) {
SF_ERROR( memory );
}
- ber_dupbv_x( set, user, cp->op->o_tmpmemctx );
+ ber_dupbv_x( set, user, cp->set_op->o_tmpmemctx );
if ( BER_BVISNULL( set ) ) {
SF_ERROR( memory );
}
/* FIXME: ok ? */ ;
} else if ( IS_OP( SF_TOP() ) ) {
- op = (unsigned)SF_POP();
+ op = (unsigned long)SF_POP();
lset = SF_POP();
set = slap_set_join( cp, lset, op, set );
if ( set == NULL ) {
LDAP_BEGIN_DECL
typedef struct slap_set_cookie {
- struct slap_op *op;
+ struct slap_op *set_op;
} SetCookie;
/* this routine needs to return the bervals instead of
* initialize stuff and figure out which backend we're dealing with
*/
-#ifdef SLAPD_MODULES
- if ( module_init() != 0 ) {
- fprintf( stderr, "%s: module_init failed!\n", progname );
- exit( EXIT_FAILURE );
- }
-#endif
-
- rc = slap_schema_init();
-
- if ( rc != 0 ) {
- fprintf( stderr, "%s: slap_schema_init failed!\n", progname );
- exit( EXIT_FAILURE );
- }
-
rc = slap_init( mode, progname );
-
if ( rc != 0 ) {
fprintf( stderr, "%s: slap_init failed!\n", progname );
exit( EXIT_FAILURE );
}
- if ( frontend_init() ) {
- fprintf( stderr, "%s: frontend_init failed!\n", progname );
- exit( EXIT_FAILURE );
- }
-
- if ( overlay_init() ) {
- fprintf( stderr, "%s: overlay_init failed!\n", progname );
- exit( EXIT_FAILURE );
- }
-
-#ifdef SLAP_DYNACL
- if ( acl_init() ) {
- fprintf( stderr, "%s: acl_init failed!\n", progname );
- exit( EXIT_FAILURE );
- }
-#endif /* SLAP_DYNACL */
-
rc = read_config( conffile, confdir );
if ( rc != 0 ) {
int slapi_sdn_isempty( const Slapi_DN *sdn)
{
- return ( BER_BVISEMPTY( &sdn->dn ) );
+ return ( BER_BVISEMPTY( &sdn->dn ) && BER_BVISEMPTY( &sdn->ndn ) );
}
int slapi_sdn_issuffix( const Slapi_DN *sdn, const Slapi_DN *suffix_sdn )
void slapi_rdn_set_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn )
{
- return slapi_rdn_set_dn( rdn, slapi_sdn_get_dn( sdn ) );
+ slapi_rdn_set_dn( rdn, slapi_sdn_get_dn( sdn ) );
}
void slapi_rdn_set_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn )
{
- return slapi_rdn_set_dn( rdn, fromrdn->bv.bv_val );
+ slapi_rdn_set_dn( rdn, fromrdn->bv.bv_val );
}
void slapi_rdn_free( Slapi_RDN **rdn )