]> git.sur5r.net Git - openldap/commitdiff
added new log; minor cleanup of rewrite stuff
authorPierangelo Masarati <ando@openldap.org>
Wed, 16 May 2001 22:55:44 +0000 (22:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 16 May 2001 22:55:44 +0000 (22:55 +0000)
servers/slapd/back-ldap/add.c
servers/slapd/back-ldap/bind.c
servers/slapd/back-ldap/compare.c
servers/slapd/back-ldap/delete.c
servers/slapd/back-ldap/group.c
servers/slapd/back-ldap/modify.c
servers/slapd/back-ldap/modrdn.c
servers/slapd/back-ldap/search.c
servers/slapd/back-ldap/unbind.c

index cccc79e2bae61f2cd9dec622bad034c2597dc6af..32fc5bb9102c4cd417a946a97f77707a4235d7a6 100644 (file)
@@ -60,6 +60,13 @@ ldap_back_add(
        LDAPMod **attrs;
        char *mdn = NULL, *mapped;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, "ldap_back_add: %s\n",
+                               e->e_dn ));
+#else /* !NEW_LOGGING */
+       Debug(LDAP_DEBUG_ARGS, "==> ldap_back_add: %s\n", e->e_dn, 0, 0);
+#endif /* !NEW_LOGGING */
+       
        lc = ldap_back_getconn(li, conn, op);
        if ( !lc || !ldap_back_dobind( lc, op ) ) {
                return( -1 );
@@ -71,18 +78,27 @@ ldap_back_add(
 #ifdef ENABLE_REWRITE
        switch (rewrite_session( li->rwinfo, "addDn", e->e_dn, conn, &mdn )) {
        case REWRITE_REGEXEC_OK:
-       if ( mdn == NULL ) {
+               if ( mdn == NULL ) {
                        mdn = e->e_dn;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                                       "[rw] addDn: \"%s\" -> \"%s\"\n",
+                                       e->e_dn, mdn ));                
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS, "rw> addDn: \"%s\" -> \"%s\"\n%s", 
                                e->e_dn, mdn, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               return( -1 );
                
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                return( -1 );
        }
 #else /* !ENABLE_REWRITE */
@@ -180,11 +196,18 @@ ldap_dnattr_rewrite(
                                /* no substitution */
                                continue;
                        }
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                                       "[rw] bindDn (in add of dn-valued"
+                                       " attr): \"%s\" -> \"%s\"\n",
+                                       a_vals[ j ]->bv_val, mattr ));
+#else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS,
                                        "rw> bindDn (in add of dn-valued attr):"
                                        " \"%s\" -> \"%s\"\n%s",
                                        a_vals[ j ]->bv_val, mattr, "" );
-                       
+#endif /* !NEW_LOGGING */
+
                        free( a_vals[ j ]->bv_val );
                        a_vals[ j ]->bv_val = mattr;
                        a_vals[ j ]->bv_len = strlen( mattr );
index 0a6c7aed00612c5dc98c25445863b65c34c78454..3f584d43fa5c83e81b3646287ea02b374b097645 100644 (file)
@@ -83,15 +83,23 @@ ldap_back_bind(
                if ( mdn == NULL ) {
                        mdn = ( char * )dn;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] bindDn: \"%s\" -> \"%s\"\n", dn, mdn ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n%s",
                                dn, mdn, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               return( -1 );
 
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                return( -1 );
        }
 #else /* !ENABLE_REWRITE */
@@ -239,11 +247,19 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                                        lc->bound_dn = 
                                                ch_strdup( lc->conn->c_cdn );
                                }
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                                               "[rw] bindDn: \"%s\" ->"
+                                               " \"%s\"\n%s",
+                                               lc->conn->c_cdn,
+                                               lc->bound_dn ));
+#else /* !NEW_LOGGING */
                                Debug( LDAP_DEBUG_ARGS,
                                                "rw> bindDn: \"%s\" ->"
-                                              " \"%s\"\n%s",
+                                               " \"%s\"\n%s",
                                                lc->conn->c_cdn,
                                                lc->bound_dn, "" );
+#endif /* !NEW_LOGGING */
                                break;
                                
                        case REWRITE_REGEXEC_UNWILLING:
@@ -251,8 +267,13 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                                                LDAP_UNWILLING_TO_PERFORM,
                                                NULL, "Unwilling to perform",
                                                NULL, NULL );
+                               return( NULL );
                                
                        case REWRITE_REGEXEC_ERR:
+                               send_ldap_result( conn, op,
+                                               LDAP_OPERATIONS_ERROR,
+                                               NULL, "Operations error",
+                                               NULL, NULL );
                                return( NULL );
                        }
 #else /* !ENABLE_REWRITE */
@@ -275,9 +296,15 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                
                ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
 
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+                               "ldap_back_getconn: conn %ld inserted\n",
+                               lc->conn->c_connid ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_TRACE,
-                       "=>ldap_back_getconn: conn %ld inserted%s%s\n",
+                       "=>ldap_back_getconn: conn %ld inserted\n%s%s",
                        lc->conn->c_connid, "", "" );
+#endif /* !NEW_LOGGING */
                
                /* Err could be -1 in case a duplicate ldapconn is inserted */
                if ( err != 0 ) {
@@ -287,9 +314,15 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
                        return( NULL );
                }
        } else {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+                               "ldap_back_getconn: conn %ld inserted\n",
+                               lc->conn->c_connid ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_TRACE,
                        "=>ldap_back_getconn: conn %ld fetched%s%s\n",
                        lc->conn->c_connid, "", "" );
+#endif /* !NEW_LOGGING */
        }
        
        return( lc );
index 99bd3972436fba71e61fd12168f2cd0e333689c3..23d65f9e5635065921b6b99da1930b7ac3e80799 100644 (file)
@@ -73,15 +73,24 @@ ldap_back_compare(
                if ( mdn == NULL ) {
                        mdn = ( char * )dn;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] compareDn: \"%s\" -> \"%s\"\n",
+                               dn, mdn ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS, "rw> compareDn: \"%s\" -> \"%s\"\n%s",
                                dn, mdn, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               return( -1 );
                
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                return( -1 );
        }
 #else /* !ENABLE_REWRITE */
index ef1d9475186121462c365cf100ca32dde48fcd39..cd00c5469f5db0ffd05af1e3c818beb444d1ee70 100644 (file)
@@ -74,15 +74,23 @@ ldap_back_delete(
        if ( mdn == NULL ) {
                        mdn = ( char * )dn;
                }
-               Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s",
-                               dn, mdn, "" );
-               break;
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                       "[rw] deleteDn: \"%s\" -> \"%s\"\n", dn, mdn ));
+#else /* !NEW_LOGGING */
+       Debug( LDAP_DEBUG_ARGS, "rw> deleteDn: \"%s\" -> \"%s\"\n%s",
+                       dn, mdn, "" );
+#endif /* !NEW_LOGGING */
+       break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               return( -1 );
 
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                return( -1 );
        }
 #else /* !ENABLE_REWRITE */
index 800b873e8d8c85f6f4661139a795ebd22a88e527..4c33926bc2640984b4c615b702021751fe3da052 100644 (file)
@@ -100,9 +100,15 @@ ldap_back_group(
                if ( mop_ndn == NULL ) {
                        mop_ndn = ( char * )op_ndn;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] bindDn (op ndn in group):"
+                               " \"%s\" -> \"%s\"\n", op_ndn, mop_ndn ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS,
                        "rw> bindDn (op ndn in group): \"%s\" -> \"%s\"\n%s",
                        op_ndn, mop_ndn, "" );
+#endif /* !NEW_LOGGING */
                break;
        
        case REWRITE_REGEXEC_UNWILLING:
@@ -120,10 +126,16 @@ ldap_back_group(
                if ( mgr_ndn == NULL ) {
                        mgr_ndn = ( char * )gr_ndn;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] searchBase (gr ndn in group):"
+                               " \"%s\" -> \"%s\"\n%s", gr_ndn, mgr_ndn ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS,
                        "rw> searchBase (gr ndn in group):"
                        " \"%s\" -> \"%s\"\n%s",
                        gr_ndn, mgr_ndn, "" );
+#endif /* !NEW_LOGGING */
                break;
        
        case REWRITE_REGEXEC_UNWILLING:
index 269ebf459114f06ad59dfddc9f68ffc66db74b7f..0b986db4c3386cc08a023b0ce34b6e7f46560410 100644 (file)
@@ -77,15 +77,23 @@ ldap_back_modify(
                if ( mdn == NULL ) {
                        mdn = ( char * )dn;
                }
-               Debug( LDAP_DEBUG_ARGS, "rw> modifyDN: \"%s\" -> \"%s\"\n%s",
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] modifyDn: \"%s\" -> \"%s\"\n", dn, mdn ));
+#else /* !NEW_LOGGING */
+               Debug( LDAP_DEBUG_ARGS, "rw> modifyDn: \"%s\" -> \"%s\"\n%s",
                                dn, mdn, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               return( -1 );
 
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                return( -1 );
        }
 #else /* !ENABLE_REWRITE */
index 74c2922ce82605a4020c0b2b563358270f5a4cee..72d2543ab824d0849609884cb208faa4abe1c6b6 100644 (file)
@@ -81,17 +81,28 @@ ldap_back_modrdn(
                        if ( mnewSuperior == NULL ) {
                                mnewSuperior = ( char * )newSuperior;
                        }
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                                       "[rw] newSuperiorDn:"
+                                       " \"%s\" -> \"%s\"\n",
+                                       newSuperior, mnewSuperior ));
+#else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS, "rw> newSuperiorDn:"
                                        " \"%s\" -> \"%s\"\n%s",
                                        newSuperior, mnewSuperior, "" );
+#endif /* !NEW_LOGGING */
                        break;
 
                case REWRITE_REGEXEC_UNWILLING:
                        send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                        NULL, "Unwilling to perform",
                                        NULL, NULL );
+                       return( -1 );
 
                case REWRITE_REGEXEC_ERR:
+                       send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                                       NULL, "Operations error",
+                                       NULL, NULL );
                        return( -1 );
                }
 #else /* !ENABLE_REWRITE */
@@ -112,15 +123,23 @@ ldap_back_modrdn(
                if ( mdn == NULL ) {
                        mdn = ( char * )dn;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] modrDn: \"%s\" -> \"%s\"\n", dn, mdn ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS, "rw> modrDn: \"%s\" -> \"%s\"\n%s",
                                dn, mdn, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               return( -1 );
 
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                return( -1 );
        }
 #else /* !ENABLE_REWRITE */
index 1b0e3a20ee28a785f69dd546ce1b850fbcf560cb..a0097d5c7feb301e542644fe422a5ff6e5258f64 100644 (file)
@@ -103,15 +103,25 @@ ldap_back_search(
                if ( mbase == NULL ) {
                        mbase = ( char * )base;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] searchBase: \"%s\" -> \"%s\"\n%",
+                               base, mbase ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS, "rw> searchBase: \"%s\" -> \"%s\"\n%s",
                                base, mbase, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
                                NULL, "Unwilling to perform", NULL, NULL );
+               rc = -1;
+               goto finish;
 
        case REWRITE_REGEXEC_ERR:
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
+                               NULL, "Operations error", NULL, NULL );
                rc = -1;
                goto finish;
        }
@@ -128,9 +138,15 @@ ldap_back_search(
                        }
                        mfilter = ( char * )filterstr;
                }
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                               "[rw] searchFilter: \"%s\" -> \"%s\"\n",
+                               filterstr, mfilter ));
+#else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS,
                                "rw> searchFilter: \"%s\" -> \"%s\"\n%s",
                                filterstr, mfilter, "" );
+#endif /* !NEW_LOGGING */
                break;
                
        case REWRITE_REGEXEC_UNWILLING:
@@ -226,9 +242,16 @@ fail:
                        if ( mmatch == NULL ) {
                                mmatch = ( char * )match;
                        }
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                                       "[rw]  matchedDn:"
+                                       " \"%s\" -> \"%s\"\n",
+                                       match, mmatch ));
+#else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS, "rw> matchedDn:"
-                                      " \"%s\" -> \"%s\"\n%s",
-                                      match, mmatch, "" );
+                                       " \"%s\" -> \"%s\"\n%s",
+                                       match, mmatch, "" );
+#endif /* !NEW_LOGGING */
                        break;
                        
                case REWRITE_REGEXEC_UNWILLING:
@@ -325,8 +348,14 @@ ldap_send_entry(
                if ( ent.e_dn == NULL ) {
                        ent.e_dn = dn;
                } else {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
+                                       "[rw] searchResult: \"%s\""
+                                       " -> \"%s\"\n", dn, ent.e_dn ));
+#else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS, "rw> searchResult: \"%s\""
                                        " -> \"%s\"\n%s", dn, ent.e_dn, "" );
+#endif /* !NEW_LOGGING */
                        free( dn );
                        dn = NULL;
                }
@@ -414,10 +443,20 @@ ldap_send_entry(
                                        if ( newval == NULL ) {
                                                break;
                                        }
+#ifdef NEW_LOGGING
+                                       LDAP_LOG(( "backend",
+                                                       LDAP_LEVEL_DETAIL1,
+                                                       "[rw] searchResult on"
+                                                       " attr=%s:"
+                                                       " \"%s\" -> \"%s\"\n",
+                                                       attr->a_desc->ad_type->sat_cname,
+                                                       bv->bv_val, newval ));
+#else /* !NEW_LOGGING */
                                        Debug( LDAP_DEBUG_ARGS,
                "rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n",
                                                attr->a_desc->ad_type->sat_cname,
                                                bv->bv_val, newval );
+#endif /* !NEW_LOGGING */
                                        
                                        free( bv->bv_val );
                                        bv->bv_val = newval;
index 49b2f3ef19ceac2446fca41b3cef951e99156dba..eb8db9608b4ed3fb5ea7a3a3ae746dd069dcc848 100644 (file)
@@ -54,10 +54,15 @@ ldap_back_conn_destroy(
        struct ldapinfo *li = (struct ldapinfo *) be->be_private;
        struct ldapconn *lc, lc_curr;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
+                       "ldap_back_conn_destroy: fetching conn %d\n",
+                       conn->c_connid ));
+#else /* !NEW_LOGGING */
        Debug( LDAP_DEBUG_TRACE,
                "=>ldap_back_conn_destroy: fetching conn %d\n",
                conn->c_connid, 0, 0 );
-       
+#endif /* !NEW_LOGGING */
 
        lc_curr.conn = conn;