mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
Use common entry cleanup code.
This commit is contained in:
parent
86bd13846f
commit
550542e020
@ -83,12 +83,12 @@ do_add( Connection *conn, Operation *op )
|
|||||||
|
|
||||||
e->e_dn = dn;
|
e->e_dn = dn;
|
||||||
e->e_ndn = ndn;
|
e->e_ndn = ndn;
|
||||||
|
e->e_attrs = NULL;
|
||||||
e->e_private = NULL;
|
e->e_private = NULL;
|
||||||
|
|
||||||
Debug( LDAP_DEBUG_ARGS, " do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
|
Debug( LDAP_DEBUG_ARGS, " do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
|
||||||
|
|
||||||
/* get the attrs */
|
/* get the attrs */
|
||||||
e->e_attrs = NULL;
|
|
||||||
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
|
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
|
||||||
tag = ber_next_element( ber, &len, last ) ) {
|
tag = ber_next_element( ber, &len, last ) ) {
|
||||||
char *type;
|
char *type;
|
||||||
@ -97,18 +97,17 @@ do_add( Connection *conn, Operation *op )
|
|||||||
if ( ber_scanf( ber, "{a{V}}", &type, &vals ) == LBER_ERROR ) {
|
if ( ber_scanf( ber, "{a{V}}", &type, &vals ) == LBER_ERROR ) {
|
||||||
send_ldap_disconnect( conn, op,
|
send_ldap_disconnect( conn, op,
|
||||||
LDAP_PROTOCOL_ERROR, "decoding error" );
|
LDAP_PROTOCOL_ERROR, "decoding error" );
|
||||||
entry_free( e );
|
rc = -1;
|
||||||
return -1;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( vals == NULL ) {
|
if ( vals == NULL ) {
|
||||||
Debug( LDAP_DEBUG_ANY, "no values for type %s\n", type,
|
Debug( LDAP_DEBUG_ANY, "no values for type %s\n", type,
|
||||||
0, 0 );
|
0, 0 );
|
||||||
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
|
send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
|
||||||
NULL, "no values for type", NULL, NULL );
|
NULL, "no values for type", NULL, NULL );
|
||||||
free( type );
|
free( type );
|
||||||
entry_free( e );
|
goto done;
|
||||||
return LDAP_PROTOCOL_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attr_merge( e, type, vals );
|
attr_merge( e, type, vals );
|
||||||
@ -118,17 +117,16 @@ do_add( Connection *conn, Operation *op )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
|
if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
|
||||||
entry_free( e );
|
|
||||||
Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
|
Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
|
||||||
send_ldap_disconnect( conn, op,
|
send_ldap_disconnect( conn, op,
|
||||||
LDAP_PROTOCOL_ERROR, "decoding error" );
|
LDAP_PROTOCOL_ERROR, "decoding error" );
|
||||||
return -1;
|
rc = -1;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
|
if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
|
||||||
entry_free( e );
|
|
||||||
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
|
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
|
||||||
return rc;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d ADD dn=\"%s\"\n",
|
Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d ADD dn=\"%s\"\n",
|
||||||
@ -141,10 +139,9 @@ do_add( Connection *conn, Operation *op )
|
|||||||
*/
|
*/
|
||||||
be = select_backend( e->e_ndn );
|
be = select_backend( e->e_ndn );
|
||||||
if ( be == NULL ) {
|
if ( be == NULL ) {
|
||||||
entry_free( e );
|
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL,
|
||||||
send_ldap_result( conn, op, LDAP_REFERRAL, NULL,
|
|
||||||
NULL, default_referral, NULL );
|
NULL, default_referral, NULL );
|
||||||
return rc;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure this backend recongizes critical controls */
|
/* make sure this backend recongizes critical controls */
|
||||||
@ -153,17 +150,15 @@ do_add( Connection *conn, Operation *op )
|
|||||||
if( rc != LDAP_SUCCESS ) {
|
if( rc != LDAP_SUCCESS ) {
|
||||||
send_ldap_result( conn, op, rc,
|
send_ldap_result( conn, op, rc,
|
||||||
NULL, NULL, NULL, NULL );
|
NULL, NULL, NULL, NULL );
|
||||||
entry_free( e );
|
goto done;
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( global_readonly || be->be_readonly ) {
|
if ( global_readonly || be->be_readonly ) {
|
||||||
Debug( LDAP_DEBUG_ANY, "do_add: database is read-only\n",
|
Debug( LDAP_DEBUG_ANY, "do_add: database is read-only\n",
|
||||||
0, 0, 0 );
|
0, 0, 0 );
|
||||||
entry_free( e );
|
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
|
||||||
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
|
|
||||||
NULL, "database is read-only", NULL, NULL );
|
NULL, "database is read-only", NULL, NULL );
|
||||||
return LDAP_UNWILLING_TO_PERFORM;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -191,11 +186,10 @@ do_add( Connection *conn, Operation *op )
|
|||||||
rc = add_created_attrs( op, e );
|
rc = add_created_attrs( op, e );
|
||||||
|
|
||||||
if( rc != LDAP_SUCCESS ) {
|
if( rc != LDAP_SUCCESS ) {
|
||||||
entry_free( e );
|
|
||||||
send_ldap_result( conn, op, rc,
|
send_ldap_result( conn, op, rc,
|
||||||
NULL, "no-user-modification attribute type",
|
NULL, "no-user-modification attribute type",
|
||||||
NULL, NULL );
|
NULL, NULL );
|
||||||
return rc;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,22 +202,26 @@ do_add( Connection *conn, Operation *op )
|
|||||||
replog( be, op, e->e_dn, e );
|
replog( be, op, e->e_dn, e );
|
||||||
}
|
}
|
||||||
be_entry_release_w( be, e );
|
be_entry_release_w( be, e );
|
||||||
|
e = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SLAPD_MULTIMASTER
|
#ifndef SLAPD_MULTIMASTER
|
||||||
} else {
|
} else {
|
||||||
entry_free( e );
|
|
||||||
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
|
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
|
||||||
be->be_update_refs ? be->be_update_refs : default_referral, NULL );
|
be->be_update_refs ? be->be_update_refs : default_referral, NULL );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Debug( LDAP_DEBUG_ARGS, " do_add: HHH\n", 0, 0, 0 );
|
Debug( LDAP_DEBUG_ARGS, " do_add: HHH\n", 0, 0, 0 );
|
||||||
entry_free( e );
|
|
||||||
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
|
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
|
||||||
NULL, "Function not implemented", NULL, NULL );
|
NULL, "Function not implemented", NULL, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if( e ) {
|
||||||
|
entry_free( e );
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user