]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/add.c
Fix negative caching again, be sure it's really from zero entries returned
[openldap] / servers / slapd / add.c
index 6bfebbd7c878db5642cdf3a30b89425ab248aa0c..0f3f09a7ed58b0a5f8b9105b3d055e4c32070656 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -216,7 +216,7 @@ fe_op_add( Operation *op, SlapReply *rs )
        int             manageDSAit;
        Modifications   **modtail = &op->ora_modlist;
        int             rc = 0;
-       BackendDB       *op_be;
+       BackendDB       *op_be, *bd = op->o_bd;
        char            textbuf[ SLAP_TEXT_BUFLEN ];
        size_t          textlen = sizeof( textbuf );
 
@@ -229,23 +229,20 @@ fe_op_add( Operation *op, SlapReply *rs )
         */
        op->o_bd = select_backend( &op->ora_e->e_nname, manageDSAit, 1 );
        if ( op->o_bd == NULL ) {
+               op->o_bd = bd;
                rs->sr_ref = referral_rewrite( default_referral,
                        NULL, &op->ora_e->e_name, LDAP_SCOPE_DEFAULT );
                if ( !rs->sr_ref ) rs->sr_ref = default_referral;
                if ( rs->sr_ref ) {
                        rs->sr_err = LDAP_REFERRAL;
-                       op->o_bd = frontendDB;
                        send_ldap_result( op, rs );
-                       op->o_bd = NULL;
 
                        if ( rs->sr_ref != default_referral ) {
                                ber_bvarray_free( rs->sr_ref );
                        }
                } else {
-                       op->o_bd = frontendDB;
                        send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                                "no global superior knowledge" );
-                       op->o_bd = NULL;
                }
                goto done;
        }
@@ -372,12 +369,13 @@ fe_op_add( Operation *op, SlapReply *rs )
 #endif /* SLAPD_MULTIMASTER */
                }
        } else {
-           Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
-           send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+               Debug( LDAP_DEBUG_ARGS, "do_add: no backend support\n", 0, 0, 0 );
+               send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
                        "operation not supported within namingContext" );
        }
 
 done:;
+       op->o_bd = bd;
        return rc;
 }
 
@@ -668,9 +666,9 @@ int slap_add_opattrs(
                ptr = ber_bvchr( &csn, '#' );
                if ( ptr ) {
                        timestamp.bv_len = ptr - csn.bv_val;
-                       if ( timestamp.bv_len >= sizeof(timebuf) )
+                       if ( timestamp.bv_len >= sizeof(timebuf) )      /* ?!? */
                                timestamp.bv_len = sizeof(timebuf) - 1;
-                       strncpy( timebuf, csn.bv_val, timestamp.bv_len );
+                       AC_MEMCPY( timebuf, csn.bv_val, timestamp.bv_len );
                        timebuf[timestamp.bv_len] = '\0';
                } else {
                        time_t now = slap_get_time();
@@ -734,7 +732,6 @@ int slap_add_opattrs(
                        attr_merge_one( op->ora_e,
                                slap_schema.si_ad_modifyTimestamp, &timestamp, NULL );
                }
-
        }
        return LDAP_SUCCESS;
 }