]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/passwd.c
cannot ignore old password when setting sasl password
[openldap] / servers / slapd / passwd.c
index 3d63e447fe2bf3bc7113e3102aa834c0c8ccfb8d..5ada68fa927588a9d9b045df1addbd9175b328c6 100644 (file)
@@ -73,8 +73,8 @@ int passwd_extop(
        qpw->rs_mods = NULL;
        qpw->rs_modtail = NULL;
 
-       rs->sr_err = slap_passwd_parse( op->ore_reqdata, &id, &qpw->rs_old,
-               &qpw->rs_new, &rs->sr_text );
+       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",
@@ -109,6 +109,12 @@ int passwd_extop(
        }
 
        if( op->o_bd == NULL ) {
+               if ( qpw->rs_old.bv_val != NULL ) {
+                       rs->sr_text = "unwilling to verify old password";
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto error_return;
+               }
+
 #ifdef HAVE_CYRUS_SASL
                rc = slap_sasl_setpass( op, rs );
 #else
@@ -200,6 +206,12 @@ int passwd_extop(
                goto error_return;
        }
 
+       if ( qpw->rs_old.bv_val != NULL ) {
+               rs->sr_text = "unwilling to verify old password";
+               rc = LDAP_UNWILLING_TO_PERFORM;
+               goto error_return;
+       }
+
        ml = ch_malloc( sizeof(Modifications) );
        if ( !qpw->rs_modtail ) qpw->rs_modtail = &ml->sml_next;
 
@@ -349,6 +361,15 @@ int slap_passwd_parse( struct berval *reqdata,
                        goto decoding_error;
                }
 
+               if( oldpass->bv_len == 0 ) {
+                       Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: OLD empty.\n",
+                               0, 0, 0 );
+
+                       *text = "old password value is empty";
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto done;
+               }
+
                tag = ber_peek_tag( ber, &len );
        }
 
@@ -371,6 +392,15 @@ int slap_passwd_parse( struct berval *reqdata,
                        goto decoding_error;
                }
 
+               if( newpass->bv_len == 0 ) {
+                       Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: NEW empty.\n",
+                               0, 0, 0 );
+
+                       *text = "new password value is empty";
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto done;
+               }
+
                tag = ber_peek_tag( ber, &len );
        }