]> git.sur5r.net Git - openldap/commitdiff
merge changes from authPassword work which should fix SPASSWD code...
authorKurt Zeilenga <kurt@openldap.org>
Wed, 20 Sep 2000 00:28:57 +0000 (00:28 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 20 Sep 2000 00:28:57 +0000 (00:28 +0000)
servers/slapd/back-ldbm/bind.c
servers/slapd/backend.c
servers/slapd/init.c
servers/slapd/passwd.c
servers/slapd/proto-slap.h
servers/slapd/sasl.c

index 73dddc18bb913052736c9e2ff065dad143fc8d1b..7025dd318ae12d5585112d496f0b833512982853 100644 (file)
@@ -165,7 +165,7 @@ ldbm_back_bind(
                        goto return_results;
                }
 
-               if ( slap_passwd_check( a, cred ) != 0 ) {
+               if ( slap_passwd_check( conn, a, cred ) != 0 ) {
                        send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
                                NULL, NULL, NULL, NULL );
                        /* stop front end from sending result */
index 67f45256abd92e9ebd885465d3e54ed342218dd5..0dad539936c0a9919776ef56456ac850e44f4551 100644 (file)
@@ -516,14 +516,17 @@ be_isroot_pw( Backend *be, const char *ndn, struct berval *cred )
                return 0;
        }
 
-#ifdef SLAPD_CRYPT
-       ldap_pvt_thread_mutex_lock( &crypt_mutex );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+       ldap_pvt_thread_mutex_lock( &passwd_mutex );
+#ifdef SLAPD_SPASSWD
+       lutil_passwd_sasl_conn = conn->c_sasl_context;
+#endif
 #endif
 
        result = lutil_passwd( &be->be_root_pw, cred, NULL );
 
-#ifdef SLAPD_CRYPT
-       ldap_pvt_thread_mutex_unlock( &crypt_mutex );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+       ldap_pvt_thread_mutex_unlock( &passwd_mutex );
 #endif
 
        return result == 0;
index 5c41461dff564551cc0b36ba44e0c3e1dafe3591..69f64d4b7a32f8feb02e8267215c83178376c003 100644 (file)
@@ -40,8 +40,8 @@ char          **g_argv;
  */
 ldap_pvt_thread_pool_t connection_pool;
 ldap_pvt_thread_mutex_t        gmtime_mutex;
-#ifdef SLAPD_CRYPT
-ldap_pvt_thread_mutex_t        crypt_mutex;
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+ldap_pvt_thread_mutex_t        passwd_mutex;
 #endif
 
 int                            num_conns;
@@ -103,8 +103,8 @@ slap_init( int mode, const char *name )
                        ldap_pvt_thread_mutex_init( &num_sent_mutex );
 
                        ldap_pvt_thread_mutex_init( &gmtime_mutex );
-#ifdef SLAPD_CRYPT
-                       ldap_pvt_thread_mutex_init( &crypt_mutex );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+                       ldap_pvt_thread_mutex_init( &passwd_mutex );
 #endif
 
                        rc = slap_sasl_init();
index 547fb44c221b936a1cbbde76d458645347431e57..39ffb398bc194184d09485314faf25e2d37c7004 100644 (file)
@@ -217,28 +217,32 @@ struct berval * slap_passwd_return(
 
 int
 slap_passwd_check(
+       Connection *conn,
        Attribute *a,
        struct berval *cred )
 {
        int     i;
-       for ( i = 0; a->a_vals[i] != NULL; i++ ) {
-               int result;
+       int result = 1;
 
-#ifdef SLAPD_CRYPT
-               ldap_pvt_thread_mutex_lock( &crypt_mutex );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+       ldap_pvt_thread_mutex_lock( &crypt_mutex );
+#ifdef SLAPD_SPASSWD
+       lutil_passwd_sasl_conn = conn->c_sasl_context;
 #endif
-
-               result = lutil_passwd( a->a_vals[i], cred, NULL );
-
-#ifdef SLAPD_CRYPT
-               ldap_pvt_thread_mutex_unlock( &crypt_mutex );
 #endif
 
-               if( !result )
-                       return result;
+       for ( i = 0; a->a_vals[i] != NULL; i++ ) {
+               if( !lutil_passwd( a->a_vals[i], cred, NULL ) ) {
+                       result = 0;
+                       break;
+               }
        }
 
-       return( 1 );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+       ldap_pvt_thread_mutex_unlock( &passwd_mutex );
+#endif
+
+       return result;
 }
 
 struct berval * slap_passwd_generate( void )
@@ -259,14 +263,14 @@ struct berval * slap_passwd_hash(
 
        struct berval *new;
 
-#ifdef SLAPD_CRYPT
-       ldap_pvt_thread_mutex_lock( &crypt_mutex );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+       ldap_pvt_thread_mutex_lock( &passwd_mutex );
 #endif
 
        new = lutil_passwd_hash( cred , hash );
        
-#ifdef SLAPD_CRYPT
-       ldap_pvt_thread_mutex_unlock( &crypt_mutex );
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_PASSWD )
+       ldap_pvt_thread_mutex_unlock( &passwd_mutex );
 #endif
 
        return new;
index 480ac3e021f17a27be50d1e3dcfafe54a9fab4a2..bc0ac1db888bd6b494090fb17b90d130183beb39 100644 (file)
@@ -727,6 +727,7 @@ LDAP_SLAPD_F (int) passwd_extop LDAP_P((
        struct berval *** refs ));
 
 LDAP_SLAPD_F (int) slap_passwd_check(
+       Connection                      *conn,
        Attribute                       *attr,
        struct berval           *cred );
 
@@ -804,8 +805,8 @@ LDAP_SLAPD_F (ldap_pvt_thread_pool_t)       connection_pool;
 LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) entry2str_mutex;
 LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) replog_mutex;
 
-#ifdef SLAPD_CRYPT
-LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) crypt_mutex;
+#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
+LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) passwd_mutex;
 #endif
 LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) gmtime_mutex;
 
index f776f7d44d86b496757b77421742294833121fc6..3a37c5d8ca81b0fed6b685a737df14e97bcd9248 100644 (file)
@@ -203,11 +203,7 @@ int slap_sasl_init( void )
     sasl_secprops.maxbufsize = 65536;
     sasl_secprops.security_flags = SASL_SEC_NOPLAINTEXT|SASL_SEC_NOANONYMOUS;
 
-#ifdef SLAPD_SPASSWD
-       lutil_passwd_sasl_conn = server;
-#else
        sasl_dispose( &server );
-#endif
 
 #endif
        return 0;
@@ -216,9 +212,6 @@ int slap_sasl_init( void )
 int slap_sasl_destroy( void )
 {
 #ifdef HAVE_CYRUS_SASL
-#ifdef SLAPD_SPASSWD
-       sasl_dispose( &lutil_passwd_sasl_conn );
-#endif
        sasl_done();
 #endif
        return 0;