]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/passwd.c
slight improvements; doesn't work yet
[openldap] / servers / slapd / passwd.c
index 5b9fcf61b730fff80cff3c15381da5e1e847accb..2faa368c3c04de7f0344f97ffd03a4b7dc658c31 100644 (file)
@@ -168,7 +168,7 @@ int passwd_extop(
        }
        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";
@@ -183,25 +183,7 @@ int passwd_extop(
        ml->sml_op = qpw->rs_old.bv_val ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
        ml->sml_next = qpw->rs_mods;
        qpw->rs_mods = ml;
-       if ( qpw->rs_old.bv_val ) {
-               ml = ch_malloc( sizeof(Modifications) );
-               ml->sml_values = ch_malloc( (nhash+1)*sizeof(struct berval) );
-               for ( i=0; hashes[i]; i++ ) {
-                       slap_passwd_hash( hashes[i], &qpw->rs_old, &hash, &rs->sr_text );
-                       if ( hash.bv_len == 0 ) {
-                               if ( !rs->sr_text ) {
-                                       rs->sr_text = "password hash failed";
-                               }
-                               break;
-                       }
-                       ml->sml_values[i] = hash;
-               }
-               ml->sml_values[i].bv_val = NULL;
-               ml->sml_desc = slap_schema.si_ad_userPassword;
-               ml->sml_op = LDAP_MOD_DELETE;
-               ml->sml_next = qpw->rs_mods;
-               qpw->rs_mods = ml;
-       }
+
        if ( hashes[i] ) {
                rs->sr_err = LDAP_OTHER;
        } else {
@@ -473,23 +455,16 @@ slap_passwd_generate( struct berval *pass )
 }
 
 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;
 
-       if ( !hash ) {
-               if ( default_passwd_hash ) {
-                       hash = default_passwd_hash[0];
-               }
-               if ( !hash ) {
-                       hash = (char *)defhash[0];
-               }
-       }
+       assert( hash );
 
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
        ldap_pvt_thread_mutex_lock( &passwd_mutex );
@@ -502,3 +477,19 @@ slap_passwd_hash(
 #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 );
+}