X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Fmodify.c;h=659527c31bebc1ff03ded9b5110e8b7f0eb3f562;hb=caf751fbb20fbccf535b900df1dabef0f40e0222;hp=5744b60dcc446320465a23a10c8abeb4aa3dfef4;hpb=d989f196685f863c6d562bae2dcc913257afc824;p=openldap diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 5744b60dcc..659527c31b 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2008 The OpenLDAP Foundation. + * Copyright 1998-2012 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,12 +82,14 @@ do_modify( if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "%s do_modify: slap_parse_modlist failed err=%d msg=%s\n", op->o_log_prefix, rs->sr_err, rs->sr_text ); + send_ldap_result( op, rs ); goto cleanup; } if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "%s do_modify: get_ctrls failed\n", op->o_log_prefix, 0, 0 ); + /* get_ctrls has sent results. Now clean up. */ goto cleanup; } @@ -268,6 +270,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) if ( op->orm_increment && !SLAP_INCREMENT( op->o_bd ) ) { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "modify/increment not supported in context" ); + goto cleanup; } /* @@ -681,7 +684,7 @@ slap_sort_vals( AttributeDescription *ad; MatchingRule *mr; int istack[sizeof(int)*16]; - int i, j, k, l, ir, jstack, match, *ix, itmp, nvals, rc; + int i, j, k, l, ir, jstack, match, *ix, itmp, nvals, rc = LDAP_SUCCESS; int is_norm; struct berval a, *cv; @@ -689,7 +692,7 @@ slap_sort_vals( #define SWAP(a,b,tmp) tmp=(a);(a)=(b);(b)=tmp #define COMP(a,b) match=0; rc = ordered_value_match( &match, \ ad, mr, SLAP_MR_EQUALITY \ - | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX \ + | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX \ | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH \ | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, \ &(a), &(b), text ); @@ -702,6 +705,8 @@ slap_sort_vals( ad = ml->sml_desc; nvals = ml->sml_numvals; + if ( nvals <= 1 ) + goto ret; /* For Modifications, sml_nvalues is NULL if normalization wasn't needed. * For Attributes, sml_nvalues == sml_values when normalization isn't needed. @@ -807,7 +812,7 @@ slap_sort_vals( } } done: - if ( i >= 0 ) + if ( match == 0 && i >= 0 ) *dup = ix[i]; /* For sorted attributes, put the values in index order */ @@ -831,15 +836,14 @@ slap_sort_vals( slap_sl_free( ix, ctx ); - if ( rc != LDAP_SUCCESS ) { - return rc; - } else if ( match == 0 ) { + if ( rc == LDAP_SUCCESS && match == 0 ) { /* value exists already */ assert( i >= 0 ); assert( i < nvals ); - return LDAP_TYPE_OR_VALUE_EXISTS; + rc = LDAP_TYPE_OR_VALUE_EXISTS; } - return LDAP_SUCCESS; + ret: + return rc; } /* Enter with bv->bv_len = sizeof buffer, returns with @@ -847,21 +851,11 @@ slap_sort_vals( */ void slap_timestamp( time_t *tm, struct berval *bv ) { - struct tm *ltm; -#ifdef HAVE_GMTIME_R - struct tm ltm_buf; - - ltm = gmtime_r( tm, <m_buf ); -#else - ldap_pvt_thread_mutex_lock( &gmtime_mutex ); - ltm = gmtime( tm ); -#endif + struct tm ltm; - bv->bv_len = lutil_gentime( bv->bv_val, bv->bv_len, ltm ); + ldap_pvt_gmtime( tm, <m ); -#ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); -#endif + bv->bv_len = lutil_gentime( bv->bv_val, bv->bv_len, <m ); } /* Called for all modify and modrdn ops. If the current op was replicated @@ -875,7 +869,7 @@ void slap_mods_opattrs( struct berval name, timestamp, csn = BER_BVNULL; struct berval nname; char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; - char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; + char csnbuf[ LDAP_PVT_CSNSTR_BUFSIZE ]; Modifications *mod, **modtail, *modlast; int gotcsn = 0, gotmname = 0, gotmtime = 0; @@ -885,6 +879,7 @@ void slap_mods_opattrs( for ( modtail = modsp; *modtail; modtail = &(*modtail)->sml_next ) { if ( (*modtail)->sml_op != LDAP_MOD_ADD && (*modtail)->sml_op != SLAP_MOD_SOFTADD && + (*modtail)->sml_op != SLAP_MOD_ADD_IF_NOT_PRESENT && (*modtail)->sml_op != LDAP_MOD_REPLACE ) { continue;