2004-07-27 05:26:34 +08:00
|
|
|
/* frontend.c - routines for dealing with frontend */
|
2008-02-12 06:29:11 +08:00
|
|
|
/* $OpenLDAP$ */
|
2004-07-27 05:26:34 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2021-01-12 03:25:53 +08:00
|
|
|
* Copyright 1998-2021 The OpenLDAP Foundation.
|
2004-07-27 05:26:34 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
/* Portions Copyright (c) 1995 Regents of the University of Michigan.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that this notice is preserved and that due credit is given
|
|
|
|
* to the University of Michigan at Ann Arbor. The name of the University
|
|
|
|
* may not be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission. This software
|
|
|
|
* is provided ``as is'' without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "lutil.h"
|
|
|
|
#include "lber_pvt.h"
|
|
|
|
|
|
|
|
#include "ldap_rq.h"
|
|
|
|
|
2005-01-26 03:39:56 +08:00
|
|
|
static BackendInfo slap_frontendInfo;
|
|
|
|
static BackendDB slap_frontendDB;
|
2004-07-27 05:26:34 +08:00
|
|
|
BackendDB *frontendDB;
|
|
|
|
|
2007-12-30 00:07:07 +08:00
|
|
|
static int
|
|
|
|
fe_entry_get_rw(
|
|
|
|
Operation *op,
|
|
|
|
struct berval *ndn,
|
|
|
|
ObjectClass *oc,
|
|
|
|
AttributeDescription *at,
|
|
|
|
int rw,
|
|
|
|
Entry **e )
|
|
|
|
{
|
|
|
|
BackendDB *bd;
|
|
|
|
int rc = LDAP_NO_SUCH_OBJECT;
|
|
|
|
|
|
|
|
bd = op->o_bd;
|
|
|
|
op->o_bd = select_backend( ndn, 0 );
|
|
|
|
if ( op->o_bd != NULL ) {
|
|
|
|
if ( op->o_bd->be_fetch ) {
|
|
|
|
rc = op->o_bd->be_fetch( op, ndn, oc, at, rw, e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
op->o_bd = bd;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
fe_entry_release_rw(
|
|
|
|
Operation *op,
|
|
|
|
Entry *e,
|
|
|
|
int rw )
|
|
|
|
{
|
|
|
|
BackendDB *bd;
|
|
|
|
int rc = LDAP_NO_SUCH_OBJECT;
|
|
|
|
|
|
|
|
bd = op->o_bd;
|
|
|
|
op->o_bd = select_backend( &e->e_nname, 0 );
|
|
|
|
if ( op->o_bd != NULL ) {
|
|
|
|
if ( op->o_bd->be_release ) {
|
|
|
|
rc = op->o_bd->be_release( op, e, rw );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
op->o_bd = bd;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-07-27 05:26:34 +08:00
|
|
|
int
|
|
|
|
frontend_init( void )
|
|
|
|
{
|
|
|
|
/* data */
|
|
|
|
frontendDB = &slap_frontendDB;
|
2008-04-23 18:23:00 +08:00
|
|
|
frontendDB->bd_self = frontendDB;
|
2004-07-27 05:26:34 +08:00
|
|
|
|
|
|
|
/* ACLs */
|
|
|
|
frontendDB->be_dfltaccess = ACL_READ;
|
|
|
|
|
|
|
|
/* limits */
|
|
|
|
frontendDB->be_def_limit.lms_t_soft = SLAPD_DEFAULT_TIMELIMIT; /* backward compatible limits */
|
|
|
|
frontendDB->be_def_limit.lms_t_hard = 0;
|
|
|
|
frontendDB->be_def_limit.lms_s_soft = SLAPD_DEFAULT_SIZELIMIT; /* backward compatible limits */
|
|
|
|
frontendDB->be_def_limit.lms_s_hard = 0;
|
|
|
|
frontendDB->be_def_limit.lms_s_unchecked = -1; /* no limit on unchecked size */
|
|
|
|
frontendDB->be_def_limit.lms_s_pr = 0; /* page limit */
|
|
|
|
frontendDB->be_def_limit.lms_s_pr_hide = 0; /* don't hide number of entries left */
|
|
|
|
frontendDB->be_def_limit.lms_s_pr_total = 0; /* number of total entries returned by pagedResults equal to hard limit */
|
|
|
|
|
2008-11-02 15:58:50 +08:00
|
|
|
ldap_pvt_thread_mutex_init( &frontendDB->be_pcl_mutex );
|
2004-12-11 20:53:47 +08:00
|
|
|
|
2004-07-27 05:26:34 +08:00
|
|
|
/* suffix */
|
|
|
|
frontendDB->be_suffix = ch_calloc( 2, sizeof( struct berval ) );
|
|
|
|
ber_str2bv( "", 0, 1, &frontendDB->be_suffix[0] );
|
|
|
|
BER_BVZERO( &frontendDB->be_suffix[1] );
|
|
|
|
frontendDB->be_nsuffix = ch_calloc( 2, sizeof( struct berval ) );
|
|
|
|
ber_str2bv( "", 0, 1, &frontendDB->be_nsuffix[0] );
|
|
|
|
BER_BVZERO( &frontendDB->be_nsuffix[1] );
|
|
|
|
|
|
|
|
/* info */
|
|
|
|
frontendDB->bd_info = &slap_frontendInfo;
|
|
|
|
|
2005-07-08 01:39:29 +08:00
|
|
|
SLAP_BFLAGS(frontendDB) |= SLAP_BFLAG_FRONTEND;
|
|
|
|
|
2004-07-27 05:26:34 +08:00
|
|
|
/* name */
|
|
|
|
frontendDB->bd_info->bi_type = "frontend";
|
|
|
|
|
|
|
|
/* known controls */
|
2008-09-20 04:37:11 +08:00
|
|
|
{
|
2005-01-30 01:58:48 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
frontendDB->bd_info->bi_controls = slap_known_controls;
|
|
|
|
|
|
|
|
for ( i = 0; slap_known_controls[ i ]; i++ ) {
|
|
|
|
int cid;
|
|
|
|
|
|
|
|
if ( slap_find_control_id( slap_known_controls[ i ], &cid )
|
|
|
|
== LDAP_CONTROL_NOT_FOUND )
|
|
|
|
{
|
|
|
|
assert( 0 );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
frontendDB->bd_info->bi_ctrls[ cid ] = 1;
|
|
|
|
frontendDB->be_ctrls[ cid ] = 1;
|
|
|
|
}
|
|
|
|
}
|
2004-07-27 05:26:34 +08:00
|
|
|
|
|
|
|
/* calls */
|
2004-12-10 05:17:29 +08:00
|
|
|
frontendDB->bd_info->bi_op_abandon = fe_op_abandon;
|
2004-07-27 05:26:34 +08:00
|
|
|
frontendDB->bd_info->bi_op_add = fe_op_add;
|
|
|
|
frontendDB->bd_info->bi_op_bind = fe_op_bind;
|
|
|
|
frontendDB->bd_info->bi_op_compare = fe_op_compare;
|
|
|
|
frontendDB->bd_info->bi_op_delete = fe_op_delete;
|
|
|
|
frontendDB->bd_info->bi_op_modify = fe_op_modify;
|
|
|
|
frontendDB->bd_info->bi_op_modrdn = fe_op_modrdn;
|
|
|
|
frontendDB->bd_info->bi_op_search = fe_op_search;
|
|
|
|
frontendDB->bd_info->bi_extended = fe_extended;
|
2005-07-22 11:40:06 +08:00
|
|
|
frontendDB->bd_info->bi_operational = fe_aux_operational;
|
2005-07-22 13:01:09 +08:00
|
|
|
frontendDB->bd_info->bi_entry_get_rw = fe_entry_get_rw;
|
|
|
|
frontendDB->bd_info->bi_entry_release_rw = fe_entry_release_rw;
|
2005-07-23 12:18:48 +08:00
|
|
|
frontendDB->bd_info->bi_access_allowed = fe_access_allowed;
|
2005-07-22 13:01:09 +08:00
|
|
|
frontendDB->bd_info->bi_acl_group = fe_acl_group;
|
|
|
|
frontendDB->bd_info->bi_acl_attribute = fe_acl_attribute;
|
2004-07-27 05:26:34 +08:00
|
|
|
|
2004-12-11 23:44:30 +08:00
|
|
|
#if 0
|
2004-12-11 20:53:47 +08:00
|
|
|
/* FIXME: is this too early? */
|
|
|
|
return backend_startup_one( frontendDB );
|
2004-12-11 23:44:30 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
2004-07-27 05:26:34 +08:00
|
|
|
}
|
|
|
|
|