mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
Add backend_check_referrals() framework.
This commit is contained in:
parent
3a0c301b07
commit
6f378341a2
@ -18,7 +18,6 @@
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
#include <ac/socket.h>
|
||||
@ -45,6 +44,7 @@ do_add( Connection *conn, Operation *op )
|
||||
Modifications *mods = NULL;
|
||||
const char *text;
|
||||
int rc = LDAP_SUCCESS;
|
||||
struct berval **urls = NULL;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
|
||||
|
||||
@ -134,8 +134,7 @@ do_add( Connection *conn, Operation *op )
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ( modlist == NULL )
|
||||
{
|
||||
if ( modlist == NULL ) {
|
||||
send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
|
||||
NULL, "no attributes provided", NULL, NULL );
|
||||
goto done;
|
||||
@ -158,13 +157,21 @@ do_add( Connection *conn, Operation *op )
|
||||
|
||||
/* make sure this backend recongizes critical controls */
|
||||
rc = backend_check_controls( be, conn, op, &text ) ;
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* check for referrals */
|
||||
rc = backend_check_referrals( be, conn, op, &urls, &text );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, urls, NULL );
|
||||
ber_bvecfree( urls );
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ( global_readonly || be->be_readonly ) {
|
||||
Debug( LDAP_DEBUG_ANY, "do_add: database is read-only\n",
|
||||
0, 0, 0 );
|
||||
|
@ -615,6 +615,23 @@ backend_check_controls(
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
|
||||
int backend_check_referrals(
|
||||
Backend *be,
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
struct berval ***bv,
|
||||
const char **text )
|
||||
{
|
||||
*bv = NULL;
|
||||
|
||||
if( be->be_chk_referrals ) {
|
||||
return be->be_chk_referrals( be,
|
||||
conn, op, bv, text );
|
||||
}
|
||||
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
backend_group(
|
||||
Backend *be,
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ac/socket.h>
|
||||
|
||||
#include "ldap_pvt.h"
|
||||
@ -37,6 +36,7 @@ do_compare(
|
||||
AttributeAssertion ava;
|
||||
Backend *be;
|
||||
int rc = LDAP_SUCCESS;
|
||||
struct berval **urls = NULL;
|
||||
const char *text = NULL;
|
||||
|
||||
ava.aa_desc = NULL;
|
||||
@ -94,6 +94,35 @@ do_compare(
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* We could be serving multiple database backends. Select the
|
||||
* appropriate one, or send a referral to our "referral server"
|
||||
* if we don't hold it.
|
||||
*/
|
||||
if ( (be = select_backend( ndn )) == NULL ) {
|
||||
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
|
||||
NULL, NULL, default_referral, NULL );
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* make sure this backend recongizes critical controls */
|
||||
rc = backend_check_controls( be, conn, op, &text ) ;
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* check for referrals */
|
||||
rc = backend_check_referrals( be, conn, op, &urls, &text );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, urls, NULL );
|
||||
ber_bvecfree( urls );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = slap_bv2ad( &desc, &ava.aa_desc, &text );
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc, NULL,
|
||||
@ -125,28 +154,6 @@ do_compare(
|
||||
op->o_connid, op->o_opid, dn, ava.aa_desc->ad_cname->bv_val, 0 );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* We could be serving multiple database backends. Select the
|
||||
* appropriate one, or send a referral to our "referral server"
|
||||
* if we don't hold it.
|
||||
*/
|
||||
if ( (be = select_backend( ndn )) == NULL ) {
|
||||
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
|
||||
NULL, NULL, default_referral, NULL );
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* make sure this backend recongizes critical controls */
|
||||
rc = backend_check_controls( be, conn, op, &text ) ;
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* deref suffix alias if appropriate */
|
||||
ndn = suffix_alias( be, ndn );
|
||||
|
||||
|
@ -33,6 +33,7 @@ do_delete(
|
||||
{
|
||||
char *dn, *ndn = NULL;
|
||||
const char *text;
|
||||
struct berval **urls = NULL;
|
||||
Backend *be;
|
||||
int rc;
|
||||
|
||||
@ -81,13 +82,21 @@ do_delete(
|
||||
|
||||
/* make sure this backend recongizes critical controls */
|
||||
rc = backend_check_controls( be, conn, op, &text ) ;
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* check for referrals */
|
||||
rc = backend_check_referrals( be, conn, op, &urls, &text );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, urls, NULL );
|
||||
ber_bvecfree( urls );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ( global_readonly || be->be_readonly ) {
|
||||
Debug( LDAP_DEBUG_ANY, "do_delete: database is read-only\n",
|
||||
0, 0, 0 );
|
||||
|
@ -27,12 +27,10 @@
|
||||
#include "slap.h"
|
||||
|
||||
|
||||
|
||||
int
|
||||
do_modify(
|
||||
Connection *conn,
|
||||
Operation *op
|
||||
)
|
||||
Operation *op )
|
||||
{
|
||||
char *dn, *ndn = NULL;
|
||||
char *last;
|
||||
@ -47,6 +45,7 @@ do_modify(
|
||||
Backend *be;
|
||||
int rc;
|
||||
const char *text;
|
||||
struct berval **urls;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
|
||||
|
||||
@ -129,8 +128,6 @@ do_modify(
|
||||
}
|
||||
|
||||
(*modtail)->ml_op = mop;
|
||||
|
||||
|
||||
modtail = &(*modtail)->ml_next;
|
||||
}
|
||||
*modtail = NULL;
|
||||
@ -159,7 +156,6 @@ do_modify(
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MOD dn=\"%s\"\n",
|
||||
op->o_connid, op->o_opid, dn, 0, 0 );
|
||||
|
||||
@ -183,11 +179,20 @@ do_modify(
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* check for referrals */
|
||||
rc = backend_check_referrals( be, conn, op, &urls, &text );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, urls, NULL );
|
||||
ber_bvecfree( urls );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ( global_readonly || be->be_readonly ) {
|
||||
Debug( LDAP_DEBUG_ANY, "do_modify: database is read-only\n",
|
||||
0, 0, 0 );
|
||||
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
|
||||
NULL, "directory is read-only", NULL, NULL );
|
||||
NULL, "directory is read-only", NULL, NULL );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ do_modrdn(
|
||||
ber_len_t length;
|
||||
int rc;
|
||||
const char *text;
|
||||
struct berval **urls = NULL;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
|
||||
|
||||
@ -167,13 +168,21 @@ do_modrdn(
|
||||
|
||||
/* make sure this backend recongizes critical controls */
|
||||
rc = backend_check_controls( be, conn, op, &text ) ;
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* check for referrals */
|
||||
rc = backend_check_referrals( be, conn, op, &urls, &text );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, urls, NULL );
|
||||
ber_bvecfree( urls );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ( global_readonly || be->be_readonly ) {
|
||||
Debug( LDAP_DEBUG_ANY, "do_modrdn: database is read-only\n",
|
||||
0, 0, 0 );
|
||||
|
@ -155,6 +155,13 @@ LIBSLAPD_F( int ) backend_check_controls LDAP_P((
|
||||
Operation *op,
|
||||
const char **text ));
|
||||
|
||||
LIBSLAPD_F( int ) backend_check_referrals LDAP_P((
|
||||
Backend *be,
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
struct berval ***bv,
|
||||
const char **text ));
|
||||
|
||||
LIBSLAPD_F (int) backend_connection_init LDAP_P((Connection *conn));
|
||||
LIBSLAPD_F (int) backend_connection_destroy LDAP_P((Connection *conn));
|
||||
|
||||
|
@ -25,13 +25,11 @@
|
||||
#include "ldap_pvt.h"
|
||||
#include "slap.h"
|
||||
|
||||
|
||||
int
|
||||
do_search(
|
||||
Connection *conn, /* where to send results */
|
||||
Operation *op /* info about the op to which we're responding */
|
||||
)
|
||||
{
|
||||
) {
|
||||
int i;
|
||||
ber_int_t scope, deref, attrsonly;
|
||||
ber_int_t sizelimit, timelimit;
|
||||
@ -41,6 +39,7 @@ do_search(
|
||||
Backend *be;
|
||||
int rc;
|
||||
const char *text;
|
||||
struct berval **urls = NULL;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
|
||||
|
||||
@ -218,13 +217,21 @@ do_search(
|
||||
|
||||
/* make sure this backend recongizes critical controls */
|
||||
rc = backend_check_controls( be, conn, op, &text ) ;
|
||||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/* check for referrals */
|
||||
rc = backend_check_referrals( be, conn, op, &urls, &text );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, urls, NULL );
|
||||
ber_bvecfree( urls );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/* deref the base if needed */
|
||||
nbase = suffix_alias( be, nbase );
|
||||
|
||||
|
@ -743,6 +743,7 @@ struct slap_backend_db {
|
||||
#define be_extended bd_info->bi_extended
|
||||
|
||||
#define be_release bd_info->bi_entry_release_rw
|
||||
#define be_chk_referrals bd_info->bi_chk_referrals
|
||||
#define be_group bd_info->bi_acl_group
|
||||
|
||||
#define be_controls bd_info->bi_controls
|
||||
@ -907,6 +908,11 @@ struct slap_backend_info {
|
||||
/* Auxilary Functions */
|
||||
int (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw));
|
||||
|
||||
int (*bi_chk_referrals) LDAP_P((BackendDB *bd,
|
||||
struct slap_conn *c, struct slap_op *o,
|
||||
struct berval ***urls,
|
||||
const char **text ));
|
||||
|
||||
int (*bi_acl_group) LDAP_P((Backend *bd,
|
||||
Entry *e, const char *bdn, const char *edn,
|
||||
ObjectClass *group_oc,
|
||||
|
Loading…
Reference in New Issue
Block a user