Commit 37477ebe authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

CLDAP fixes

look harder for BDB 4.1
parent 05a8de77
......@@ -8,8 +8,10 @@ OpenLDAP 2.1.14 Engineering
Fixed back-bdb group/atttribute txn code (ITS#2122)
Fixed back-bdb modrdn subtree rename bug (ITS#2336)
Fixed client tools krb4 handling
Fixed (historic) CLDAP support (ITS#2335)
Updated slapadd to complain about holes in the DIT
Build Environment
Look harder for BDB 4.1 (ITS#2339)
Documentation
Misc man page updates
......
......@@ -314,8 +314,10 @@ AC_DEFUN([OL_BERKELEY_DB_LINK],
OL_BERKELEY_DB_TRY(ol_cv_db_none)
OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
......
This diff is collapsed.
......@@ -401,6 +401,9 @@ try_read1msg(
BerElement tmpber;
int rc, refer_cnt, hadref, simple_request;
ber_int_t lderr;
#ifdef LDAP_CONNECTIONLESS
int firstmsg = 1, moremsgs = 0, isv2 = 0;
#endif
/*
* v3ref = flag for V3 referral / search reference
* 0 = not a ref, 1 = sucessfully chased ref, -1 = pass ref to application
......@@ -435,7 +438,9 @@ retry2:
if ( LDAP_IS_UDP(ld) ) {
struct sockaddr from;
ber_int_sb_read(sb, &from, sizeof(struct sockaddr));
if (ld->ld_options.ldo_version == LDAP_VERSION2) isv2=1;
}
nextresp3:
#endif
if ( (tag = ber_get_next( sb, &len, ber ))
!= LDAP_TAG_MESSAGE ) {
......@@ -505,10 +510,10 @@ retry_ber:
goto retry_ber;
}
#ifdef LDAP_CONNECTIONLESS
if (LDAP_IS_UDP(ld) && ld->ld_options.ldo_version == LDAP_VERSION2) {
struct berval blank;
ber_scanf(ber, "m{", &blank);
if (LDAP_IS_UDP(ld) && isv2) {
ber_scanf(ber, "x{");
}
nextresp2:
#endif
/* the message type */
if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
......@@ -811,6 +816,84 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
new->lm_msgtype = tag;
new->lm_ber = ber;
#ifdef LDAP_CONNECTIONLESS
/* CLDAP replies all fit in a single datagram. In LDAPv2 RFC1798
* the responses are all a sequence wrapped in one message. In
* LDAPv3 each response is in its own message. The datagram must
* end with a SearchResult. We can't just parse each response in
* separate calls to try_read1msg because the header info is only
* present at the beginning of the datagram, not at the beginning
* of each response. So parse all the responses at once and queue
* them up, then pull off the first response to return to the
* caller when all parsing is complete.
*/
if ( LDAP_IS_UDP(ld) ) {
/* If not a result, look for more */
if ( tag != LDAP_RES_SEARCH_RESULT ) {
int ok = 0;
moremsgs = 1;
if (isv2) {
/* LDAPv2: dup the current ber, skip past the current
* response, and see if there are any more after it.
*/
ber = ber_dup( ber );
ber_scanf( ber, "x" );
if (ber_peek_tag(ber, &len) != LBER_DEFAULT) {
/* There's more - dup the ber buffer so they can all be
* individually freed by ldap_msgfree.
*/
struct berval bv;
ber_get_option(ber, LBER_OPT_BER_REMAINING_BYTES, &len);
bv.bv_val = LDAP_MALLOC(len);
if (bv.bv_val) {
ok=1;
ber_read(ber, bv.bv_val, len);
bv.bv_len = len;
ber_init2(ber, &bv, ld->ld_lberoptions );
}
}
} else {
/* LDAPv3: Just allocate a new ber. Since this is a buffered
* datagram, if the sockbuf is readable we still have data
* to parse.
*/
ber = ldap_alloc_ber_with_options(ld);
if (ber_sockbuf_ctrl(sb, LBER_SB_OPT_DATA_READY, NULL)) ok=1;
}
/* set up response chain */
if ( firstmsg ) {
firstmsg = 0;
new->lm_next = ld->ld_responses;
ld->ld_responses = new;
} else {
tmp->lm_chain = new;
}
tmp = new;
/* "ok" means there's more to parse */
if (ok) {
if (isv2) goto nextresp2;
else goto nextresp3;
} else {
/* got to end of datagram without a SearchResult. Free
* our dup'd ber, but leave any buffer alone. For v2 case,
* the previous response is still using this buffer. For v3,
* the new ber has no buffer to free yet.
*/
ber_free(ber, 0);
return -1;
}
} else if ( moremsgs ) {
/* got search result, and we had multiple responses in 1 datagram.
* stick the result onto the end of the chain, and then pull the
* first response off the head of the chain.
*/
tmp->lm_chain = new;
*result = chkResponseList( ld, msgid, all );
ld->ld_errno = LDAP_SUCCESS;
return( (*result)->lm_msgtype );
}
}
#endif
/* is this the one we're looking for? */
if ( msgid == LDAP_RES_ANY || id == msgid ) {
......
......@@ -1439,19 +1439,18 @@ connection_input(
op->o_pagedresults_state = conn->c_pagedresults_state;
#endif
#ifdef LDAP_CONNECTIONLESS
op->o_peeraddr = peeraddr;
if (cdn ) {
ber_str2bv( cdn, 0, 1, &op->o_dn );
op->o_protocol = LDAP_VERSION2;
}
if (conn->c_is_udp) {
int rc;
if ( cdn ) {
ber_str2bv( cdn, 0, 1, &op->o_dn );
op->o_protocol = LDAP_VERSION2;
}
op->o_res_ber = ber_alloc_t( LBER_USE_DER );
if (op->o_res_ber == NULL)
return 1;
rc = ber_write(op->o_res_ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
rc = ber_write(op->o_res_ber, (char *)&peeraddr, sizeof(struct sockaddr), 0);
if (rc != sizeof(struct sockaddr)) {
#ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, INFO,
......@@ -1463,8 +1462,8 @@ connection_input(
return 1;
}
if (conn->c_protocol == LDAP_VERSION2) {
rc = ber_printf(op->o_res_ber, "{i{" /*}}*/, op->o_msgid);
if (op->o_protocol == LDAP_VERSION2) {
rc = ber_printf(op->o_res_ber, "{is{" /*}}*/, op->o_msgid, "");
if (rc == -1) {
#ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, INFO,
......
......@@ -277,7 +277,7 @@ send_ldap_response(
}
#ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp && conn->c_protocol == LDAP_VERSION2) {
if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
rc = ber_printf( ber, "t{ess" /*"}}"*/,
tag, err,
matched == NULL ? "" : matched,
......@@ -328,6 +328,12 @@ send_ldap_response(
rc = ber_printf( ber, /*"{"*/ "N}" );
}
#ifdef LDAP_CONNECTIONLESS
if( conn->c_is_udp && op->o_protocol == LDAP_VERSION2 && rc != -1 ) {
rc = ber_printf( ber, /*"{"*/ "N}" );
}
#endif
if ( rc == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
......@@ -774,8 +780,8 @@ slap_send_search_entry(
ber_init_w_nullc( ber, LBER_USE_DER );
#ifdef LDAP_CONNECTIONLESS
if (conn->c_is_udp && conn->c_protocol == LDAP_VERSION2) {
rc = ber_printf(ber, "t{0{" /*}}*/,
if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
rc = ber_printf(ber, "t{O{" /*}}*/,
LDAP_RES_SEARCH_ENTRY, &e->e_name);
} else
#endif
......@@ -1250,6 +1256,11 @@ slap_send_search_entry(
rc = send_ldap_controls( ber, ctrls );
}
#ifdef LDAP_CONNECTIONLESS
if( conn->c_is_udp && op->o_protocol == LDAP_VERSION2 ) {
; /* empty, skip following if */
} else
#endif
if( rc != -1 ) {
rc = ber_printf( ber, /*{*/ "N}" );
}
......
......@@ -1744,9 +1744,6 @@ typedef struct slap_op {
LDAP_LIST_ENTRY(slap_op) link;
#endif
#ifdef LDAP_CONNECTIONLESS
Sockaddr o_peeraddr; /* UDP peer address */
#endif
AuthorizationInformation o_authz;
BerElement *o_ber; /* ber of the request */
......
Markdown is supported
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