mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-27 17:19:19 -05:00
improve (and cleanup) value normalization
This commit is contained in:
parent
43b1658160
commit
756d35cb6e
8 changed files with 27 additions and 94 deletions
|
|
@ -203,7 +203,6 @@ struct monitorsubsys {
|
|||
extern struct monitorsubsys monitor_subsys[];
|
||||
|
||||
extern AttributeDescription *monitor_ad_desc;
|
||||
extern slap_mr_normalize_func *monitor_ad_normalize;
|
||||
extern BackendDB *be_monitor;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ monitor_subsys_backend_init(
|
|||
for ( i = nBackendInfo; i--; ) {
|
||||
char buf[1024];
|
||||
BackendInfo *bi;
|
||||
struct berval bv, nbv;
|
||||
int rc;
|
||||
struct berval bv;
|
||||
|
||||
bi = &backendInfo[i];
|
||||
|
||||
|
|
@ -110,23 +109,8 @@ monitor_subsys_backend_init(
|
|||
bv.bv_val = bi->bi_type;
|
||||
bv.bv_len = strlen( bv.bv_val );
|
||||
|
||||
nbv.bv_val = NULL;
|
||||
if ( monitor_ad_normalize ) {
|
||||
rc = monitor_ad_normalize(
|
||||
0,
|
||||
monitor_ad_desc->ad_type->sat_syntax,
|
||||
monitor_ad_desc->ad_type->sat_equality,
|
||||
&bv, &nbv );
|
||||
if ( rc ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
attr_merge_one( e, monitor_ad_desc, &bv,
|
||||
nbv.bv_val ? &nbv : NULL );
|
||||
attr_merge_one( e_backend, monitor_ad_desc, &bv,
|
||||
nbv.bv_val ? &nbv : NULL );
|
||||
ch_free( nbv.bv_val );
|
||||
attr_merge_normalize_one( e, monitor_ad_desc, &bv );
|
||||
attr_merge_normalize_one( e_backend, monitor_ad_desc, &bv );
|
||||
|
||||
if ( bi->bi_controls ) {
|
||||
int j;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ monitor_subsys_database_init(
|
|||
j, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val );
|
||||
bv.bv_val = buf;
|
||||
bv.bv_len = strlen( buf );
|
||||
attr_mergeit_one( e, ad_seeAlso, &bv );
|
||||
attr_merge_normalize_one( e, ad_seeAlso, &bv );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ monitor_back_add_plugin( Backend *be, Entry *e_database )
|
|||
|
||||
bv.bv_val = buf;
|
||||
bv.bv_len = strlen( buf );
|
||||
attr_mergeit_one( e_database, monitor_ad_desc, &bv );
|
||||
attr_merge_normalize_one( e_database, monitor_ad_desc, &bv );
|
||||
|
||||
i++;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@
|
|||
* used by many functions to add description to entries
|
||||
*/
|
||||
AttributeDescription *monitor_ad_desc = NULL;
|
||||
slap_mr_normalize_func *monitor_ad_normalize = NULL;
|
||||
BackendDB *be_monitor = NULL;
|
||||
|
||||
/*
|
||||
|
|
@ -301,10 +300,6 @@ monitor_back_db_init(
|
|||
return( -1 );
|
||||
}
|
||||
|
||||
if ( monitor_ad_desc->ad_type->sat_equality ) {
|
||||
monitor_ad_normalize = monitor_ad_desc->ad_type->sat_equality->smr_normalize;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create all the subsystem specific entries
|
||||
*/
|
||||
|
|
@ -429,7 +424,7 @@ monitor_back_db_init(
|
|||
} else {
|
||||
bv.bv_len = strlen( Versionstr );
|
||||
}
|
||||
if ( attr_merge_one( e, monitor_ad_desc, &bv, NULL ) ) {
|
||||
if ( attr_merge_normalize_one( e, monitor_ad_desc, &bv ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, CRIT,
|
||||
"unable to add description to '%s' entry\n",
|
||||
|
|
|
|||
|
|
@ -122,54 +122,22 @@ monitor_subsys_listener_init(
|
|||
|
||||
#ifdef HAVE_TLS
|
||||
if ( l[i]->sl_is_tls ) {
|
||||
struct berval bv, nbv;
|
||||
struct berval bv;
|
||||
|
||||
bv.bv_val = "TLS";
|
||||
bv.bv_len = sizeof("TLS")-1;
|
||||
|
||||
nbv.bv_val = NULL;
|
||||
if ( monitor_ad_normalize ) {
|
||||
int rc;
|
||||
|
||||
rc = monitor_ad_normalize(
|
||||
0,
|
||||
monitor_ad_desc->ad_type->sat_syntax,
|
||||
monitor_ad_desc->ad_type->sat_equality,
|
||||
&bv, &nbv );
|
||||
if ( rc ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
attr_merge_one( e, monitor_ad_desc, &bv,
|
||||
nbv.bv_val ? &nbv : NULL );
|
||||
ch_free( nbv.bv_val );
|
||||
attr_merge_normalize_one( e, monitor_ad_desc, &bv );
|
||||
}
|
||||
#endif /* HAVE_TLS */
|
||||
#ifdef LDAP_CONNECTIONLESS
|
||||
if ( l[i]->sl_is_udp ) {
|
||||
struct berval bv, nbv;
|
||||
struct berval bv;
|
||||
|
||||
bv.bv_val = "UDP";
|
||||
bv.bv_len = sizeof("UDP")-1;
|
||||
|
||||
nbv.bv_val = NULL;
|
||||
if ( monitor_ad_normalize ) {
|
||||
int rc;
|
||||
|
||||
rc = monitor_ad_normalize(
|
||||
0,
|
||||
monitor_ad_desc->ad_type->sat_syntax,
|
||||
monitor_ad_desc->ad_type->sat_equality,
|
||||
&bv, &nbv );
|
||||
if ( rc ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
attr_merge_one( e, monitor_ad_desc, &bv,
|
||||
nbv.bv_val ? &nbv : NULL );
|
||||
ch_free( nbv.bv_val );
|
||||
attr_merge_normalize_one( e, monitor_ad_desc, &bv );
|
||||
}
|
||||
#endif /* HAVE_TLS */
|
||||
|
||||
|
|
|
|||
|
|
@ -116,10 +116,10 @@ monitor_subsys_log_init(
|
|||
/* initialize the debug level(s) */
|
||||
for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
|
||||
|
||||
if ( monitor_ad_normalize ) {
|
||||
if ( monitor_ad_desc->ad_type->sat_equality->smr_normalize ) {
|
||||
int rc;
|
||||
|
||||
rc = monitor_ad_normalize(
|
||||
rc = (*monitor_ad_desc->ad_type->sat_equality->smr_normalize)(
|
||||
0,
|
||||
monitor_ad_desc->ad_type->sat_syntax,
|
||||
monitor_ad_desc->ad_type->sat_equality,
|
||||
|
|
@ -167,7 +167,8 @@ monitor_subsys_log_modify(
|
|||
*/
|
||||
if ( is_at_operational( mod->sm_desc->ad_type ) ) {
|
||||
( void ) attr_delete( &e->e_attrs, mod->sm_desc );
|
||||
rc = attr_mergeit( e, mod->sm_desc, mod->sm_bvalues );
|
||||
rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
|
||||
mod->sm_nvalues );
|
||||
if ( rc != 0 ) {
|
||||
rc = LDAP_OTHER;
|
||||
break;
|
||||
|
|
@ -374,10 +375,10 @@ add_values( Entry *e, Modification *mod, int *newlevel )
|
|||
}
|
||||
|
||||
/* no - add them */
|
||||
if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues,
|
||||
mod->sm_nvalues ) != 0 ) {
|
||||
rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, mod->sm_nvalues );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
/* this should return result of attr_mergeit */
|
||||
return LDAP_OTHER;
|
||||
return rc;
|
||||
}
|
||||
|
||||
return LDAP_SUCCESS;
|
||||
|
|
@ -499,10 +500,12 @@ replace_values( Entry *e, Modification *mod, int *newlevel )
|
|||
return rc;
|
||||
}
|
||||
|
||||
if ( mod->sm_bvalues != NULL &&
|
||||
attr_merge( e, mod->sm_desc, mod->sm_bvalues,
|
||||
mod->sm_nvalues ) != 0 ) {
|
||||
return LDAP_OTHER;
|
||||
if ( mod->sm_bvalues != NULL ) {
|
||||
rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
|
||||
mod->sm_nvalues );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
return LDAP_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -115,28 +115,12 @@ monitor_subsys_readw_update_internal(
|
|||
}
|
||||
|
||||
if ( b == NULL || b[0].bv_val == NULL ) {
|
||||
struct berval bv, nbv;
|
||||
struct berval bv;
|
||||
|
||||
bv.bv_val = buf;
|
||||
bv.bv_len = strlen( buf );
|
||||
|
||||
nbv.bv_val = NULL;
|
||||
if ( monitor_ad_normalize ) {
|
||||
int rc;
|
||||
|
||||
rc = monitor_ad_normalize(
|
||||
0,
|
||||
monitor_ad_desc->ad_type->sat_syntax,
|
||||
monitor_ad_desc->ad_type->sat_equality,
|
||||
&bv, &nbv );
|
||||
if ( rc ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
attr_merge_one( e, monitor_ad_desc, &bv,
|
||||
nbv.bv_val ? &nbv : NULL );
|
||||
ch_free( nbv.bv_val );
|
||||
attr_merge_normalize_one( e, monitor_ad_desc, &bv );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ monitor_subsys_thread_init(
|
|||
bv.bv_val = buf;
|
||||
bv.bv_len = strlen( bv.bv_val );
|
||||
|
||||
attr_merge_one( e, monitor_ad_desc, &bv, NULL );
|
||||
attr_merge_normalize_one( e, monitor_ad_desc, &bv );
|
||||
|
||||
monitor_cache_release( mi, e );
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ monitor_subsys_thread_update(
|
|||
|
||||
bv.bv_val = buf;
|
||||
bv.bv_len = strlen( buf );
|
||||
attr_merge_one( e, monitor_ad_desc, &bv, NULL );
|
||||
attr_merge_normalize_one( e, monitor_ad_desc, &bv );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue