Commit f9db1ea8 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Rework BER decoding with lieu of LDAPv3 controls (coming soon).

Add place holder for handling LDAPv3 extended operations (coming soon).
parent 42d53c49
......@@ -38,10 +38,17 @@ do_abandon(
*/
if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0 ,0 );
Debug( LDAP_DEBUG_ANY, "do_abandon: ber_scanf failed\n", 0, 0 ,0 );
return;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 0 ) == -1 ) {
Debug( LDAP_DEBUG_ANY, "do_abandon: get_ctrls failed\n", 0, 0 ,0 );
return;
}
#endif
Debug( LDAP_DEBUG_ARGS, "do_abandon: id %d\n", id, 0 ,0 );
/*
......
......@@ -48,7 +48,7 @@ do_add( Connection *conn, Operation *op )
/* get the name */
if ( ber_scanf( ber, "{a", /*}*/ &dn ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
return;
......@@ -94,6 +94,22 @@ do_add( Connection *conn, Operation *op )
ber_bvecfree( vals );
}
if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
entry_free( e );
Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
return;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
entry_free( e );
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
return;
}
#endif
Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d ADD dn=\"%s\"\n",
conn->c_connid, op->o_opid, e->e_ndn, 0, 0 );
......
......@@ -60,6 +60,22 @@ do_bind(
return;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
if ( cdn != NULL ) {
free( cdn );
}
if ( ndn != NULL ) {
free( ndn );
}
if ( cred.bv_val != NULL ) {
free( cred.bv_val );
}
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
return;
}
#endif
Debug( LDAP_DEBUG_TRACE, "do_bind: version %d dn (%s) method %d\n",
version, cdn, method );
......
......@@ -48,6 +48,16 @@ do_compare(
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
return;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
free( ndn );
ava_free( &ava, 0 );
Debug( LDAP_DEBUG_ANY, "do_compare: get_ctrls failed\n", 0, 0, 0 );
return;
}
#endif
value_normalize( ava.ava_value.bv_val, attr_syntax( ava.ava_type ) );
Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
......
......@@ -647,6 +647,12 @@ connection_operation( void *arg_v )
do_abandon( conn, arg->co_op );
break;
#if 0
case LDAP_REQ_EXTENDED:
do_extended( conn, arg->co_op );
break;
#endif
default:
Debug( LDAP_DEBUG_ANY, "unknown request 0x%lx\n",
arg->co_op->o_tag, 0, 0 );
......
......@@ -42,6 +42,14 @@ do_delete(
return;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
free( ndn );
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
return;
}
#endif
Debug( LDAP_DEBUG_ARGS, "do_delete: dn (%s)\n", ndn, 0, 0 );
dn_normalize_case( ndn );
......
......@@ -133,6 +133,15 @@ do_modify(
}
#endif
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
free( ndn );
modlist_free( modlist );
Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
return;
}
#endif
Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d MOD dn=\"%s\"\n",
conn->c_connid, op->o_opid, ndn, 0, 0 );
......
......@@ -67,11 +67,6 @@ do_modrdn(
return;
}
Debug( LDAP_DEBUG_ARGS,
"do_modrdn: dn (%s) newrdn (%s) deloldrdn (%d)\n", ndn, newrdn,
deloldrdn );
/* Check for newSuperior parameter, if present scan it */
if ( ber_peek_tag( op->o_ber, &length ) == LDAP_TAG_NEWSUPERIOR ) {
......@@ -97,7 +92,7 @@ do_modrdn(
return;
}
if ( ber_scanf( op->o_ber, /*{*/ "a}", &newSuperior )
if ( ber_scanf( op->o_ber, "a", &newSuperior )
== LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\"}) failed\n",
......@@ -108,10 +103,34 @@ do_modrdn(
}
}
Debug( LDAP_DEBUG_ARGS, "do_modrdn: newSuperior=(%s)\n",
newSuperior, 0, 0 );
Debug( LDAP_DEBUG_ARGS,
"do_modrdn: dn (%s) newrdn (%s) newsuperior (%s)\n",
ndn, newrdn,
newSuperior != NULL ? newSuperior : "" );
if ( ber_scanf( op->o_ber, /*{*/ "}") == LBER_ERROR ) {
free( ndn );
free( newrdn );
free( newSuperior );
Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
return;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
free( ndn );
free( newrdn );
free( newSuperior );
Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
return;
}
#endif
if( newSuperior != NULL ) {
/* GET BACKEND FOR NEW SUPERIOR */
nnewSuperior = strdup( newSuperior );
......@@ -125,7 +144,6 @@ do_modrdn(
* XXX: We may need to do something else here, not sure
* what though.
*/
Debug( LDAP_DEBUG_ARGS,
"do_modrdn: cant find backend for=(%s)\n",
......@@ -138,9 +156,7 @@ do_modrdn(
send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
default_referral );
return;
}
}
dn_normalize_case( ndn );
......
......@@ -120,6 +120,14 @@ int charray_inlist LDAP_P(( char **a, char *s ));
char ** charray_dup LDAP_P(( char **a ));
char ** str2charray LDAP_P(( char *str, char *brkstr ));
/*
* controls.c
*/
int get_ctrls LDAP_P((
Connection *co,
Operation *op,
int senderrors ));
/*
* config.c
*/
......
......@@ -93,13 +93,22 @@ do_search(
goto return_results;
}
#ifdef GET_CTRLS
if( get_ctrls( conn, op, 1 ) == -1 ) {
Debug( LDAP_DEBUG_ANY, "do_search: get_ctrls failed\n", 0, 0, 0 );
goto return_results;
}
#endif
Debug( LDAP_DEBUG_ARGS, " attrs:", 0, 0, 0 );
if ( attrs != NULL ) {
for ( i = 0; attrs[i] != NULL; i++ ) {
attr_normalize( attrs[i] );
Debug( LDAP_DEBUG_ARGS, " %s", attrs[i], 0, 0 );
}
}
Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 );
Statslog( LDAP_DEBUG_STATS,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment