From: Kurt Zeilenga Date: Wed, 10 Jan 2001 23:48:24 +0000 (+0000) Subject: Rework scope defaulting to only default scope for references. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1603 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a0828d6135945077d0e3d23e4327873a578a4ce9;p=openldap Rework scope defaulting to only default scope for references. Might break LDAPv2 partial results --- diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index f2dcea3488..9ed399fae4 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -442,8 +442,10 @@ LDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr ); LDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); LDAP_F (void) ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all ); LDAP_F (void) ldap_dump_requests_and_responses( LDAP *ld ); -LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ); -LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char **referralsp, int *hadrefp ); +LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, + char **errstrp, int sref, int *hadrefp ); +LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, + char **refs, int sref, char **referralsp, int *hadrefp ); LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s ); /* diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 880b0015bc..b1e7e170c2 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -49,6 +49,7 @@ static BerElement * re_encode_request( LDAP *ld, BerElement *origber, ber_int_t msgid, + int sref, LDAPURLDesc *srv, int *type ); @@ -626,7 +627,7 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * /* parse out & follow referrals */ for( i=0; refarray[i] != NULL; i++) { /* Parse the referral URL */ - if (( rc = ldap_url_parse( refarray[i], &srv)) != LDAP_SUCCESS) { + if (( rc = ldap_url_parse_ext( refarray[i], &srv)) != LDAP_SUCCESS) { ld->ld_errno = rc; rc = -1; goto done; @@ -655,7 +656,8 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * * if two search references come in one behind the other * for the same server with different contexts. */ - Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referrals: queue referral \"%s\"\n", + Debug( LDAP_DEBUG_TRACE, + "ldap_chase_v3referrals: queue referral \"%s\"\n", refarray[i], 0, 0); if( lc->lconn_rebind_queue == NULL ) { /* Create a referral list */ @@ -700,14 +702,17 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char * srv->lud_dn = LDAP_STRDUP( "" ); } - if (( ber = re_encode_request( ld, origreq->lr_ber, - ++ld->ld_msgid, srv, &rinfo.ri_request )) == NULL ) { + ber = re_encode_request( ld, origreq->lr_ber, ++ld->ld_msgid, + sref, srv, &rinfo.ri_request ); + + if( ber == NULL ) { ld->ld_errno = LDAP_ENCODING_ERROR; rc = -1; goto done; } - Debug( LDAP_DEBUG_TRACE, "ldap_chase_v3referral: msgid %d, url \"%s\"\n", + Debug( LDAP_DEBUG_TRACE, + "ldap_chase_v3referral: msgid %d, url \"%s\"\n", lr->lr_msgid, refarray[i], 0); /* Send the new request to the server - may require a bind */ @@ -781,7 +786,11 @@ done: * XXX merging of errors in this routine needs to be improved */ int -ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) +ldap_chase_referrals( LDAP *ld, + LDAPRequest *lr, + char **errstrp, + int sref, + int *hadrefp ) { int rc, count, len; char *p, *ref, *unfollowed; @@ -858,7 +867,7 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) *hadrefp = 1; ber = re_encode_request( ld, origreq->lr_ber, - ++ld->ld_msgid, srv, &rinfo.ri_request ); + ++ld->ld_msgid, sref, srv, &rinfo.ri_request ); if( ber == NULL ) { return -1 ; @@ -929,6 +938,7 @@ static BerElement * re_encode_request( LDAP *ld, BerElement *origber, ber_int_t msgid, + int sref, LDAPURLDesc *srv, int *type ) { @@ -981,7 +991,7 @@ re_encode_request( LDAP *ld, /* use the scope provided in reference */ scope = srv->lud_scope; - } else if ( scope != LDAP_SCOPE_SUBTREE ) { + } else if ( sref && scope != LDAP_SCOPE_SUBTREE ) { /* use scope implied by previous operation */ /* base -> base */ /* one -> base */ diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 75f89e0747..f9e70a2cf2 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -334,7 +334,7 @@ try_read1msg( ber_int_t msgid, int all, Sockbuf *sb, - LDAPConn *lc, + LDAPConn *lc, LDAPMessage **result ) { BerElement *ber; @@ -426,7 +426,8 @@ try_read1msg( return( -1 ); } - Debug( LDAP_DEBUG_TRACE, "ldap_read: message type %s msgid %ld, original id %ld\n", + Debug( LDAP_DEBUG_TRACE, + "ldap_read: message type %s msgid %ld, original id %ld\n", ldap_int_msgtype2str( tag ), (long) lr->lr_msgid, (long) lr->lr_origid ); @@ -534,14 +535,13 @@ try_read1msg( tmpber = *ber; /* struct copy */ if ( v3ref == 1 ) { ; /* V3 search reference or V3 referral sucessfully chased */ - } else - if ( ber_scanf( &tmpber, "{iaa}", &lderr, + } else if ( ber_scanf( &tmpber, "{iaa}", &lderr, &lr->lr_res_matched, &lr->lr_res_error ) != LBER_ERROR ) { if ( lderr != LDAP_SUCCESS ) { /* referrals are in error string */ refer_cnt = ldap_chase_referrals( ld, lr, - &lr->lr_res_error, &hadref ); + &lr->lr_res_error, -1, &hadref ); lr->lr_status = LDAP_REQST_COMPLETED; Debug( LDAP_DEBUG_TRACE, "read1msg: V2 referral chased, mark request completed, id = %d\n", lr->lr_msgid, 0, 0);