return tag;
}
-static void trim_refs_urls(
- struct berval **refs )
-{
- unsigned i;
-
- if( refs == NULL ) return;
-
- for( i=0; refs[i] != NULL; i++ ) {
- if( refs[i]->bv_len > sizeof("ldap://")-1 &&
- strncasecmp( refs[i]->bv_val, "ldap://",
- sizeof("ldap://")-1 ) == 0 )
- {
- unsigned j;
- for( j=sizeof("ldap://")-1; j<refs[i]->bv_len ; j++ ) {
- if( refs[i]->bv_val[j] == '/' ) {
- refs[i]->bv_val[j] = '\0';
- refs[i]->bv_len = j;
- break;
- }
- }
- }
- }
-}
-
-struct berval **get_entry_referrals(
- Backend *be,
- Connection *conn,
- Operation *op,
- Entry *e )
-{
- Attribute *attr;
- struct berval **refs;
- unsigned i, j;
-
- AttributeDescription *ad_ref = slap_schema.si_ad_ref;
-
- attr = attr_find( e->e_attrs, ad_ref );
-
- if( attr == NULL ) return NULL;
-
- for( i=0; attr->a_vals[i] != NULL; i++ ) {
- /* count references */
- }
-
- if( i < 1 ) return NULL;
-
- refs = ch_malloc( (i + 1) * sizeof(struct berval *));
-
- for( i=0, j=0; attr->a_vals[i] != NULL; i++ ) {
- unsigned k;
- struct berval *ref = ber_bvdup( attr->a_vals[i] );
-
- /* trim the label */
- for( k=0; k<ref->bv_len; k++ ) {
- if( isspace(ref->bv_val[k]) ) {
- ref->bv_val[k] = '\0';
- ref->bv_len = k;
- break;
- }
- }
-
- if( ref->bv_len > 0 ) {
- refs[j++] = ref;
-
- } else {
- ber_bvfree( ref );
- }
- }
-
- refs[j] = NULL;
-
- if( j == 0 ) {
- ber_bvecfree( refs );
- refs = NULL;
- }
-
- /* we should check that a referral value exists... */
-
- return refs;
-}
-
static long send_ldap_ber(
Connection *conn,
BerElement *ber )
return;
}
- rc = ber_printf( ber, "{it{ess",
+#ifdef LDAP_CONNECTIONLESS
+ if (conn->c_is_udp) {
+ rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
+ if (rc != sizeof(struct sockaddr)) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+ "send_ldap_response: conn %d ber_write failed\n",
+ conn ? conn->c_connid : 0 ));
+#else
+ Debug( LDAP_DEBUG_ANY, "ber_write failed\n", 0, 0, 0 );
+#endif
+ ber_free(ber, 1);
+ return;
+ }
+ }
+ if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
+ rc = ber_printf( ber, "{is{t{ess",
+ msgid, "", tag, err,
+ matched == NULL ? "" : matched,
+ text == NULL ? "" : text );
+ } else
+#endif
+ {
+ rc = ber_printf( ber, "{it{ess",
msgid, tag, err,
matched == NULL ? "" : matched,
text == NULL ? "" : text );
+ }
if( rc != -1 ) {
if ( ref != NULL ) {
if( rc != -1 ) {
rc = ber_printf( ber, "N}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
if( ref ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
- "send_ldap_result: referral=\"%s\"\n",
- ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL" ));
+ "send_ldap_result: referral=\"%s\"\n",
+ ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL" ));
#else
Debug( LDAP_DEBUG_ARGS,
"send_ldap_result: referral=\"%s\"\n",
ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL",
NULL, NULL );
#endif
-
}
assert( err != LDAP_PARTIAL_RESULTS );
- if( op->o_tag != LDAP_REQ_SEARCH ) {
- trim_refs_urls( ref );
- }
-
if ( err == LDAP_REFERRAL ) {
if( ref == NULL ) {
err = LDAP_NO_SUCH_OBJECT;
assert( err != LDAP_PARTIAL_RESULTS );
- trim_refs_urls( refs );
-
if( op->o_protocol < LDAP_VERSION3 ) {
/* send references in search results */
if( err == LDAP_REFERRAL ) {
goto error_return;
}
- rc = ber_printf( ber, "{it{s{" /*}}}*/, op->o_msgid,
+#ifdef LDAP_CONNECTIONLESS
+ if (conn->c_is_udp) {
+ rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
+ if (rc != sizeof(struct sockaddr)) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+ "send_search_entry: conn %d ber_printf failed\n",
+ conn ? conn->c_connid : 0 ));
+#else
+ Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
+#endif
+ ber_free(ber, 1);
+ return;
+ }
+ }
+ if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
+ rc = ber_printf( ber, "{is{t{s{",
+ op->o_msgid, "", LDAP_RES_SEARCH_ENTRY, e->e_dn );
+ } else
+#endif
+ {
+ rc = ber_printf( ber, "{it{s{" /*}}}*/, op->o_msgid,
LDAP_RES_SEARCH_ENTRY, e->e_dn );
+ }
if ( rc == -1 ) {
#ifdef NEW_LOGGING
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
AttributeDescription *desc = a->a_desc;
- char *type = desc->ad_cname->bv_val;
+ char *type = desc->ad_cname.bv_val;
if ( attrs == NULL ) {
/* all addrs request, skip operational attributes */
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
"send_search_entry: conn %d access to attribute %s not allowed\n",
- op->o_connid, desc->ad_cname->bv_val ));
+ op->o_connid, desc->ad_cname.bv_val ));
#else
Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n",
- desc->ad_cname->bv_val, 0, 0 );
+ desc->ad_cname.bv_val, 0, 0 );
#endif
continue;
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
"send_search_entry: conn %d access to attribute %s, value %d not allowed\n",
- op->o_connid, desc->ad_cname->bv_val, i ));
+ op->o_connid, desc->ad_cname.bv_val, i ));
#else
Debug( LDAP_DEBUG_ACL,
"acl: access to attribute %s, value %d not allowed\n",
- desc->ad_cname->bv_val, i, 0 );
+ desc->ad_cname.bv_val, i, 0 );
#endif
continue;
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
"send_search_entry: conn %s access to attribute %s not allowed\n",
- op->o_connid, desc->ad_cname->bv_val ));
+ op->o_connid, desc->ad_cname.bv_val ));
#else
Debug( LDAP_DEBUG_ACL, "acl: access to attribute %s not allowed\n",
- desc->ad_cname->bv_val, 0, 0 );
+ desc->ad_cname.bv_val, 0, 0 );
#endif
continue;
}
- rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname->bv_val );
+ rc = ber_printf( ber, "{s[" /*]}*/ , desc->ad_cname.bv_val );
if ( rc == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding description error", NULL, NULL );
+ attrs_free( aa );
goto error_return;
}
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
"send_search_entry: conn %d access to %s, value %d not allowed\n",
- op->o_connid, desc->ad_cname->bv_val, i ));
+ op->o_connid, desc->ad_cname.bv_val, i ));
#else
Debug( LDAP_DEBUG_ACL,
"acl: access to attribute %s, value %d not allowed\n",
- desc->ad_cname->bv_val, i, 0 );
+ desc->ad_cname.bv_val, i, 0 );
#endif
continue;
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding values error", NULL, NULL );
+ attrs_free( aa );
goto error_return;
}
}
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode end error", NULL, NULL );
+ attrs_free( aa );
goto error_return;
}
}
rc = ber_printf( ber, /*{{{*/ "}N}N}" );
+#ifdef LDAP_CONNECTIONLESS
+ if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2 && rc != -1)
+ rc = ber_printf( ber, "}" );
+#endif
if ( rc == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
Operation *op,
Entry *e,
struct berval **refs,
- int scope,
LDAPControl **ctrls,
struct berval ***v2refs
)
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
- "send_search_reference: conn %d dn=\"%s\"\n",
- op->o_connid, e->e_dn ));
+ "send_search_reference: conn %d dn=\"%s\"\n",
+ op->o_connid, e->e_dn ));
#else
Debug( LDAP_DEBUG_TRACE,
"=> send_search_reference: dn=\"%s\"\n",
{
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
- "send_search_reference: conn %d access to entry %s not allowed\n",
- op->o_connid, e->e_dn ));
+ "send_search_reference: conn %d access to entry %s not allowed\n",
+ op->o_connid, e->e_dn ));
#else
Debug( LDAP_DEBUG_ACL,
"send_search_reference: access to entry not allowed\n",
{
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
- "send_search_reference: conn %d access to reference not allowed.\n",
- op->o_connid ));
+ "send_search_reference: conn %d access to reference not allowed.\n",
+ op->o_connid ));
#else
Debug( LDAP_DEBUG_ACL,
"send_search_reference: access to reference not allowed\n",
if( refs == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
- "send_search_reference: null ref in (%s).\n",
- op->o_connid, e->e_dn ));
+ "send_search_reference: null ref in (%s).\n",
+ op->o_connid, e->e_dn ));
#else
Debug( LDAP_DEBUG_ANY,
"send_search_reference: null ref in (%s)\n",
if ( ber == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
- "send_search_reference: conn %d ber_alloc failed\n",
- op->o_connid ));
+ "send_search_reference: conn %d ber_alloc failed\n",
+ op->o_connid ));
#else
Debug( LDAP_DEBUG_ANY,
"send_search_reference: ber_alloc failed\n", 0, 0, 0 );
if ( rc == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
- "send_search_reference: conn %d ber_printf failed.\n",
- op->o_connid ));
+ "send_search_reference: conn %d ber_printf failed.\n",
+ op->o_connid ));
#else
Debug( LDAP_DEBUG_ANY,
"send_search_reference: ber_printf failed\n", 0, 0, 0 );
num_pdu_sent++;
ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
- Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld ENTRY dn=\"%s\"\n",
- (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 );
+ Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld REF dn=\"%s\"\n",
+ (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 );
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
- "send_search_reference: conn %d exit.\n", op->o_connid ));
+ "send_search_reference: conn %d exit.\n", op->o_connid ));
#else
Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 );
#endif
-
return 0;
}