]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-passwd/search.c
ITS#3607 add automatic BDB recovery
[openldap] / servers / slapd / back-passwd / search.c
index eb48f6a9e8f62cdc16c20e09c626b77928bbfcd3..ab2c7c1a2262af6289fd10dcf39a556db774de9f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2003 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,6 @@
 
 #include "slap.h"
 #include "back-passwd.h"
-#include <ldap_pvt.h>
 
 static void pw_start( Backend *be );
 
@@ -65,15 +64,13 @@ passwd_back_search(
        time_t          stoptime;
 
        LDAPRDN rdn = NULL;
-       struct berval parent = { 0, NULL };
+       struct berval parent = BER_BVNULL;
 
        AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
 
-       op->oq_search.rs_tlimit = (op->oq_search.rs_tlimit > op->o_bd->be_timelimit || op->oq_search.rs_tlimit < 1) ? op->o_bd->be_timelimit
-           : op->oq_search.rs_tlimit;
-       stoptime = op->o_time + op->oq_search.rs_tlimit;
-       op->oq_search.rs_slimit = (op->oq_search.rs_slimit > op->o_bd->be_sizelimit || op->oq_search.rs_slimit < 1) ? op->o_bd->be_sizelimit
-           : op->oq_search.rs_slimit;
+       if (op->ors_tlimit != SLAP_NO_LIMIT ) {
+               stoptime = op->o_time + op->ors_tlimit;
+       }
 
        /* Handle a query for the base of this backend */
        if ( be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
@@ -83,7 +80,7 @@ passwd_back_search(
 
                rs->sr_matched = op->o_req_dn.bv_val;
 
-               if( op->oq_search.rs_scope != LDAP_SCOPE_ONELEVEL ) {
+               if( op->ors_scope != LDAP_SCOPE_ONELEVEL ) {
                        AttributeDescription *desc = NULL;
 
                        /* Create an entry corresponding to the base DN */
@@ -128,14 +125,15 @@ passwd_back_search(
                        vals[0].bv_len = sizeof("organizationalUnit")-1;
                        attr_mergeit( e, ad_objectClass, vals );
        
-                       if ( test_filter( op, e, op->oq_search.rs_filter ) == LDAP_COMPARE_TRUE ) {
+                       if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
                                rs->sr_entry = e;
-                               rs->sr_attrs = op->oq_search.rs_attrs;
+                               rs->sr_attrs = op->ors_attrs;
+                               rs->sr_flags = REP_ENTRY_MODIFIABLE;
                                send_search_entry( op, rs );
                        }
                }
 
-               if ( op->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
+               if ( op->ors_scope != LDAP_SCOPE_BASE ) {
                        /* check all our "children" */
 
                        ldap_pvt_thread_mutex_lock( &passwd_mutex );
@@ -145,11 +143,13 @@ passwd_back_search(
                                if ( op->o_abandon ) {
                                        endpwent();
                                        ldap_pvt_thread_mutex_unlock( &passwd_mutex );
-                                       return( -1 );
+                                       return( SLAPD_ABANDON );
                                }
 
                                /* check time limit */
-                               if ( slap_get_time() > stoptime ) {
+                               if ( op->ors_tlimit != SLAP_NO_LIMIT
+                                               && slap_get_time() > stoptime )
+                               {
                                        send_ldap_error( op, rs, LDAP_TIMELIMIT_EXCEEDED, NULL );
                                        endpwent();
                                        ldap_pvt_thread_mutex_unlock( &passwd_mutex );
@@ -163,9 +163,9 @@ passwd_back_search(
                                        goto done;
                                }
 
-                               if ( test_filter( op, e, op->oq_search.rs_filter ) == LDAP_COMPARE_TRUE ) {
+                               if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
                                        /* check size limit */
-                                       if ( --op->oq_search.rs_slimit == -1 ) {
+                                       if ( --op->ors_slimit == -1 ) {
                                                send_ldap_error( op, rs, LDAP_SIZELIMIT_EXCEEDED, NULL );
                                                endpwent();
                                                ldap_pvt_thread_mutex_unlock( &passwd_mutex );
@@ -173,7 +173,8 @@ passwd_back_search(
                                        }
 
                                        rs->sr_entry = e;
-                                       rs->sr_attrs = op->oq_search.rs_attrs;
+                                       rs->sr_attrs = op->ors_attrs;
+                                       rs->sr_flags = REP_ENTRY_MODIFIABLE;
                                        send_search_entry( op, rs );
                                }
 
@@ -203,7 +204,7 @@ passwd_back_search(
                        goto done;
                }
 
-               if( op->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL ) {
+               if( op->ors_scope == LDAP_SCOPE_ONELEVEL ) {
                        goto done;
                }
 
@@ -230,9 +231,10 @@ passwd_back_search(
                        goto done;
                }
 
-               if ( test_filter( op, e, op->oq_search.rs_filter ) == LDAP_COMPARE_TRUE ) {
+               if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
                        rs->sr_entry = e;
-                       rs->sr_attrs = op->oq_search.rs_attrs;
+                       rs->sr_attrs = op->ors_attrs;
+                       rs->sr_flags = REP_ENTRY_MODIFIABLE;
                        send_search_entry( op, rs );
                }