[Date Prev][Date Next]
loadable module support
Last week I sent the message below, containing a patch for OpenLDAP
1.2.1 that enables support for dynamically loadable modules. The patch
was too big so the message got bounced. So I've uploaded the actual
patch to ftp://ftp.openldap.org/incoming/bb_dynmods_for_1.2.1.v0.0.gz .
I'll start porting this patch to the current development version of
OpenLDAP soon, so if give me some feedback about what you like to see
added/removed/changed please let me know. I'll try to incorporate it in
the next version. Any help with integrating this stuff with the autoconf
build environment would be appreciated very much too. (Kurt probably is
too busy for that and it may take a while before I've learned how to do
I've created a new patch against OpenLDAP 1.2.1 for loadable module
support. It has some minor improvements over
the original patch and does not directly depend on glib anymore.
string_map.h and string_map.c have been added these files contain (a
start of ) an implementation of a char* to void*
map, based on the AVL tree.
backend.c now contains a map with registered backend modules. The
following functions have been added:
void register_static_backend_modules(). Is called from main.c after
init(). It registers static (compiled in)
void register_backend_module(BackendModule *module). Allows a
dynamically loaded backend module to
register them selves.
BackendModule *lookup_backend_module(char *name). Looks up the
backend module corresponding to the
BackendModule is a structure containing the name of the module (e.g.
'shell', 'ldbm', etc.), a function pointer to
<backend-name>_back_set_functions(BackendModule*, Backend*) and a void
pointer to private data of the module.
new_backend has been modified so that is does a lookup with
lookup_backend_module. If the module is found a call is
made to module->mod_setfunctions() , wich sets the appropriate function
pointers in the new Backend struct.
config.c now accepts the parameter 'loadmodule'. Syntax:
loadmodule module_file_name [options]
loadmodule /opt/ldap/modules/backcorba.so name=corba IIOPPort=3333
config.c call function load_module(char *file_name, int argc, char
*argv) defined in module.c
Here the module is loaded (with gmodule). It then looks up the method
init_module(int argc, char* argv) and (if
found) calls it with the argc and argv parameters.
Typically the init_module function will create a BackendModule structure
and call the register_backend_module.
Changes to the backend:
addition of init_module for dynamic modules. addition of
<backend>_back_register_module for static registration.
addition of <backend>_back_set_funtions used by new_backend. Also
prototype header files have been added
As I've stated earlier I'm no autoconf expert so I haven't touched the
configure scripts. The patched sources should
compile without modifications. You'll then get a slapd that has only
static backend modules. For dynamic modules I do
(on RH Linux 5.2):
setenv CFLAGS '-fPIC -DSLAPD_LOADABLE_MODULES'
setenv LDFLAGS -rdynamic
setenv LIBS -lgmodule -lglib -ldl
(I also symlinked /usr/lib/glib/include/glibconfig.h to /usr/include,
since adding -I/usr/lib/glib/include to CFLAGS was
not enough: make depend fails).
then configure with --enable-shared and all backends.
cd to servers/slapd and delete libbackends.a and delete slapd.
cut'n paste the build command, removing libbackends.a from it.
The resulting slapd should not have any backends in it.
Now build the backend modules:
go to backend dir, eg. back-shell
build the module with:
gcc -shared -o backshell.so *.o
Kurt, could you please help with the integration of the build into the
configure and make scripts?
fn: Bastiaan Bakker
org: LifeLine Networks BV