]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/add.c
Remove extensible filter #ifdef
[openldap] / servers / slapd / add.c
index 86030d638e2e95f52482476162639cd58fe5ad5d..f8f220aed695b1a81aee13479498d47304531092 100644 (file)
@@ -44,9 +44,14 @@ do_add( Connection *conn, Operation *op )
        Modifications *mods = NULL;
        const char *text;
        int                     rc = LDAP_SUCCESS;
+       int     manageDSAit;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
+                  "do_add: conn %d enter\n", conn->c_connid ));
+#else
        Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
-
+#endif
        /*
         * Parse the add request.  It looks like this:
         *
@@ -61,7 +66,12 @@ do_add( Connection *conn, Operation *op )
 
        /* get the name */
        if ( ber_scanf( ber, "{a", /*}*/ &dn ) == LBER_ERROR ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "do_add: conn %d ber_scanf failed\n", conn->c_connid ));
+#else
                Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
+#endif
                send_ldap_disconnect( conn, op,
                        LDAP_PROTOCOL_ERROR, "decoding error" );
                return -1;
@@ -70,7 +80,12 @@ do_add( Connection *conn, Operation *op )
        ndn = ch_strdup( dn );
 
        if ( dn_normalize( ndn ) == NULL ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "do_add: conn %d      invalid dn (%s)\n", conn->c_connid, dn ));
+#else
                Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn, 0, 0 );
+#endif
                send_ldap_result( conn, op, LDAP_INVALID_DN_SYNTAX, NULL,
                    "invalid DN", NULL, NULL );
                free( dn );
@@ -85,7 +100,12 @@ do_add( Connection *conn, Operation *op )
        e->e_attrs = NULL;
        e->e_private = NULL;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
+                  "do_add: conn %d  ndn (%s)\n", conn->c_connid, e->e_ndn ));
+#else
        Debug( LDAP_DEBUG_ARGS, "do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
+#endif
 
        /* get the attrs */
        for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
@@ -98,7 +118,12 @@ do_add( Connection *conn, Operation *op )
                rc = ber_scanf( ber, "{a{V}}", &mod->ml_type, &mod->ml_bvalues );
 
                if ( rc == LBER_ERROR ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                                  "do_add: conn %d      decoding error \n", conn->c_connid ));
+#else
                        Debug( LDAP_DEBUG_ANY, "do_add: decoding error\n", 0, 0, 0 );
+#endif
                        send_ldap_disconnect( conn, op,
                                LDAP_PROTOCOL_ERROR, "decoding error" );
                        rc = -1;
@@ -107,8 +132,14 @@ do_add( Connection *conn, Operation *op )
                }
 
                if ( mod->ml_bvalues == NULL ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
+                                  "do_add: conn %d      no values for type %s\n",
+                                  conn->c_connid, mod->ml_type ));
+#else
                        Debug( LDAP_DEBUG_ANY, "no values for type %s\n",
                                mod->ml_type, 0, 0 );
+#endif
                        send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
                                NULL, "no values for attribute type", NULL, NULL );
                        free( mod->ml_type );
@@ -121,7 +152,12 @@ do_add( Connection *conn, Operation *op )
        }
 
        if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "do_add: conn %d      ber_scanf failed\n", conn->c_connid ));
+#else
                Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
+#endif
                send_ldap_disconnect( conn, op,
                        LDAP_PROTOCOL_ERROR, "decoding error" );
                rc = -1;
@@ -129,7 +165,12 @@ do_add( Connection *conn, Operation *op )
        }
 
        if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
+                          "do_add: conn %d      get_ctrls failed\n", conn->c_connid ));
+#else
                Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
+#endif
                goto done;
        } 
 
@@ -149,12 +190,15 @@ do_add( Connection *conn, Operation *op )
                goto done;
        }
 
+       manageDSAit = get_manageDSAit( op ) &&
+               is_entry_referral( e );
+
        /*
         * We could be serving multiple database backends.  Select the
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       be = select_backend( e->e_ndn );
+       be = select_backend( e->e_ndn, manageDSAit );
        if ( be == NULL ) {
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        NULL, NULL, default_referral, NULL );
@@ -183,28 +227,27 @@ do_add( Connection *conn, Operation *op )
         */
        if ( be->be_add ) {
                /* do the update here */
-#ifdef SLAPD_MULTIMASTER
-               if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
-                       global_lastmod == ON)) && (be->be_update_ndn == NULL ||
-                       strcmp( be->be_update_ndn, op->o_ndn )) )
-#else
-               if ( be->be_update_ndn == NULL ||
-                       strcmp( be->be_update_ndn, op->o_ndn ) == 0 )
+               int repl_user = (be->be_update_ndn != NULL &&
+                       strcmp( be->be_update_ndn, op->o_ndn ) == 0);
+#ifndef SLAPD_MULTIMASTER
+               if ( be->be_update_ndn == NULL || repl_user )
 #endif
                {
                        int update = be->be_update_ndn != NULL;
+                       char textbuf[SLAP_TEXT_BUFLEN];
+                       size_t textlen = sizeof textbuf;
+
+                       rc = slap_modlist2mods( modlist, update, &mods, &text,
+                               textbuf, textlen );
 
-                       rc = slap_modlist2mods( modlist, update, &mods, &text );
                        if( rc != LDAP_SUCCESS ) {
                                send_ldap_result( conn, op, rc,
                                        NULL, text, NULL, NULL );
                                goto done;
                        }
 
-#ifndef SLAPD_MULTIMASTER
                        if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
-                               global_lastmod == ON)) && !update )
-#endif
+                               global_lastmod == ON)) && !repl_user )
                        {
                                Modifications **modstail;
                                for( modstail = &mods;
@@ -231,8 +274,7 @@ do_add( Connection *conn, Operation *op )
 
                        if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
 #ifdef SLAPD_MULTIMASTER
-                               if (be->be_update_ndn == NULL ||
-                                       strcmp( be->be_update_ndn, op->o_ndn ))
+                               if ( !repl_user )
 #endif
                                {
                                        replog( be, op, e->e_dn, e );
@@ -248,9 +290,14 @@ do_add( Connection *conn, Operation *op )
 #endif
                }
        } else {
-           Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
-               send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
-                       NULL, "operation not supported within namingContext", NULL, NULL );
+#ifdef NEW_LOGGING
+           LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
+                      "do_add: conn %d  no backend support\n", conn->c_connid ));
+#else
+           Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
+#endif
+           send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
+                             NULL, "operation not supported within namingContext", NULL, NULL );
        }
 
 done: