Pass op to slap_mods_check()

This commit is contained in:
Howard Chu 2006-12-24 06:55:02 +00:00
parent e955bbeaf5
commit 45fbb173b7
8 changed files with 15 additions and 58 deletions

View File

@ -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 */

View File

@ -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,

View File

@ -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 );

View File

@ -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 ));

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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",