/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2003 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
* Portions Copyright 2000-2003 Kurt D. Zeilenga.
* All rights reserved.
*
#include <ac/socket.h>
#include "slap.h"
-#include "external.h"
+#include "proto-dnssrv.h"
int
dnssrv_back_referrals(
char **hosts = NULL;
BerVarray urls = NULL;
- if( op->o_req_dn.bv_len == 0 ) {
+ if ( BER_BVISEMPTY( &op->o_req_dn ) ) {
+#ifdef LDAP_DEVEL
+ /* FIXME: need some means to determine whether the database
+ * is a glue instance */
+ if ( SLAP_GLUE_INSTANCE( op->o_bd ) ) {
+ return LDAP_SUCCESS;
+ }
+#endif /* LDAP_DEVEL */
+
rs->sr_text = "DNS SRV operation upon null (empty) DN disallowed";
return LDAP_UNWILLING_TO_PERFORM;
}
rs->sr_err = LDAP_REFERRAL;
rs->sr_ref = default_referral;
send_ldap_result( op, rs );
+ rs->sr_ref = NULL;
return LDAP_REFERRAL;
}
Debug( LDAP_DEBUG_TRACE, "DNSSRV: dn=\"%s\" -> domain=\"%s\"\n",
op->o_req_dn.bv_val, domain, 0 );
- if( ( rc = ldap_domain2hostlist( domain, &hostlist ) ) ) {
+ i = ldap_domain2hostlist( domain, &hostlist );
+ if ( i ) {
Debug( LDAP_DEBUG_TRACE,
"DNSSRV: domain2hostlist(%s) returned %d\n",
- domain, rc, 0 );
+ domain, i, 0 );
rs->sr_text = "no DNS SRV RR available for DN";
rc = LDAP_NO_SUCH_OBJECT;
goto done;
for( i=0; hosts[i] != NULL; i++) {
struct berval url;
- url.bv_len = sizeof("ldap://")-1 + strlen(hosts[i]);
+ url.bv_len = STRLENOF( "ldap://" ) + strlen( hosts[i] );
url.bv_val = ch_malloc( url.bv_len + 1 );
strcpy( url.bv_val, "ldap://" );
- strcpy( &url.bv_val[sizeof("ldap://")-1], hosts[i] );
+ strcpy( &url.bv_val[STRLENOF( "ldap://" )], hosts[i] );
if ( ber_bvarray_add( &urls, &url ) < 0 ) {
free( url.bv_val );
}
Statslog( LDAP_DEBUG_STATS,
- "conn=%lu op=%lu DNSSRV p=%d dn=\"%s\" url=\"%s\"\n",
- op->o_connid, op->o_opid, op->o_protocol,
- op->o_req_dn.bv_val, urls[0].bv_val );
+ "%s DNSSRV p=%d dn=\"%s\" url=\"%s\"\n",
+ op->o_log_prefix, op->o_protocol,
+ op->o_req_dn.bv_val, urls[0].bv_val, 0 );
Debug( LDAP_DEBUG_TRACE, "DNSSRV: dn=\"%s\" -> url=\"%s\"\n",
op->o_req_dn.bv_val, urls[0].bv_val, 0 );
rs->sr_ref = urls;
send_ldap_error( op, rs, LDAP_REFERRAL,
"DNS SRV generated referrals" );
+ rs->sr_ref = NULL;
+ rc = LDAP_REFERRAL;
done:
if( domain != NULL ) ch_free( domain );