]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/log.c
Add search no-op support.
[openldap] / servers / slapd / back-monitor / log.c
index 58f8d358fde38d92b291fdd858d87e98e409b6f3..fe5a0819327fae89b8e79fb13aef7c89488113cc 100644 (file)
@@ -1,12 +1,9 @@
 /* log.c - deal with log subsystem */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
- * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- * 
  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
  * 
  * This work has beed deveolped for the OpenLDAP Foundation 
@@ -89,34 +86,36 @@ monitor_subsys_log_init(
        struct monitorinfo      *mi;
        Entry                   *e;
        int                     i;
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        ldap_pvt_thread_mutex_init( &monitor_log_mutex );
 
        mi = ( struct monitorinfo * )be->be_private;
 
-       if ( monitor_cache_get( mi, monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn, 
+       if ( monitor_cache_get( mi, &monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn, 
                                &e ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
                        "monitor_subsys_log_init: "
                        "unable to get entry '%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn ));
+                       monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn.bv_val ));
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_log_init: "
                        "unable to get entry '%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn, 
+                       monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn.bv_val
                        "", "" );
 #endif
                return( -1 );
        }
 
+       bv[1].bv_val = NULL;
+
        /* initialize the debug level */
        for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
                if ( int_2_level[ i ].i & ldap_syslog ) {
-                       val.bv_val = ( char * )int_2_level[ i ].s;
-                       val.bv_len = strlen( val.bv_val );
+                       bv[0].bv_val = ( char * )int_2_level[ i ].s;
+                       bv[0].bv_len = strlen( bv[0].bv_val );
 
                        attr_merge( e, monitor_ad_desc, bv );
                }
@@ -148,26 +147,8 @@ monitor_subsys_log_modify(
                Modification    *mod = &ml->sml_mod;
 
                /*
-                * Operational attributes
-                */
-#if 0
-               if ( mod->sm_desc == slap_schema.si_ad_modifyTimestamp 
-                       || mod->sm_desc == slap_schema.si_ad_modifiersName ) {
-                       ( void ) attr_delete( &e->e_attrs, mod->sm_desc );
-                       rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues );
-                       if ( rc != 0 ) {
-                               rc = LDAP_OTHER;
-                               break;
-                       }
-                       continue;
-
-               /*
-                * unhandled operational attributes
+                * accept all operational attributes
                 */
-               } else if ( is_at_operational( mod->sm_desc->ad_type ) ) {
-                       continue;
-
-#else
                if ( is_at_operational( mod->sm_desc->ad_type ) ) {
                        ( void ) attr_delete( &e->e_attrs, mod->sm_desc );
                        rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues );
@@ -177,7 +158,6 @@ monitor_subsys_log_modify(
                        }
                        continue;
 
-#endif
                /*
                 * only the monitor description attribute can be modified
                 */
@@ -226,15 +206,15 @@ monitor_subsys_log_modify(
 #endif
 
                /* check that the entry still obeys the schema */
-               rc = entry_schema_check( e, save_attrs, &text, textbuf
-                               sizeof( textbuf ) );
+               rc = entry_schema_check( be_monitor, e, save_attrs
+                               &text, textbuf, sizeof( textbuf ) );
                if ( rc != LDAP_SUCCESS ) {
                        goto cleanup;
                }
 
                ldap_syslog = newlevel;
 
-#if 0
+#if 0  /* debug rather than log */
                slap_debug = newlevel;
                lutil_set_debug_level( "slapd", slap_debug );
                ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
@@ -290,21 +270,21 @@ check_constraints( Modification *mod, int *newlevel )
 {
        int             i;
 
-       for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i] != NULL; i++ ) {
+       for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                int l;
                const char *s;
                ber_len_t len;
                
-               l = loglevel2int( mod->sm_bvalues[i]->bv_val );
+               l = loglevel2int( mod->sm_bvalues[i].bv_val );
                if ( !l ) {
                        return LDAP_CONSTRAINT_VIOLATION;
                }
 
                s = int2loglevel( l );
                len = strlen( s );
-               assert( len == mod->sm_bvalues[i]->bv_len );
+               assert( len == mod->sm_bvalues[i].bv_len );
                
-               AC_MEMCPY( mod->sm_bvalues[i]->bv_val, s, len );
+               AC_MEMCPY( mod->sm_bvalues[i].bv_val, s, len );
 
                *newlevel |= l;
        }
@@ -333,15 +313,15 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
 
-               for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+               for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                        int rc;
                        int j;
                        const char *text = NULL;
-                       struct berval *asserted = NULL;
+                       struct berval asserted;
 
                        rc = value_normalize( mod->sm_desc,
                                        SLAP_MR_EQUALITY,
-                                       mod->sm_bvalues[i],
+                                       &mod->sm_bvalues[i],
                                        &asserted,
                                        &text );
 
@@ -349,25 +329,25 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                                return rc;
                        }
 
-                       for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+                       for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
                                                SLAP_MR_VALUE_SYNTAX_MATCH,
-                                               a->a_vals[j], asserted, &text );
+                                               &a->a_vals[j], &asserted, &text );
 
                                if ( rc == LDAP_SUCCESS && match == 0 ) {
-                                       ber_bvfree( asserted );
+                                       free( asserted.bv_val );
                                        return LDAP_TYPE_OR_VALUE_EXISTS;
                                }
                        }
 
-                       ber_bvfree( asserted );
+                       free( asserted.bv_val );
                }
        }
 
        /* no - add them */
        if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
-               /* this should return result return of attr_merge */
+               /* this should return result of attr_merge */
                return LDAP_OTHER;
        }
 
@@ -379,8 +359,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
 {
        int             i, j, k, found, rc, nl = 0;
        Attribute       *a;
-       char *desc = mod->sm_desc->ad_cname.bv_val;
-       MatchingRule *mr = mod->sm_desc->ad_type->sat_equality;
+       MatchingRule    *mr = mod->sm_desc->ad_type->sat_equality;
 
        rc = check_constraints( mod, &nl );
        if ( rc != LDAP_SUCCESS ) {
@@ -414,26 +393,26 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* find each value to delete */
-       for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+       for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                int rc;
                const char *text = NULL;
 
-               struct berval *asserted = NULL;
+               struct berval asserted;
 
                rc = value_normalize( mod->sm_desc,
                                SLAP_MR_EQUALITY,
-                               mod->sm_bvalues[i],
+                               &mod->sm_bvalues[i],
                                &asserted,
                                &text );
 
                if( rc != LDAP_SUCCESS ) return rc;
 
                found = 0;
-               for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+               for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                        int match;
                        int rc = value_match( &match, mod->sm_desc, mr,
                                        SLAP_MR_VALUE_SYNTAX_MATCH,
-                                       a->a_vals[j], asserted, &text );
+                                       &a->a_vals[j], &asserted, &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 ) {
                                continue;
@@ -443,16 +422,16 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
                        found = 1;
 
                        /* delete it */
-                       ber_bvfree( a->a_vals[j] );
-                       for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+                       free( a->a_vals[j].bv_val );
+                       for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
                                a->a_vals[k - 1] = a->a_vals[k];
                        }
-                       a->a_vals[k - 1] = NULL;
+                       a->a_vals[k - 1].bv_val = NULL;
 
                        break;
                }
 
-               ber_bvfree( asserted );
+               free( asserted.bv_val );
 
                /* looked through them all w/o finding it */
                if ( ! found ) {
@@ -461,7 +440,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* if no values remain, delete the entire attribute */
-       if ( a->a_vals[0] == NULL ) {
+       if ( a->a_vals[0].bv_val == NULL ) {
                /* should already be zero */
                *newlevel = 0;