/* 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
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,
+ LDAP_LOG( OPERATION, 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, 0, 0 );
#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 );
}
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 );
}
continue;
-#endif
/*
* only the monitor description attribute can be modified
*/
break;
default:
- rc = LDAP_OPERATIONS_ERROR;
+ rc = LDAP_OTHER;
break;
}
#if 0 /* need op */
/* check for abandon */
- ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
if ( op->o_abandon ) {
- ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
rc = SLAPD_ABANDON;
goto cleanup;
#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;
}
+ /*
+ * Do we need to protect this with a mutex?
+ */
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);
{
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;
}
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 );
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;
}
{
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 ) {
}
/* 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;
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 ) {
}
/* 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;