]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/passwd.c
reject registrations when back-monitor is not configured
[openldap] / servers / slapd / passwd.c
index 270b1148b21e920f1d56f9877d7f2d002eece78d..3d63e447fe2bf3bc7113e3102aa834c0c8ccfb8d 100644 (file)
@@ -62,6 +62,8 @@ int passwd_extop(
        assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) == 0 );
 
        if( op->o_dn.bv_len == 0 ) {
+               Statslog( LDAP_DEBUG_STATS, "%s PASSMOD\n",
+                       op->o_log_prefix, 0, 0, 0, 0 );
                rs->sr_text = "only authenticated users may change passwords";
                return LDAP_STRONG_AUTH_REQUIRED;
        }
@@ -74,6 +76,16 @@ int passwd_extop(
        rs->sr_err = slap_passwd_parse( op->ore_reqdata, &id, &qpw->rs_old,
                &qpw->rs_new, &rs->sr_text );
 
+       if ( rs->sr_err == LDAP_SUCCESS && !BER_BVISEMPTY( &id ) ) {
+               Statslog( LDAP_DEBUG_STATS, "%s PASSMOD id=\"%s\"%s%s\n",
+                       op->o_log_prefix, id.bv_val,
+                       qpw->rs_old.bv_val ? " old" : "",
+                       qpw->rs_new.bv_val ? " new" : "", 0 );
+       } else {
+               Statslog( LDAP_DEBUG_STATS, "%s PASSMOD\n",
+                       op->o_log_prefix, 0, 0, 0, 0 );
+       }
+
        if ( rs->sr_err != LDAP_SUCCESS ) {
                return rs->sr_err;
        }
@@ -213,6 +225,7 @@ int passwd_extop(
        ml->sml_nvalues = NULL;
        ml->sml_desc = slap_schema.si_ad_userPassword;
        ml->sml_op = LDAP_MOD_REPLACE;
+       ml->sml_flags = 0;
        ml->sml_next = qpw->rs_mods;
        qpw->rs_mods = ml;
 
@@ -242,7 +255,7 @@ int passwd_extop(
                op->o_tag = LDAP_REQ_EXTENDED;
                op->o_callback = sc;
        }
-       slap_mods_free( qpw->rs_mods );
+       slap_mods_free( qpw->rs_mods, 1 );
        if ( rsp ) {
                free( qpw->rs_new.bv_val );
        }
@@ -469,7 +482,7 @@ slap_passwd_hash_type(
        new->bv_len = 0;
        new->bv_val = NULL;
 
-       assert( hash );
+       assert( hash != NULL );
 
        lutil_passwd_hash( cred , hash, new, text );
 }
@@ -509,8 +522,10 @@ static int slapd_crypt( const char *key, const char *salt, char **hash )
                if ( hash ) {
                        *hash = ber_strdup( cr );
                        rc = LUTIL_PASSWD_OK;
+
+               } else {
+                       rc = strcmp( salt, cr ) ? LUTIL_PASSWD_ERR : LUTIL_PASSWD_OK;
                }
-               rc = strcmp( salt, cr ) ? LUTIL_PASSWD_ERR : LUTIL_PASSWD_OK;
        }
 
        ldap_pvt_thread_mutex_unlock( &passwd_mutex );