From 45fbb173b719c7001f94a03b06f14c77bc90d1bd Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 24 Dec 2006 06:55:02 +0000 Subject: [PATCH] Pass op to slap_mods_check() --- servers/slapd/add.c | 49 +----------------------------- servers/slapd/modify.c | 3 +- servers/slapd/proto-slap.h | 1 + servers/slapd/slapi/proto-slapi.h | 2 +- servers/slapd/slapi/slapi_ops.c | 4 +-- servers/slapd/slapi/slapi_pblock.c | 2 +- servers/slapd/slapi/slapi_utils.c | 6 ++-- servers/slapd/syncrepl.c | 6 ++-- 8 files changed, 15 insertions(+), 58 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index bacbe232a3..3fb10969e1 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -157,7 +157,7 @@ do_add( Operation *op, SlapReply *rs ) goto done; } - rs->sr_err = slap_mods_check( modlist, &rs->sr_text, + rs->sr_err = slap_mods_check( op, modlist, &rs->sr_text, textbuf, textlen, NULL ); if ( rs->sr_err != LDAP_SUCCESS ) { @@ -323,15 +323,6 @@ fe_op_add( Operation *op, SlapReply *rs ) goto done; } -#if 0 /* This is a no-op since *modtail is NULL */ - rs->sr_err = slap_mods2entry( *modtail, &op->ora_e, - 0, 0, &rs->sr_text, textbuf, textlen ); - if ( rs->sr_err != LDAP_SUCCESS ) { - send_ldap_result( op, rs ); - goto done; - } -#endif - cb.sc_next = op->o_callback; op->o_callback = &cb; } @@ -472,44 +463,6 @@ slap_mods2entry( #endif } -#if 0 /* checked for duplicates in slap_mods_check */ - if( mods->sml_values[1].bv_val != NULL ) { - /* check for duplicates */ - int i, j, rc, match; - MatchingRule *mr = mods->sml_desc->ad_type->sat_equality; - - for ( i = 1; mods->sml_values[i].bv_val != NULL; i++ ) { - /* test asserted values against themselves */ - for( j = 0; j < i; j++ ) { - rc = ordered_value_match( &match, mods->sml_desc, mr, - SLAP_MR_EQUALITY - | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX - | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH - | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, - mods->sml_nvalues - ? &mods->sml_nvalues[i] - : &mods->sml_values[i], - mods->sml_nvalues - ? &mods->sml_nvalues[j] - : &mods->sml_values[j], - text ); - - if ( rc == LDAP_SUCCESS && match == 0 ) { - /* value exists already */ - snprintf( textbuf, textlen, - "%s: value #%d provided more than once", - mods->sml_desc->ad_cname.bv_val, j ); - *text = textbuf; - return LDAP_TYPE_OR_VALUE_EXISTS; - - } else if ( rc != LDAP_SUCCESS ) { - return rc; - } - } - } - } -#endif - attr = attr_alloc( mods->sml_desc ); /* move values to attr structure */ diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 6e987da08d..f8f709244d 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -183,7 +183,7 @@ do_modify( goto cleanup; } - rs->sr_err = slap_mods_check( modlist, + rs->sr_err = slap_mods_check( op, modlist, &rs->sr_text, textbuf, textlen, NULL ); if ( rs->sr_err != LDAP_SUCCESS ) { @@ -539,6 +539,7 @@ slap_mods_no_repl_user_mod_check( * Do basic attribute type checking and syntax validation. */ int slap_mods_check( + Operation *op, Modifications *ml, const char **text, char *textbuf, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index a0674ca2f3..4f25d301b2 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1098,6 +1098,7 @@ LDAP_SLAPD_F ( int ) slap_mods_no_repl_user_mod_check( size_t textlen ); LDAP_SLAPD_F( int ) slap_mods_check( + Operation *op, Modifications *ml, const char **text, char *textbuf, size_t textlen, void *ctx ); diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 45dfe1dc6d..3a823880e6 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -27,7 +27,7 @@ LDAP_BEGIN_DECL /* slapi_utils.c */ LDAP_SLAPI_F (LDAPMod **) slapi_int_modifications2ldapmods LDAP_P(( Modifications * )); -LDAP_SLAPI_F (Modifications *) slapi_int_ldapmods2modifications LDAP_P(( LDAPMod ** )); +LDAP_SLAPI_F (Modifications *) slapi_int_ldapmods2modifications LDAP_P(( Operation *op, LDAPMod ** )); LDAP_SLAPI_F (int) slapi_int_count_controls LDAP_P(( LDAPControl **ctrls )); LDAP_SLAPI_F (char **) slapi_get_supported_extended_ops LDAP_P((void)); LDAP_SLAPI_F (int) slapi_int_access_allowed LDAP_P((Operation *op, Entry *entry, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state )); diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index aba0caeb44..7e90ee8c9c 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -465,7 +465,7 @@ slapi_add_internal_pb( Slapi_PBlock *pb ) assert( pb->pb_op->ora_modlist != NULL ); } - rs->sr_err = slap_mods_check( pb->pb_op->ora_modlist, &rs->sr_text, + rs->sr_err = slap_mods_check( pb->pb_op, pb->pb_op->ora_modlist, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL ); if ( rs->sr_err != LDAP_SUCCESS ) { goto cleanup; @@ -550,7 +550,7 @@ slapi_modify_internal_pb( Slapi_PBlock *pb ) goto cleanup; } - rs->sr_err = slap_mods_check( pb->pb_op->orm_modlist, + rs->sr_err = slap_mods_check( pb->pb_op, pb->pb_op->orm_modlist, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL ); if ( rs->sr_err != LDAP_SUCCESS ) { goto cleanup; diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 30fd74292c..02164d2236 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -1005,7 +1005,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value ) break; } - newmods = slapi_int_ldapmods2modifications( (LDAPMod **)value ); + newmods = slapi_int_ldapmods2modifications( pb->pb_op, (LDAPMod **)value ); if ( newmods != NULL ) { slap_mods_free( *mlp, 1 ); *mlp = newmods; diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index ac618cf50d..83733aaacd 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -2607,7 +2607,7 @@ int slapi_acl_check_mods(Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char if ( pb == NULL || pb->pb_op == NULL ) return LDAP_PARAM_ERROR; - ml = slapi_int_ldapmods2modifications( mods ); + ml = slapi_int_ldapmods2modifications( pb->pb_op, mods ); if ( ml == NULL ) { return LDAP_OTHER; } @@ -2677,7 +2677,7 @@ LDAPMod **slapi_int_modifications2ldapmods( Modifications *modlist ) * before prettying (and we can't easily get out of calling * slap_mods_check() because we need normalized values). */ -Modifications *slapi_int_ldapmods2modifications ( LDAPMod **mods ) +Modifications *slapi_int_ldapmods2modifications ( Operation *op, LDAPMod **mods ) { Modifications *modlist = NULL, **modtail; LDAPMod **modp; @@ -2746,7 +2746,7 @@ Modifications *slapi_int_ldapmods2modifications ( LDAPMod **mods ) modtail = &mod->sml_next; } - if ( slap_mods_check( modlist, &text, textbuf, sizeof( textbuf ), NULL ) != LDAP_SUCCESS ) { + if ( slap_mods_check( op, modlist, &text, textbuf, sizeof( textbuf ), NULL ) != LDAP_SUCCESS ) { slap_mods_free( modlist, 1 ); modlist = NULL; } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index ebc66aa651..53d2cc82b1 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -985,6 +985,8 @@ do_syncrepl( op->o_bd = be = si->si_be; op->o_dn = op->o_bd->be_rootdn; op->o_ndn = op->o_bd->be_rootndn; + if ( !si->si_schemachecking ) + op->o_no_schema_check = 1; /* Establish session, do search */ if ( !si->si_ld ) { @@ -1265,7 +1267,7 @@ syncrepl_message_to_op( /* If we didn't get required data, bail */ if ( !modlist ) goto done; - rc = slap_mods_check( modlist, &text, txtbuf, textlen, NULL ); + rc = slap_mods_check( op, modlist, &text, txtbuf, textlen, NULL ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_op: rid %03d " @@ -1451,7 +1453,7 @@ syncrepl_message_to_entry( goto done; } - rc = slap_mods_check( *modlist, &text, txtbuf, textlen, NULL ); + rc = slap_mods_check( op, *modlist, &text, txtbuf, textlen, NULL ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: rid %03d mods check (%s)\n", -- 2.39.5