#ifndef SLAPD_MULTIMASTER
/* This does not apply to multi-master case */
- if( op->o_bd->be_update_ndn.bv_len ) {
+ if(!( !SLAP_SHADOW( op->o_bd ) || be_isupdate( op ))) {
/* we SHOULD return a referral in this case */
- BerVarray defref = NULL;
- if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
- syncinfo_t *si;
- LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
- struct berval tmpbv;
- ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
- ber_bvarray_add( &defref, &tmpbv );
- }
- } else {
- defref = referral_rewrite( op->o_bd->be_update_refs,
+ BerVarray defref = op->o_bd->be_update_refs
+ ? op->o_bd->be_update_refs : default_referral;
+
+ if( defref != NULL ) {
+ rs->sr_ref = referral_rewrite( op->o_bd->be_update_refs,
NULL, NULL, LDAP_SCOPE_DEFAULT );
+ if(rs->sr_ref) {
+ rs->sr_flags |= REP_REF_MUSTBEFREED;
+ } else {
+ rs->sr_ref = defref;
+ }
+ return LDAP_REFERRAL;
+
}
- rs->sr_ref = defref;
- return LDAP_REFERRAL;
+
+ rs->sr_text = "shadow context; no update referral";
+ return LDAP_UNWILLING_TO_PERFORM;
}
#endif /* !SLAPD_MULTIMASTER */
}
ml->sml_values = ch_malloc( (nhash+1)*sizeof(struct berval) );
for ( i=0; hashes[i]; i++ ) {
- slap_passwd_hash( hashes[i], &qpw->rs_new, &hash, &rs->sr_text );
+ slap_passwd_hash_type( &qpw->rs_new, &hash, hashes[i], &rs->sr_text );
if ( hash.bv_len == 0 ) {
if ( !rs->sr_text ) {
rs->sr_text = "password hash failed";
ml->sml_op = LDAP_MOD_REPLACE;
ml->sml_next = qpw->rs_mods;
qpw->rs_mods = ml;
- if ( rsp ) {
- free( qpw->rs_new.bv_val );
- }
+
if ( hashes[i] ) {
rs->sr_err = LDAP_OTHER;
} else {
op2.o_tag = LDAP_REQ_MODIFY;
op2.o_callback = &cb2;
op2.orm_modlist = qpw->rs_mods;
+ cb2.sc_private = qpw; /* let Modify know this was pwdMod,
+ * if it cares... */
rs->sr_err = slap_mods_opattrs( &op2, ml, qpw->rs_modtail, &rs->sr_text,
NULL, 0 );
}
}
slap_mods_free( qpw->rs_mods );
+ if ( rsp ) {
+ free( qpw->rs_new.bv_val );
+ }
return rs->sr_err;
}
}
void
-slap_passwd_hash(
- char *hash,
+slap_passwd_hash_type(
struct berval * cred,
struct berval * new,
+ char *hash,
const char **text )
{
new->bv_len = 0;
new->bv_val = NULL;
+ assert( hash );
+
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_lock( &passwd_mutex );
#endif
#endif
}
+void
+slap_passwd_hash(
+ struct berval * cred,
+ struct berval * new,
+ const char **text )
+{
+ char *hash = NULL;
+ if ( default_passwd_hash ) {
+ hash = default_passwd_hash[0];
+ }
+ if ( !hash ) {
+ hash = (char *)defhash[0];
+ }
+
+ slap_passwd_hash_type( cred, new, hash, text );
+}