2002-04-08 17:43:22 +08:00
|
|
|
/* null.c - the null backend */
|
2003-11-27 01:34:58 +08:00
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2008-01-08 08:19:56 +08:00
|
|
|
* Copyright 2002-2008 The OpenLDAP Foundation.
|
2003-11-27 01:34:58 +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>.
|
|
|
|
*/
|
|
|
|
/* ACKNOWLEDGEMENTS:
|
2005-01-21 02:52:00 +08:00
|
|
|
* This work was originally developed by Hallvard Furuseth for inclusion
|
2003-11-27 01:34:58 +08:00
|
|
|
* in OpenLDAP Software.
|
2002-04-08 17:43:22 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
2007-07-26 01:21:05 +08:00
|
|
|
#include "config.h"
|
2002-04-08 17:43:22 +08:00
|
|
|
|
|
|
|
struct null_info {
|
2005-09-01 02:00:40 +08:00
|
|
|
int ni_bind_allowed;
|
|
|
|
ID ni_nextid;
|
2002-04-08 17:43:22 +08:00
|
|
|
};
|
|
|
|
|
2005-09-01 02:00:40 +08:00
|
|
|
|
|
|
|
/* LDAP operations */
|
|
|
|
|
2005-01-02 00:13:25 +08:00
|
|
|
static int
|
2003-04-03 05:02:12 +08:00
|
|
|
null_back_bind( Operation *op, SlapReply *rs )
|
2002-04-08 17:43:22 +08:00
|
|
|
{
|
2003-04-03 05:02:12 +08:00
|
|
|
struct null_info *ni = (struct null_info *) op->o_bd->be_private;
|
2002-04-08 17:43:22 +08:00
|
|
|
|
2006-04-28 00:12:59 +08:00
|
|
|
if ( ni->ni_bind_allowed || be_isroot_pw( op ) ) {
|
2003-01-25 04:12:50 +08:00
|
|
|
/* front end will send result on success (0) */
|
2005-01-02 00:13:25 +08:00
|
|
|
return LDAP_SUCCESS;
|
2003-04-03 05:02:12 +08:00
|
|
|
}
|
2002-04-08 17:43:22 +08:00
|
|
|
|
2003-04-03 05:02:12 +08:00
|
|
|
rs->sr_err = LDAP_INVALID_CREDENTIALS;
|
|
|
|
send_ldap_result( op, rs );
|
2002-04-08 17:43:22 +08:00
|
|
|
|
2005-01-02 00:13:25 +08:00
|
|
|
return rs->sr_err;
|
2002-04-08 17:43:22 +08:00
|
|
|
}
|
|
|
|
|
2003-04-03 05:02:12 +08:00
|
|
|
/* add, delete, modify, modrdn, search */
|
2005-01-02 00:13:25 +08:00
|
|
|
static int
|
2003-04-03 05:02:12 +08:00
|
|
|
null_back_success( Operation *op, SlapReply *rs )
|
2002-04-08 17:43:22 +08:00
|
|
|
{
|
2003-04-03 05:02:12 +08:00
|
|
|
rs->sr_err = LDAP_SUCCESS;
|
|
|
|
send_ldap_result( op, rs );
|
2002-04-08 17:43:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-04-03 05:02:12 +08:00
|
|
|
/* compare */
|
2005-01-02 00:13:25 +08:00
|
|
|
static int
|
2003-04-03 05:02:12 +08:00
|
|
|
null_back_false( Operation *op, SlapReply *rs )
|
2002-04-08 17:43:22 +08:00
|
|
|
{
|
2003-04-03 05:02:12 +08:00
|
|
|
rs->sr_err = LDAP_COMPARE_FALSE;
|
|
|
|
send_ldap_result( op, rs );
|
2002-04-08 17:43:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-01 02:00:40 +08:00
|
|
|
|
2007-07-24 04:13:36 +08:00
|
|
|
/* for overlays */
|
2008-02-12 05:05:12 +08:00
|
|
|
static int
|
|
|
|
null_back_entry_get(
|
2007-07-24 04:13:36 +08:00
|
|
|
Operation *op,
|
|
|
|
struct berval *ndn,
|
|
|
|
ObjectClass *oc,
|
|
|
|
AttributeDescription *at,
|
|
|
|
int rw,
|
|
|
|
Entry **ent )
|
|
|
|
{
|
2008-02-12 05:05:12 +08:00
|
|
|
assert( *ent == NULL );
|
|
|
|
|
|
|
|
/* don't admit the object isn't there */
|
|
|
|
return oc || at ? LDAP_NO_SUCH_ATTRIBUTE : LDAP_BUSY;
|
2007-07-24 04:13:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-01 02:00:40 +08:00
|
|
|
/* Slap tools */
|
|
|
|
|
|
|
|
static int
|
|
|
|
null_tool_entry_open( BackendDB *be, int mode )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
null_tool_entry_close( BackendDB *be )
|
|
|
|
{
|
|
|
|
assert( be != NULL );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ID
|
|
|
|
null_tool_entry_next( BackendDB *be )
|
|
|
|
{
|
|
|
|
return NOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Entry *
|
|
|
|
null_tool_entry_get( BackendDB *be, ID id )
|
|
|
|
{
|
|
|
|
assert( slapMode & SLAP_TOOL_MODE );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ID
|
|
|
|
null_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
|
|
|
|
{
|
|
|
|
assert( slapMode & SLAP_TOOL_MODE );
|
|
|
|
assert( text != NULL );
|
|
|
|
assert( text->bv_val != NULL );
|
|
|
|
assert( text->bv_val[0] == '\0' ); /* overconservative? */
|
|
|
|
|
|
|
|
e->e_id = ((struct null_info *) be->be_private)->ni_nextid++;
|
|
|
|
return e->e_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup */
|
|
|
|
|
2005-01-02 00:13:25 +08:00
|
|
|
static int
|
2002-04-08 17:43:22 +08:00
|
|
|
null_back_db_config(
|
|
|
|
BackendDB *be,
|
|
|
|
const char *fname,
|
2005-01-02 00:13:25 +08:00
|
|
|
int lineno,
|
|
|
|
int argc,
|
2002-04-08 17:43:22 +08:00
|
|
|
char **argv )
|
|
|
|
{
|
|
|
|
struct null_info *ni = (struct null_info *) be->be_private;
|
|
|
|
|
|
|
|
if ( ni == NULL ) {
|
|
|
|
fprintf( stderr, "%s: line %d: null database info is null!\n",
|
|
|
|
fname, lineno );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bind requests allowed */
|
|
|
|
if ( strcasecmp( argv[0], "bind" ) == 0 ) {
|
|
|
|
if ( argc < 2 ) {
|
|
|
|
fprintf( stderr,
|
|
|
|
"%s: line %d: missing <on/off> in \"bind <on/off>\" line\n",
|
|
|
|
fname, lineno );
|
|
|
|
return 1;
|
|
|
|
}
|
2005-09-01 00:30:32 +08:00
|
|
|
ni->ni_bind_allowed = strcasecmp( argv[1], "off" );
|
2002-04-08 17:43:22 +08:00
|
|
|
|
|
|
|
/* anything else */
|
|
|
|
} else {
|
2003-12-07 15:07:00 +08:00
|
|
|
return SLAP_CONF_UNKNOWN;
|
2002-04-08 17:43:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-02 00:13:25 +08:00
|
|
|
static int
|
2007-08-03 20:02:07 +08:00
|
|
|
null_back_db_init( BackendDB *be, ConfigReply *cr )
|
2002-04-08 17:43:22 +08:00
|
|
|
{
|
2005-09-01 02:00:40 +08:00
|
|
|
struct null_info *ni = ch_calloc( 1, sizeof(struct null_info) );
|
2005-09-01 00:30:32 +08:00
|
|
|
ni->ni_bind_allowed = 0;
|
2005-09-01 02:00:40 +08:00
|
|
|
ni->ni_nextid = 1;
|
2003-04-03 05:02:12 +08:00
|
|
|
be->be_private = ni;
|
2002-04-08 17:43:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-02 00:13:25 +08:00
|
|
|
static int
|
2007-08-03 20:02:07 +08:00
|
|
|
null_back_db_destroy( Backend *be, ConfigReply *cr )
|
2002-04-08 17:43:22 +08:00
|
|
|
{
|
|
|
|
free( be->be_private );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2005-01-02 00:13:25 +08:00
|
|
|
null_back_initialize( BackendInfo *bi )
|
2002-04-08 17:43:22 +08:00
|
|
|
{
|
|
|
|
bi->bi_open = 0;
|
|
|
|
bi->bi_close = 0;
|
|
|
|
bi->bi_config = 0;
|
|
|
|
bi->bi_destroy = 0;
|
|
|
|
|
|
|
|
bi->bi_db_init = null_back_db_init;
|
|
|
|
bi->bi_db_config = null_back_db_config;
|
|
|
|
bi->bi_db_open = 0;
|
|
|
|
bi->bi_db_close = 0;
|
|
|
|
bi->bi_db_destroy = null_back_db_destroy;
|
|
|
|
|
|
|
|
bi->bi_op_bind = null_back_bind;
|
|
|
|
bi->bi_op_unbind = 0;
|
2003-04-03 05:02:12 +08:00
|
|
|
bi->bi_op_search = null_back_success;
|
|
|
|
bi->bi_op_compare = null_back_false;
|
|
|
|
bi->bi_op_modify = null_back_success;
|
|
|
|
bi->bi_op_modrdn = null_back_success;
|
|
|
|
bi->bi_op_add = null_back_success;
|
|
|
|
bi->bi_op_delete = null_back_success;
|
2002-04-08 17:43:22 +08:00
|
|
|
bi->bi_op_abandon = 0;
|
|
|
|
|
|
|
|
bi->bi_extended = 0;
|
|
|
|
|
|
|
|
bi->bi_chk_referrals = 0;
|
|
|
|
|
|
|
|
bi->bi_connection_init = 0;
|
|
|
|
bi->bi_connection_destroy = 0;
|
|
|
|
|
2007-07-24 04:13:36 +08:00
|
|
|
bi->bi_entry_get_rw = null_back_entry_get;
|
|
|
|
|
2005-09-01 02:00:40 +08:00
|
|
|
bi->bi_tool_entry_open = null_tool_entry_open;
|
|
|
|
bi->bi_tool_entry_close = null_tool_entry_close;
|
|
|
|
bi->bi_tool_entry_first = null_tool_entry_next;
|
|
|
|
bi->bi_tool_entry_next = null_tool_entry_next;
|
|
|
|
bi->bi_tool_entry_get = null_tool_entry_get;
|
|
|
|
bi->bi_tool_entry_put = null_tool_entry_put;
|
|
|
|
|
2002-04-08 17:43:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-04-08 13:56:23 +08:00
|
|
|
#if SLAPD_NULL == SLAPD_MOD_DYNAMIC
|
2004-11-14 02:52:44 +08:00
|
|
|
|
2004-11-16 03:45:49 +08:00
|
|
|
/* conditionally define the init_module() function */
|
|
|
|
SLAP_BACKEND_INIT_MODULE( null )
|
2004-11-14 02:52:44 +08:00
|
|
|
|
2004-11-16 03:45:49 +08:00
|
|
|
#endif /* SLAPD_NULL == SLAPD_MOD_DYNAMIC */
|