]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-passwd/search.c
more fixes related to ITS#3499
[openldap] / servers / slapd / back-passwd / search.c
index 1bbe1dfed1049dd69a914546e3ca81b4eb47825c..21920b5847925f5de42269e3de55e998ae2c4d8f 100644 (file)
@@ -1,5 +1,36 @@
 /* search.c - /etc/passwd backend search function */
 /* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* Portions Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).  Additional significant contributors
+ * include:
+ *     Hallvard B. Furuseth
+ *     Howard Chu
+ *     Kurt D. Zeilenga
+ */
 
 #include "portable.h"
 
@@ -34,15 +65,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 ) ) {
@@ -52,7 +81,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 */
@@ -97,14 +126,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 );
@@ -118,7 +148,9 @@ passwd_back_search(
                                }
 
                                /* 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 );
@@ -132,9 +164,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 );
@@ -142,7 +174,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 );
                                }
 
@@ -172,7 +205,7 @@ passwd_back_search(
                        goto done;
                }
 
-               if( op->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL ) {
+               if( op->ors_scope == LDAP_SCOPE_ONELEVEL ) {
                        goto done;
                }
 
@@ -199,9 +232,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 );
                }
 
@@ -269,7 +303,7 @@ pw2entry( Backend *be, struct passwd *pw, const char **text )
        sprintf( vals[0].bv_val, "uid=%s,%s",
                pw->pw_name, be->be_suffix[0].bv_val );
 
-       rc = dnNormalize( 0, NULL, NULL, vals, &bv );
+       rc = dnNormalize( 0, NULL, NULL, vals, &bv, NULL );
        if( rc != LDAP_SUCCESS ) {
                free( vals[0].bv_val );
                return NULL;