From db52f51943cc9ea3ef1c7c1270616d0542895ae3 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 15 Mar 2004 20:58:41 +0000 Subject: [PATCH] Preserve old slap_passwd_hash() signature, add slap_passwd_hash_type() --- servers/slapd/passwd.c | 33 +++++++++++++++++++++------------ servers/slapd/proto-slap.h | 7 ++++++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index 5b9fcf61b7..3538036592 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -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"; @@ -187,7 +187,7 @@ int passwd_extop( 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 ); + slap_passwd_hash_type( &qpw->rs_old, &hash, hashes[i], &rs->sr_text ); if ( hash.bv_len == 0 ) { if ( !rs->sr_text ) { rs->sr_text = "password hash failed"; @@ -473,23 +473,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 +495,19 @@ slap_passwd_hash( #endif } +void +slap_passwd_hash( + struct berval * cred, + struct berval * new, + const char **text ) +{ + char *hash; + if ( default_passwd_hash ) { + hash = default_passwd_hash[0]; + } + if ( !hash ) { + hash = (char *)defhash[0]; + } + + slap_passwd_hash_type( cred, new, hash, text ); +} diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 7c4dbdec2d..f8b050a9d5 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -864,11 +864,16 @@ LDAP_SLAPD_F (int) slap_passwd_check( LDAP_SLAPD_F (void) slap_passwd_generate( struct berval * ); LDAP_SLAPD_F (void) slap_passwd_hash( - char *type, struct berval *cred, struct berval *hash, const char **text ); +LDAP_SLAPD_F (void) slap_passwd_hash_type( + struct berval *cred, + struct berval *hash, + char *htype, + const char **text ); + LDAP_SLAPD_F (struct berval *) slap_passwd_return( struct berval *cred ); -- 2.39.5