From f23c19359fa9702fead4a5aecb0dc0eaaf9d0e5f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 20:08:30 +0000 Subject: Add documentation on new modules system (This used to be commit f0f454129a5a57e50391397f45d7cf4d58648d45) --- docs/docbook/devdoc/dev-doc.sgml | 2 + docs/docbook/devdoc/modules.sgml | 147 ++++++++++++++++++++++++++++++++++++ docs/docbook/devdoc/rpc_plugin.sgml | 13 +++- 3 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 docs/docbook/devdoc/modules.sgml (limited to 'docs') diff --git a/docs/docbook/devdoc/dev-doc.sgml b/docs/docbook/devdoc/dev-doc.sgml index b5c934b1c8..f10fe72414 100644 --- a/docs/docbook/devdoc/dev-doc.sgml +++ b/docs/docbook/devdoc/dev-doc.sgml @@ -13,6 +13,7 @@ + ]> @@ -67,6 +68,7 @@ url="http://www.fsf.org/licenses/gpl.txt">http://www.fsf.org/licenses/gpl.txt diff --git a/docs/docbook/devdoc/modules.sgml b/docs/docbook/devdoc/modules.sgml new file mode 100644 index 0000000000..098044ddfe --- /dev/null +++ b/docs/docbook/devdoc/modules.sgml @@ -0,0 +1,147 @@ + + + + JelmerVernooij + + Samba Team +
jelmer@samba.org
+
+
+ 19 March 2003 +
+ +Modules + + +Advantages + + +The new modules system has the following advantages: + + + +Transparent loading of static and shared modules (no need +for a subsystem to know about modules) +Simple selection between shared and static modules at configure time +"preload modules" option for increasing performance for stable modules +No nasty #define stuff anymore +All backends are available as plugin now (including pdb_ldap and pdb_tdb) + + + + +Loading modules + + +Some subsystems in samba use different backends. These backends can be +either statically linked in to samba or available as a plugin. A subsystem +should have a function that allows a module to register itself. For example, +the passdb subsystem has: + + + +BOOL smb_register_passdb(const char *name, pdb_init_function init, int version); + + + +This function will be called by the initialisation function of the module to +register itself. + + + +Static modules + + +The modules system compiles a list of initialisation functions for the +static modules of each subsystem. This is a define. For example, +it is here currently (from include/config.h): + + + +/* Static init functions */ +#define static_init_pdb { pdb_mysql_init(); pdb_ldap_init(); pdb_smbpasswd_init(); pdb_tdbsam_init(); pdb_guest_init();} + + + +These functions should be called before the subsystem is used. That can be +done either from the executable that will be using the subsystem ( +static_init_rpc is called from the main() function of smbd), or +from the subsystem itself when it's first used (like passdb's +lazy_initialise_passdb does). + + + + + +Shared modules + + +If a subsystem needs a certain backend, it should check if it has +already been registered. If the backend hasn't been registered already, +the subsystem should call smb_probe_module(char *subsystem, char *backend). +This function tries to load the correct module from a certain path +($LIBDIR/subsystem/backend.so). If the first character in 'backend' +is a slash, smb_probe_module() tries to load the module from the +absolute path specified in 'backend'. + + +After smb_probe_module() has been executed, the subsystem +should check again if the module has been registered. + + + + + + +Writing modules + + +Each module has an initialisation function. For modules that are +included with samba this name is 'subsystem_backend_init'. For external modules (that will never be built-in, but only available as a module) this name is always 'module_init'. +The prototype for this function is: + + + +int module_init(void); + + +This function should call one or more +registration The function should return non-zero on success and zero on +failure. + +For example, pdb_ldap_init() contains: + + +int pdb_ldap_init(void) +{ + smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION); + smb_register_passdb("ldapsam_nua", pdb_init_ldapsam_nua, PASSDB_INTERFACE_VERSION); + return TRUE; +} + + + +Static/Shared selection in configure.in + + +Some macros in configure.in generate the various defines and substs that +are necessary for the system to work correct. All modules that should +be built by default have to be added to the variable 'default_modules'. +For example, if ldap is found, pdb_ldap is added to this variable. + + + +On the bottom of configure.in, SMB_MODULE() should be called +for each module and SMB_SUBSYSTEM() for each subsystem. + + +Syntax: + + +SMB_MODULE($MODULE_subsystem_backend, subsystem_backend, object files, plugin name, subsystem name) +SMB_SUBSYSTEM(subsystem) + + + + +
diff --git a/docs/docbook/devdoc/rpc_plugin.sgml b/docs/docbook/devdoc/rpc_plugin.sgml index 21582a011d..c83742a247 100644 --- a/docs/docbook/devdoc/rpc_plugin.sgml +++ b/docs/docbook/devdoc/rpc_plugin.sgml @@ -7,6 +7,13 @@
aliguor@us.ibm.com
+ + JelmerVernooij + + Samba Team +
jelmer@samba.org
+
+
January 2003 @@ -33,12 +40,12 @@ When an RPC call is sent to smbd, smbd tries to load a shared library by the name librpc_<pipename>.so to handle the call if it doesn't know how to handle the call internally. For instance, LSA calls are handled by librpc_lsass.so.. -These shared libraries should be located in the <sambaroot>/lib/rpc. smbd then attempts to call the rpc_pipe_init function within -the shared library. +These shared libraries should be located in the <sambaroot>/lib/rpc. smbd then attempts to call the init_module function within +the shared library. Check the chapter on modules for more information. -In the rpc_pipe_init function, the library should call +In the init_module function, the library should call rpc_pipe_register_commands(). This function takes the following arguments: -- cgit