From f9db1ea88905734aef29cac9eb6bfffd5420e14e Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 30 Jun 1999 22:43:27 +0000 Subject: [PATCH] Rework BER decoding with lieu of LDAPv3 controls (coming soon). Add place holder for handling LDAPv3 extended operations (coming soon). --- servers/slapd/abandon.c | 9 ++++++++- servers/slapd/add.c | 18 +++++++++++++++++- servers/slapd/bind.c | 16 ++++++++++++++++ servers/slapd/compare.c | 10 ++++++++++ servers/slapd/connection.c | 6 ++++++ servers/slapd/delete.c | 8 ++++++++ servers/slapd/modify.c | 9 +++++++++ servers/slapd/modrdn.c | 38 +++++++++++++++++++++++++++----------- servers/slapd/proto-slap.h | 8 ++++++++ servers/slapd/search.c | 9 +++++++++ 10 files changed, 118 insertions(+), 13 deletions(-) diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index d6b4704d32..5678589bb9 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -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 ); /* diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 60e43f70e7..6293b44ebb 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -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 ); diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index ee532b1444..db49a320e6 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -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 ); diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 0d1c50abdb..2709e00c29 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -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", diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index dd56160232..bd3f1848ac 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -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 ); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index be9b1179ea..3774ca8db0 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -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 ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 345dc5f36b..5722c82ced 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -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 ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 33a4bc35b7..27e7a100f2 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -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 ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 3f7da34a9a..6c60096a47 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 */ diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 584a7b8882..c0fef8bf6f 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.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, -- 2.39.5