X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fentry.c;h=38981c2756608e63ea05a7e236e1cb1b27199522;hb=HEAD;hp=f0da7a411d2d052eddf1d1430f7bb5ae308b148a;hpb=fed9370fae35b4aed29a5f8ab619c0b17a9e8cd7;p=openldap diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index f0da7a411d..38981c2756 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2014 The OpenLDAP Foundation. + * Copyright 1998-2018 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -249,10 +249,10 @@ str2entry2( char *s, int checkvals ) rc = slap_bv2ad( type+i, &ad, &text ); if( rc != LDAP_SUCCESS ) { - Debug( slapMode & SLAP_TOOL_MODE - ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE, + int wtool = ( slapMode & (SLAP_TOOL_MODE|SLAP_TOOL_READONLY) ) == SLAP_TOOL_MODE; + Debug( wtool ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE, "<= str2entry: str2ad(%s): %s\n", type[i].bv_val, text, 0 ); - if( slapMode & SLAP_TOOL_MODE ) { + if( wtool ) { goto fail; } @@ -278,18 +278,6 @@ str2entry2( char *s, int checkvals ) if (( ad_prev && ad != ad_prev ) || ( i == lines )) { int j, k; - /* FIXME: we only need this when migrating from an unsorted DB */ - if ( atail != &ahead && atail->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL ) { - rc = slap_sort_vals( (Modifications *)atail, &text, &j, NULL ); - if ( rc == LDAP_SUCCESS ) { - atail->a_flags |= SLAP_ATTR_SORTED_VALS; - } else if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) { - Debug( LDAP_DEBUG_ANY, - "str2entry: attributeType %s value #%d provided more than once\n", - atail->a_desc->ad_cname.bv_val, j, 0 ); - goto fail; - } - } atail->a_next = attr_alloc( NULL ); atail = atail->a_next; atail->a_flags = 0; @@ -321,6 +309,18 @@ str2entry2( char *s, int checkvals ) atail->a_nvals = atail->a_vals; } attr_cnt = 0; + /* FIXME: we only need this when migrating from an unsorted DB */ + if ( atail->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL ) { + rc = slap_sort_vals( (Modifications *)atail, &text, &j, NULL ); + if ( rc == LDAP_SUCCESS ) { + atail->a_flags |= SLAP_ATTR_SORTED_VALS; + } else if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) { + Debug( LDAP_DEBUG_ANY, + "str2entry: attributeType %s value #%d provided more than once\n", + atail->a_desc->ad_cname.bv_val, j, 0 ); + goto fail; + } + } if ( i == lines ) break; } @@ -332,48 +332,6 @@ str2entry2( char *s, int checkvals ) goto fail; } - if( slapMode & SLAP_TOOL_MODE ) { - struct berval pval; - slap_syntax_validate_func *validate = - ad->ad_type->sat_syntax->ssyn_validate; - slap_syntax_transform_func *pretty = - ad->ad_type->sat_syntax->ssyn_pretty; - - if ( pretty ) { - rc = ordered_value_pretty( ad, - &vals[i], &pval, NULL ); - - } else if ( validate ) { - /* - * validate value per syntax - */ - rc = ordered_value_validate( ad, &vals[i], LDAP_MOD_ADD ); - - } else { - Debug( LDAP_DEBUG_ANY, - "str2entry: attributeType %s #%d: " - "no validator for syntax %s\n", - ad->ad_cname.bv_val, attr_cnt, - ad->ad_type->sat_syntax->ssyn_oid ); - goto fail; - } - - if( rc != 0 ) { - Debug( LDAP_DEBUG_ANY, - "str2entry: invalid value " - "for attributeType %s #%d (syntax %s)\n", - ad->ad_cname.bv_val, attr_cnt, - ad->ad_type->sat_syntax->ssyn_oid ); - goto fail; - } - - if( pretty ) { - if ( freeval[i] ) free( vals[i].bv_val ); - vals[i] = pval; - freeval[i] = 1; - } - } - if ( ad->ad_type->sat_equality && ad->ad_type->sat_equality->smr_normalize ) {