]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/bind.c
plug leaks
[openldap] / servers / slapd / back-bdb / bind.c
index 24e2d8d8921ce593fb8fdc3524eaf57c9084aae5..ef72666535b75a47de487bdc30968a08d836bee9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,6 @@
 #include <ac/unistd.h>
 
 #include "back-bdb.h"
-#include "external.h"
 
 int
 bdb_bind( Operation *op, SlapReply *rs )
@@ -43,13 +42,9 @@ bdb_bind( Operation *op, SlapReply *rs )
        u_int32_t       locker;
        DB_LOCK         lock;
 
-#ifdef NEW_LOGGING
-       LDAP_LOG ( OPERATION, ARGS,
-               "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0 );
-#else
        Debug( LDAP_DEBUG_ARGS,
-               "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0);
-#endif
+               "==> " LDAP_XSTRING(bdb_bind) ": dn: %s\n",
+               op->o_req_dn.bv_val, 0, 0);
 
        /* allow noauth binds */
        if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
@@ -93,31 +88,13 @@ dn2entry_retry:
        e = ei->bei_e;
        if ( rs->sr_err == DB_NOTFOUND ) {
                if( e != NULL ) {
-                       rs->sr_ref = is_entry_referral( e )
-                               ? get_entry_referrals( op, e )
-                               : NULL;
-                       if (rs->sr_ref) {
-                               rs->sr_matched = ch_strdup( e->e_name.bv_val );
-                               rs->sr_flags |= REP_MATCHED_MUSTBEFREED;
-                       }
-
                        bdb_cache_return_entry_r( bdb->bi_dbenv,
                                &bdb->bi_cache, e, &lock );
                        e = NULL;
-               } else {
-                       rs->sr_ref = referral_rewrite( default_referral,
-                               NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
                }
 
-               if ( rs->sr_ref != NULL ) {
-                       rs->sr_err = LDAP_REFERRAL;
-                       send_ldap_result( op, rs );
-                       ber_bvarray_free( rs->sr_ref );
-                       rs->sr_ref = NULL;
-               } else {
-                       rs->sr_err = LDAP_INVALID_CREDENTIALS;
-                       send_ldap_result( op, rs );
-               }
+               rs->sr_err = LDAP_INVALID_CREDENTIALS;
+               send_ldap_result( op, rs );
 
                LOCK_ID_FREE(bdb->bi_dbenv, locker);
 
@@ -127,93 +104,44 @@ dn2entry_retry:
        ber_dupbv( &op->oq_bind.rb_edn, &e->e_name );
 
        /* check for deleted */
-#ifdef BDB_SUBENTRIES
        if ( is_entry_subentry( e ) ) {
                /* entry is an subentry, don't allow bind */
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1, 
-                       "bdb_bind: entry is subentry\n", 0, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0,
                        0, 0 );
-#endif
-
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
                goto done;
        }
-#endif
 
-#ifdef BDB_ALIASES
        if ( is_entry_alias( e ) ) {
                /* entry is an alias, don't allow bind */
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1,
-                       "bdb_bind: entry is alias\n", 0, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
-#endif
-
-#if 1
                rs->sr_err = LDAP_INVALID_CREDENTIALS;
-#else
-               rs->sr_err = LDAP_ALIAS_PROBLEM;
-               rs->sr_text = "entry is alias";
-#endif
                goto done;
        }
-#endif
 
        if ( is_entry_referral( e ) ) {
-               /* entry is a referral, don't allow bind */
-               rs->sr_ref = get_entry_referrals( op, e );
-
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1, 
-                       "bdb_bind: entry is referral\n", 0, 0, 0 );
-#else
                Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
                        0, 0 );
-#endif
-
-               if( rs->sr_ref != NULL ) {
-                       rs->sr_err = LDAP_REFERRAL;
-                       rs->sr_matched = ch_strdup( e->e_name.bv_val );
-                       rs->sr_flags |= REP_MATCHED_MUSTBEFREED;
-               } else {
-                       rs->sr_err = LDAP_INVALID_CREDENTIALS;
-               }
+               rs->sr_err = LDAP_INVALID_CREDENTIALS;
                goto done;
        }
 
        switch ( op->oq_bind.rb_method ) {
        case LDAP_AUTH_SIMPLE:
-               rs->sr_err = access_allowed( op, e,
-                       password, NULL, ACL_AUTH, NULL );
-               if ( ! rs->sr_err ) {
-#if 1
+               a = attr_find( e->e_attrs, password );
+               if ( a == NULL ) {
                        rs->sr_err = LDAP_INVALID_CREDENTIALS;
-#else
-                       rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-#endif
                        goto done;
                }
 
-               if ( (a = attr_find( e->e_attrs, password )) == NULL ) {
-#if 1
-                       rs->sr_err = LDAP_INVALID_CREDENTIALS;
-#else
-                       rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
-#endif
-                       goto done;
-               }
-
-               if ( slap_passwd_check( op->o_conn,
-                       a, &op->oq_bind.rb_cred, &rs->sr_text ) != 0 )
+               if ( slap_passwd_check( op, e, a, &op->oq_bind.rb_cred,
+                                       &rs->sr_text ) != 0 )
                {
+                       /* failure; stop front end from sending result */
                        rs->sr_err = LDAP_INVALID_CREDENTIALS;
                        goto done;
                }
-
+                       
                rs->sr_err = 0;
                break;