if ( rs->sr_err != LDAP_SUCCESS ) {
op->o_tmpfree( ctrls, op->o_tmpmemctx );
ctrls = NULL;
+ goto done;
}
} else if ( li->li_idassert_flags & LDAP_BACK_AUTH_OBSOLETE_PROXY_AUTHZ ) {
if ( strncasecmp( authzID.bv_val, "dn:", STRLENOF( "dn:" ) ) != 0 ) {
op->o_tmpfree( ctrls[ 0 ]->ldctl_value.bv_val, op->o_tmpmemctx );
op->o_tmpfree( ctrls, op->o_tmpmemctx );
+ ctrls = NULL;
rs->sr_err = LDAP_PROTOCOL_ERROR;
goto done;
}
} else if ( strncasecmp( c->argv[ i ], "flags=", STRLENOF( "flags=" ) ) == 0 ) {
char *argvi = c->argv[ i ] + STRLENOF( "flags=" );
char **flags = ldap_str2charray( argvi, "," );
- int j;
+ int j, err = 0;
if ( flags == NULL ) {
snprintf( c->msg, sizeof( c->msg ),
}
for ( j = 0; flags[ j ] != NULL; j++ ) {
+
if ( strcasecmp( flags[ j ], "override" ) == 0 ) {
li->li_idassert_flags |= LDAP_BACK_AUTH_OVERRIDE;
"in \"idassert-mode <args>\" "
"incompatible with previously issued \"obsolete-encoding-workaround\" flag.\n",
c->fname, c->lineno, 0 );
- return 1;
+ err = 1;
+ break;
+
+ } else {
+ li->li_idassert_flags |= LDAP_BACK_AUTH_OBSOLETE_PROXY_AUTHZ;
}
- li->li_idassert_flags |= LDAP_BACK_AUTH_OBSOLETE_PROXY_AUTHZ;
} else if ( strcasecmp( flags[ j ], "obsolete-encoding-workaround" ) == 0 ) {
if ( li->li_idassert_flags & LDAP_BACK_AUTH_OBSOLETE_PROXY_AUTHZ ) {
"in \"idassert-mode <args>\" "
"incompatible with previously issued \"obsolete-proxy-authz\" flag.\n",
c->fname, c->lineno, 0 );
- return 1;
+ err = 1;
+ break;
+
+ } else {
+ li->li_idassert_flags |= LDAP_BACK_AUTH_OBSOLETE_ENCODING_WORKAROUND;
}
- li->li_idassert_flags |= LDAP_BACK_AUTH_OBSOLETE_ENCODING_WORKAROUND;
} else {
snprintf( c->msg, sizeof( c->msg ),
"unknown flag \"%s\"",
flags[ j ] );
Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
- ldap_charray_free( flags );
- return 1;
+ err = 1;
+ break;
}
}
ldap_charray_free( flags );
+ if ( err ) {
+ return 1;
+ }
} else if ( bindconf_parse( c->argv[ i ], &li->li_idassert ) ) {
return 1;
metatarget_t *mt = &mi->mi_targets[ i ];
metasingleconn_t *msc = &mc->mc_conns[ i ];
int rc, do_retry = 1;
- char *rootdn = NULL;
/*
* Not a candidate
snprintf( buf, sizeof( buf ),
"meta_back_dobind[%d]: (%s) err=%d (%s).",
- i, rootdn ? rootdn : "anonymous",
+ i, isroot ? op->o_bd->be_rootdn.bv_val : "anonymous",
rc, ldap_err2string( rc ) );
Debug( LDAP_DEBUG_ANY,
"%s %s\n",
"%s meta_back_dobind[%d]: "
"(%s)\n",
op->o_log_prefix, i,
- rootdn ? rootdn : "anonymous" );
+ isroot ? op->o_bd->be_rootdn.bv_val : "anonymous" );
ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
LDAP_BACK_CONN_BINDING_CLEAR( msc );
- if ( rootdn ) {
+ if ( isroot ) {
LDAP_BACK_CONN_ISBOUND_SET( msc );
} else {
LDAP_BACK_CONN_ISANON_SET( msc );
ber_bvnone = BER_BVC( "(?=none)" );
ber_len_t len;
+ assert( fstr != NULL );
+ BER_BVZERO( fstr );
+
if ( f == NULL ) {
ber_dupbv( fstr, &ber_bvnone );
return LDAP_OTHER;
#include "slap.h"
#include "rwm.h"
+static int
+rwm_db_destroy( BackendDB *be );
+
static int
rwm_op_dn_massage( Operation *op, SlapReply *rs, void *cookie )
{
static int
rwm_rw_config(
- BackendDB *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
+ BackendDB *be,
+ const char *fname,
+ int lineno,
+ int argc,
+ char **argv )
{
#ifdef ENABLE_REWRITE
slap_overinst *on = (slap_overinst *) be->bd_info;
static int
rwm_suffixmassage_config(
- BackendDB *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
+ BackendDB *be,
+ const char *fname,
+ int lineno,
+ int argc,
+ char **argv )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
struct ldaprwmap *rwmap =
static int
rwm_m_config(
- BackendDB *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
+ BackendDB *be,
+ const char *fname,
+ int lineno,
+ int argc,
+ char **argv )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
struct ldaprwmap *rwmap =
static int
rwm_db_config(
- BackendDB *be,
- const char *fname,
- int lineno,
- int argc,
- char **argv
-)
+ BackendDB *be,
+ const char *fname,
+ int lineno,
+ int argc,
+ char **argv )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
struct ldaprwmap *rwmap =
static int
rwm_db_init(
- BackendDB *be
-)
+ BackendDB *be )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
struct ldapmapping *mapping = NULL;
#ifdef ENABLE_REWRITE
char *rargv[ 3 ];
#endif /* ENABLE_REWRITE */
+ int rc = 0;
rwmap = (struct ldaprwmap *)ch_calloc( 1, sizeof( struct ldaprwmap ) );
#ifdef ENABLE_REWRITE
rwmap->rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
if ( rwmap->rwm_rw == NULL ) {
- ch_free( rwmap );
- return -1;
+ rc = -1;
+ goto error_return;
}
/* this rewriteContext by default must be null;
if ( rwm_map_init( &rwmap->rwm_oc, &mapping ) != LDAP_SUCCESS ||
rwm_map_init( &rwmap->rwm_at, &mapping ) != LDAP_SUCCESS )
{
- return 1;
+ rc = 1;
+ goto error_return;
}
+error_return:;
on->on_bi.bi_private = (void *)rwmap;
- return 0;
+ if ( rc ) {
+ (void)rwm_db_destroy( be );
+ }
+
+ return rc;
}
static int
rwm_db_destroy(
- BackendDB *be
-)
+ BackendDB *be )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
int rc = 0;
static slap_overinst rwm = { { NULL } };
+#if SLAPD_OVER_RWM == SLAPD_MOD_DYNAMIC
+static
+#endif /* SLAPD_OVER_RWM == SLAPD_MOD_DYNAMIC */
int
-rwm_initialize(void)
+rwm_initialize( void )
{
memset( &rwm, 0, sizeof( slap_overinst ) );
/* FIXME: I don't think this is needed any more... */
rc = slap_str2ad( "objectClass", &mapping[0].m_src_ad, &text );
if ( rc != LDAP_SUCCESS ) {
+ ch_free( mapping );
return rc;
}
Avlnode *tree;
struct ldapmapping fmapping;
+ if ( map == NULL ) {
+ return 0;
+ }
+
assert( m != NULL );
if ( remap == RWM_REMAP ) {
*/
int
rwm_map_attrnames(
- struct ldapmap *at_map,
- struct ldapmap *oc_map,
- AttributeName *an,
- AttributeName **anp,
- int remap
-)
+ struct ldapmap *at_map,
+ struct ldapmap *oc_map,
+ AttributeName *an,
+ AttributeName **anp,
+ int remap )
{
int i, j;
at_drop_missing = rwm_mapping( at_map, &an[i].an_name, &m, remap );
if ( at_drop_missing || !m ) {
-
oc_drop_missing = rwm_mapping( oc_map, &an[i].an_name, &m, remap );
/* if both at_map and oc_map required to drop missing,
if ( j == 0 && i != 0 ) {
memset( &(*anp)[0], 0, sizeof( AttributeName ) );
BER_BVSTR( &(*anp)[0].an_name, LDAP_NO_ATTRS );
+ j = 1;
}
memset( &(*anp)[j], 0, sizeof( AttributeName ) );
int
rwm_map_attrs(
- struct ldapmap *at_map,
- AttributeName *an,
- int remap,
- char ***mapped_attrs
-)
+ struct ldapmap *at_map,
+ AttributeName *an,
+ int remap,
+ char ***mapped_attrs )
{
int i, j;
char **na;
return LDAP_SUCCESS;
}
- for ( i = 0; !BER_BVISNULL( &an[ i ].an_name ); i++ ) {
- /* */
- }
+ for ( i = 0; !BER_BVISNULL( &an[ i ].an_name ); i++ )
+ /* count'em */ ;
na = (char **)ch_calloc( i + 1, sizeof( char * ) );
if ( na == NULL ) {
static int
map_attr_value(
- dncookie *dc,
- AttributeDescription **adp,
- struct berval *mapped_attr,
- struct berval *value,
- struct berval *mapped_value,
- int remap )
+ dncookie *dc,
+ AttributeDescription **adp,
+ struct berval *mapped_attr,
+ struct berval *value,
+ struct berval *mapped_value,
+ int remap )
{
struct berval vtmp = BER_BVNULL;
int freeval = 0;
static int
rwm_int_filter_map_rewrite(
- Operation *op,
- dncookie *dc,
- Filter *f,
- struct berval *fstr )
+ Operation *op,
+ dncookie *dc,
+ Filter *f,
+ struct berval *fstr )
{
int i;
Filter *p;
ber_bvnone = BER_BVC( "(?=none)" );
ber_len_t len;
+ assert( fstr != NULL );
+ BER_BVZERO( fstr );
+
if ( f == NULL ) {
ber_dupbv( fstr, &ber_bvnone );
return LDAP_OTHER;
int
rwm_filter_map_rewrite(
- Operation *op,
- dncookie *dc,
- Filter *f,
- struct berval *fstr )
+ Operation *op,
+ dncookie *dc,
+ Filter *f,
+ struct berval *fstr )
{
int rc;
dncookie fdc;
int
rwm_referral_result_rewrite(
dncookie *dc,
- BerVarray a_vals
-)
+ BerVarray a_vals )
{
int i, last;
int
rwm_dnattr_result_rewrite(
dncookie *dc,
- BerVarray a_vals
-)
+ BerVarray a_vals )
{
int i, last;