[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
General slapd backend enhancement (ITS#97)
This is a multi-part message in MIME format.
------=_NextPart_000_000F_01BE698C.19445880
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Here is a minor change to encapsulate backend entry points. This is a
portion of some work I did with the last Umich distribution to make backends
dynamically loadable. If there is interest in the rest of that work, I can
send it along as a separate set of diffs. I have support for Solaris, AIX 4,
and HPUX working, along with an added entry point to allow the main slapd to
obtain new schema definitions from the loaded backend. I also have a
filesystem backend, along with a few other toys that are dynamically loaded.
These diffs are against the OpenLDAP 1.2 release.
-- Howard
------=_NextPart_000_000F_01BE698C.19445880
Content-Type: text/plain;
name="dif.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="dif.txt"
--- acl.c.O Tue Jan 19 20:52:11 1999
+++ acl.c Thu Mar 4 14:04:15 1999
@@ -356,7 +356,7 @@
string_expand(buf, sizeof(buf), b->a_group, edn, matches);
(void) dn_normalize_case(buf);
=20
- if (be_group(be, e, buf, odn,
+ if (back_group(be, e, buf, odn,
b->a_objectclassvalue, b->a_groupattrname) =3D=3D 0)
{
Debug( LDAP_DEBUG_ACL,
--- backend.c.O Thu Jan 28 21:11:49 1999
+++ backend.c Thu Mar 4 14:23:00 1999
@@ -12,6 +12,30 @@
=20
#include "slap.h"
=20
+#ifdef SLAPD_LDBM
+extern Backfunc ldbm_backfunc;
+#endif
+
+#ifdef SLAPD_PASSWD
+extern Backfunc passwd_backfunc;
+#endif
+
+#ifdef SLAPD_SHELL
+extern Backfunc shell_backfunc;
+#endif
+
+Backfunc *bflist[] =3D {
+#ifdef SLAPD_LDBM
+ &ldbm_backfunc,
+#endif
+#ifdef SLAPD_PASSWD
+ &passwd_backfunc,
+#endif
+#ifdef SLAPD_SHELL
+ &shell_backfunc,
+#endif
+ 0L
+};
=20
#define BACKEND_GRAB_SIZE 10
=20
@@ -25,7 +49,7 @@
)
{
Backend *be;
- int foundit;
+ Backfunc **bf;
=20
if ( nbackends =3D=3D maxbackends ) {
maxbackends +=3D BACKEND_GRAB_SIZE;
@@ -38,83 +62,23 @@
be =3D &backends[nbackends++];
be->be_sizelimit =3D defsize;
be->be_timelimit =3D deftime;
- foundit =3D 0;
-
-#ifdef SLAPD_LDBM
- if ( strcasecmp( type, "ldbm" ) =3D=3D 0 ) {
- be->be_bind =3D ldbm_back_bind;
- be->be_unbind =3D ldbm_back_unbind;
- be->be_search =3D ldbm_back_search;
- be->be_compare =3D ldbm_back_compare;
- be->be_modify =3D ldbm_back_modify;
- be->be_modrdn =3D ldbm_back_modrdn;
- be->be_add =3D ldbm_back_add;
- be->be_delete =3D ldbm_back_delete;
- be->be_abandon =3D ldbm_back_abandon;
- be->be_config =3D ldbm_back_config;
- be->be_init =3D ldbm_back_init;
- be->be_close =3D ldbm_back_close;
-#ifdef SLAPD_ACLGROUPS
- be->be_group =3D ldbm_back_group;
-#endif
- be->be_type =3D "ldbm";
- foundit =3D 1;
- }
-#endif
=20
-#ifdef SLAPD_PASSWD
- if ( strcasecmp( type, "passwd" ) =3D=3D 0 ) {
- be->be_bind =3D NULL;
- be->be_unbind =3D NULL;
- be->be_search =3D passwd_back_search;
- be->be_compare =3D NULL;
- be->be_modify =3D NULL;
- be->be_modrdn =3D NULL;
- be->be_add =3D NULL;
- be->be_delete =3D NULL;
- be->be_abandon =3D NULL;
- be->be_config =3D passwd_back_config;
- be->be_init =3D NULL;
- be->be_close =3D NULL;
-#ifdef SLAPD_ACLGROUPS
- be->be_group =3D NULL;
-#endif
- be->be_type =3D "passwd";
- foundit =3D 1;
+ for (bf =3D bflist; *bf; bf++)
+ if (!strcasecmp( type, (*bf)->bf_type))
+ {
+ be->bf =3D *bf;
+ break;
}
-#endif
=20
-#ifdef SLAPD_SHELL
- if ( strcasecmp( type, "shell" ) =3D=3D 0 ) {
- be->be_bind =3D shell_back_bind;
- be->be_unbind =3D shell_back_unbind;
- be->be_search =3D shell_back_search;
- be->be_compare =3D shell_back_compare;
- be->be_modify =3D shell_back_modify;
- be->be_modrdn =3D shell_back_modrdn;
- be->be_add =3D shell_back_add;
- be->be_delete =3D shell_back_delete;
- be->be_abandon =3D shell_back_abandon;
- be->be_config =3D shell_back_config;
- be->be_init =3D shell_back_init;
- be->be_close =3D NULL;
-#ifdef SLAPD_ACLGROUPS
- be->be_group =3D NULL;
-#endif
- be->be_type =3D "shell";
- foundit =3D 1;
+ if ( ! *bf ) {
+ fprintf( stderr, "Unrecognized database type (%s)\n", type );
+ exit( 1 );
}
-#endif
=20
if ( be->be_init !=3D NULL ) {
(*be->be_init)( be );
}
=20
- if ( foundit =3D=3D 0 ) {
- fprintf( stderr, "Unrecognized database type (%s)\n", type );
- exit( 1 );
- }
-
return( be );
}
=20
@@ -244,7 +208,7 @@
}
=20
void
-be_close( void )
+back_close( void )
{
int i;
=20
@@ -257,7 +221,7 @@
=20
=20
void
-be_unbind(
+back_unbind(
Connection *conn,
Operation *op
)
@@ -273,7 +237,7 @@
=20
#ifdef SLAPD_ACLGROUPS
int=20
-be_group(
+back_group(
Backend *be,
Entry *target,
char *gr_ndn,
--- daemon.c.O Sun Feb 7 10:42:24 1999
+++ daemon.c Thu Mar 4 13:39:22 1999
@@ -381,7 +381,7 @@
Debug( LDAP_DEBUG_TRACE,
"slapd shutting down - waiting for backends to close down\n", 0, =
0,
0 );
- be_close();
+ back_close();
Debug( LDAP_DEBUG_ANY, "slapd stopping\n", 0, 0, 0 );
=20
return NULL;
--- proto-slap.h.O Sun Feb 7 10:42:24 1999
+++ proto-slap.h Thu Mar 4 17:38:55 1999
@@ -61,7 +61,7 @@
int be_isroot LDAP_P(( Backend *be, char *ndn ));
int be_isroot_pw LDAP_P(( Backend *be, char *ndn, struct berval *cred =
));
char* be_root_dn LDAP_P(( Backend *be ));
-void be_close LDAP_P(( void ));
+void back_close LDAP_P(( void ));
=20
/*
* ch_malloc.c
@@ -264,11 +264,11 @@
extern struct objclass *global_oc;
extern time_t currenttime;
=20
-extern int be_group LDAP_P((Backend *be, Entry *target,
+extern int back_group LDAP_P((Backend *be, Entry *target,
char *gr_ndn, char *op_ndn,
char *objectclassValue, char *groupattrName));
extern void init LDAP_P((void));
-extern void be_unbind LDAP_P((Connection *conn, Operation *op));
+extern void back_unbind LDAP_P((Connection *conn, Operation *op));
=20
extern void * slapd_daemon LDAP_P((void *port));
extern void slap_set_shutdown LDAP_P((int sig));
@@ -295,47 +295,6 @@
extern Connection *c;
extern int dtblsize;
extern time_t starttime;
-#endif
-
-#ifdef SLAPD_LDBM
-extern int ldbm_back_bind LDAP_P((Backend *be,
- Connection *c, Operation *o,
- char *dn, int method, struct berval *cred, char** edn ));
-extern void ldbm_back_unbind LDAP_P((Backend *be, Connection *c, =
Operation *o ));
-extern int ldbm_back_search LDAP_P((Backend *be, Connection *c, =
Operation *o, char *base, int scope, int deref, int slimit, int tlimit, =
Filter *f, char *filterstr, char **attrs, int attrsonly));
-extern int ldbm_back_compare LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, Ava *ava));
-extern int ldbm_back_modify LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, LDAPMod *m));
-extern int ldbm_back_modrdn LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
-extern int ldbm_back_add LDAP_P((Backend *be, Connection *c, =
Operation *o, Entry *e));
-extern int ldbm_back_delete LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn));
-extern void ldbm_back_abandon LDAP_P((Backend *be, Connection *c, =
Operation *o, int msgid));
-extern void ldbm_back_config LDAP_P((Backend *be, char *fname, int =
lineno, int argc, char **argv ));
-extern void ldbm_back_init LDAP_P((Backend *be));
-extern void ldbm_back_close LDAP_P((Backend *be));
-extern int ldbm_back_group LDAP_P((Backend *be, Entry *target,
- char *gr_ndn, char *op_ndn,
- char *objectclassValue, char *groupattrName ));
-#endif
-
-#ifdef SLAPD_PASSWD
-extern int passwd_back_search LDAP_P((Backend *be, Connection *c, =
Operation *o, char *base, int scope, int deref, int slimit, int tlimit, =
Filter *f, char *filterstr, char **attrs, int attrsonly));
-extern void passwd_back_config LDAP_P((Backend *be, char *fname, int =
lineno, int argc, char **argv ));
-#endif
-
-#ifdef SLAPD_SHELL
-extern int shell_back_bind LDAP_P((Backend *be,
- Connection *c, Operation *o,
- char *dn, int method, struct berval *cred, char** edn ));
-extern void shell_back_unbind LDAP_P((Backend *be, Connection *c, =
Operation *o ));
-extern int shell_back_search LDAP_P((Backend *be, Connection *c, =
Operation *o, char *base, int scope, int deref, int slimit, int tlimit, =
Filter *f, char *filterstr, char **attrs, int attrsonly));
-extern int shell_back_compare LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, Ava *ava));
-extern int shell_back_modify LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, LDAPMod *m));
-extern int shell_back_modrdn LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
-extern int shell_back_add LDAP_P((Backend *be, Connection *c, =
Operation *o, Entry *e));
-extern int shell_back_delete LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn));
-extern void shell_back_abandon LDAP_P((Backend *be, Connection *c, =
Operation *o, int msgid));
-extern void shell_back_config LDAP_P((Backend *be, char *fname, int =
lineno, int argc, char **argv ));
-extern void shell_back_init LDAP_P((Backend *be));
#endif
=20
#endif /* _proto_slap */
--- slap.h.O Sun Jan 31 09:50:49 1999
+++ slap.h Thu Mar 4 14:21:21 1999
@@ -194,69 +194,88 @@
struct objclass *oc_next;
};
=20
-/*
- * represents a "database"
- */
-
typedef struct backend Backend;
-struct backend {
- char **be_suffix; /* the DN suffixes of data in this backend */
- char **be_suffixAlias; /* the DN suffix aliases of =
data in this backend */
- char *be_root_dn; /* the magic "root" dn for this db */
- char *be_root_ndn; /* the magic "root" normalized dn for this db */
- char *be_root_pw; /* the magic "root" password for this db */
- int be_readonly; /* 1 =3D> db is in "read only" mode */
- int be_maxDerefDepth; /* limit for depth of an alias =
deref */
- int be_sizelimit; /* size limit for this backend */
- int be_timelimit; /* time limit for this backend */
- struct acl *be_acl; /* access control list for this backend */
- int be_dfltaccess; /* access given if no acl matches */
- char **be_replica; /* replicas of this backend (in master) */
- char *be_replogfile; /* replication log file (in master) */
- char *be_update_ndn; /* allowed to make changes (in replicas) */
- int be_lastmod; /* keep track of lastmodified{by,time} */
- char *be_type; /* type of database */
-
- void *be_private; /* anything the backend needs */
-
- /* backend routines */
- int (*be_bind) LDAP_P((Backend *be,
+typedef struct Backfunc {
+ char *bf_type; /* type of database */
+ int (*bf_bind) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
char *dn, int method, struct berval *cred, char** edn ));
- void (*be_unbind) LDAP_P((Backend *be,
+ void (*bf_unbind) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o ));
int (*be_search) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
char *base, int scope, int deref, int slimit, int tlimit,
Filter *f, char *filterstr, char **attrs, int attrsonly));
- int (*be_compare)LDAP_P((Backend *be,
+ int (*bf_compare)LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
char *dn, Ava *ava));
- int (*be_modify) LDAP_P((Backend *be,
+ int (*bf_modify) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
char *dn, LDAPMod *m));
- int (*be_modrdn) LDAP_P((Backend *be,
+ int (*bf_modrdn) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
char *dn, char *newrdn, int deleteoldrdn ));
- int (*be_add) LDAP_P((Backend *be,
+ int (*bf_add) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
Entry *e));
- int (*be_delete) LDAP_P((Backend *be,
+ int (*bf_delete) LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
char *dn));
- /* Bug: be_abandon in unused! */
- void (*be_abandon)LDAP_P((Backend *be,
+ /* Bug: bf_abandon is unused! */
+ void (*bf_abandon)LDAP_P((Backend *be,
struct slap_conn *c, struct slap_op *o,
int msgid));
- void (*be_config) LDAP_P((Backend *be,
+ void (*bf_config) LDAP_P((Backend *be,
char *fname, int lineno, int argc, char **argv ));
- void (*be_init) LDAP_P((Backend *be));
- void (*be_close) LDAP_P((Backend *be));
+ void (*bf_init) LDAP_P((Backend *be));
+ void (*bf_close) LDAP_P((Backend *be));
=20
#ifdef SLAPD_ACLGROUPS
- int (*be_group) LDAP_P((Backend *be, Entry *e,
+ int (*bf_group) LDAP_P((Backend *be, Entry *e,
char *bdn, char *edn,
char *objectclassValue, char *groupattrName ));
+#endif
+} Backfunc;
+
+/*
+ * represents a "database"
+ */
+
+struct backend {
+ char **be_suffix; /* the DN suffixes of data in this backend */
+ char **be_suffixAlias; /* the DN suffix aliases of =
data in this backend */
+ char *be_root_dn; /* the magic "root" dn for this db */
+ char *be_root_ndn; /* the magic "root" normalized dn for this db */
+ char *be_root_pw; /* the magic "root" password for this db */
+ int be_readonly; /* 1 =3D> db is in "read only" mode */
+ int be_maxDerefDepth; /* limit for depth of an alias =
deref */
+ int be_sizelimit; /* size limit for this backend */
+ int be_timelimit; /* time limit for this backend */
+ struct acl *be_acl; /* access control list for this backend */
+ int be_dfltaccess; /* access given if no acl matches */
+ char **be_replica; /* replicas of this backend (in master) */
+ char *be_replogfile; /* replication log file (in master) */
+ char *be_update_ndn; /* allowed to make changes (in replicas) */
+ int be_lastmod; /* keep track of lastmodified{by,time} */
+
+ void *be_private; /* anything the backend needs */
+
+ Backfunc *bf; /* backend routines */
+#define be_type bf->bf_type
+#define be_bind bf->bf_bind
+#define be_unbind bf->bf_unbind
+#define be_search bf->bf_search
+#define be_compare bf->bf_compare
+#define be_modify bf->bf_modify
+#define be_modrdn bf->bf_modrdn
+#define be_add bf->bf_add
+#define be_delete bf->bf_delete
+#define be_abandon bf->bf_abandon
+#define be_config bf->bf_config
+#define be_init bf->bf_init
+#define be_close bf->bf_close
+#ifdef SLAPD_ACLGROUPS
+#define be_group bf->bf_group
#endif
};
=20
--- unbind.c.O Mon Nov 16 15:24:29 1998
+++ unbind.c Thu Mar 4 13:36:45 1999
@@ -40,7 +40,7 @@
op->o_opid, 0, 0, 0 );
=20
/* pass the unbind to all backends */
- be_unbind( conn, op );
+ back_unbind( conn, op );
=09
/* close the connection to the client */
close_connection( conn, op->o_connid, op->o_opid );
--- back-ldbm/config.c.O Thu Jan 21 20:41:13 1999
+++ back-ldbm/config.c Thu Mar 4 17:34:51 1999
@@ -10,6 +10,25 @@
#include "slap.h"
#include "back-ldbm.h"
=20
+Backfunc ldbm_backfunc =3D {
+ "ldbm",
+ ldbm_back_bind,
+ ldbm_back_unbind,
+ ldbm_back_search,
+ ldbm_back_compare,
+ ldbm_back_modify,
+ ldbm_back_modrdn,
+ ldbm_back_add,
+ ldbm_back_delete,
+ ldbm_back_abandon,
+ ldbm_back_config,
+ ldbm_back_init,
+ ldbm_back_close,
+#ifdef SLAPD_ACLGROUPS
+ ldbm_back_group
+#endif
+};
+
void
ldbm_back_config(
Backend *be,
--- back-ldbm/proto-back-ldbm.h.O Wed Feb 10 11:36:53 1999
+++ back-ldbm/proto-back-ldbm.h Thu Mar 4 14:10:38 1999
@@ -5,6 +5,24 @@
=20
LDAP_BEGIN_DECL
=20
+int ldbm_back_bind LDAP_P((Backend *be,
+ Connection *c, Operation *o,
+ char *dn, int method, struct berval *cred, char** edn ));
+void ldbm_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o =
));
+int ldbm_back_search LDAP_P((Backend *be, Connection *c, Operation *o, =
char *base, int scope, int deref, int slimit, int tlimit, Filter *f, =
char *filterstr, char **attrs, int attrsonly));
+int ldbm_back_compare LDAP_P((Backend *be, Connection *c, Operation =
*o, char *dn, Ava *ava));
+int ldbm_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, =
char *dn, LDAPMod *m));
+int ldbm_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, =
char *dn, char *newrdn, int deleteoldrdn ));
+int ldbm_back_add LDAP_P((Backend *be, Connection *c, Operation *o, =
Entry *e));
+int ldbm_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, =
char *dn));
+void ldbm_back_abandon LDAP_P((Backend *be, Connection *c, Operation =
*o, int msgid));
+void ldbm_back_config LDAP_P((Backend *be, char *fname, int lineno, int =
argc, char **argv ));
+void ldbm_back_init LDAP_P((Backend *be));
+void ldbm_back_close LDAP_P((Backend *be));
+int ldbm_back_group LDAP_P((Backend *be, Entry *target,
+ char *gr_ndn, char *op_ndn,
+ char *objectclassValue, char *groupattrName ));
+
/*
* alias.c
*/
--- back-passwd/config.c.O Sun Nov 29 13:52:36 1998
+++ back-passwd/config.c Thu Mar 4 17:38:07 1999
@@ -10,6 +10,28 @@
=20
#include "slap.h"
=20
+int passwd_back_search LDAP_P((Backend *be, Connection *c, Operation =
*o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, =
char *filterstr, char **attrs, int attrsonly));
+void passwd_back_config LDAP_P((Backend *be, char *fname, int lineno, =
int argc, char **argv ));
+
+Backfunc passwd_backfunc =3D {
+ "passwd",
+ NULL,
+ NULL,
+ passwd_back_search,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ passwd_back_config,
+ NULL,
+ NULL,
+#ifdef SLAPD_ACLGROUPS
+ NULL
+#endif
+};
+
void
passwd_back_config(
Backend *be,
--- back-shell/config.c.O Mon Nov 16 15:24:31 1998
+++ back-shell/config.c Thu Mar 4 17:42:14 1999
@@ -10,6 +10,25 @@
#include "slap.h"
#include "shell.h"
=20
+Backfunc shell_backfunc =3D {
+ "shell",
+ shell_back_bind,
+ shell_back_unbind,
+ shell_back_search,
+ shell_back_compare,
+ shell_back_modify,
+ shell_back_modrdn,
+ shell_back_add,
+ shell_back_delete,
+ shell_back_abandon,
+ shell_back_config,
+ shell_back_init,
+ NULL,
+#ifdef SLAPD_ACLGROUPS
+ NULL
+#endif
+};
+
void
shell_back_config(
Backend *be,
--- back-shell/shell.h.O Tue Feb 2 05:23:07 1999
+++ back-shell/shell.h Thu Mar 4 17:47:34 1999
@@ -28,6 +28,20 @@
struct slap_conn *conn, struct slap_op *op,
FILE *fp, char **attrs, int attrsonly));
=20
+extern int shell_back_bind LDAP_P((Backend *be,
+ Connection *c, Operation *o,
+ char *dn, int method, struct berval *cred, char** edn ));
+extern void shell_back_unbind LDAP_P((Backend *be, Connection *c, =
Operation *o ));
+extern int shell_back_search LDAP_P((Backend *be, Connection *c, =
Operation *o, char *base, int scope, int deref, int slimit, int tlimit, =
Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern int shell_back_compare LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, Ava *ava));
+extern int shell_back_modify LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, LDAPMod *m));
+extern int shell_back_modrdn LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
+extern int shell_back_add LDAP_P((Backend *be, Connection *c, =
Operation *o, Entry *e));
+extern int shell_back_delete LDAP_P((Backend *be, Connection *c, =
Operation *o, char *dn));
+extern void shell_back_abandon LDAP_P((Backend *be, Connection *c, =
Operation *o, int msgid));
+extern void shell_back_config LDAP_P((Backend *be, char *fname, int =
lineno, int argc, char **argv ));
+extern void shell_back_init LDAP_P((Backend *be));
+
LDAP_END_DECL
=20
#endif
------=_NextPart_000_000F_01BE698C.19445880--