summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-26 16:46:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:45 -0500
commit448483199fb436309735f5203b3282fca2c517ec (patch)
treefcd663e46d0eac19b98037008a435bdd57ca7f8e
parentee10fb1a12391a76fe81e6e7a92d282ef885bc30 (diff)
downloadsamba-448483199fb436309735f5203b3282fca2c517ec.tar.gz
samba-448483199fb436309735f5203b3282fca2c517ec.tar.bz2
samba-448483199fb436309735f5203b3282fca2c517ec.zip
r12494: Support loading modules from .so files for most subsystems.
We now use a different system for initializing the modules for a subsystem. Most subsystems now have an init function that looks something like this: init_module_fn static_init[] = STATIC_AUTH_MODULES; init_module_fn *shared_init = load_samba_modules(NULL, "auth"); run_init_functions(static_init); run_init_functions(shared_init); talloc_free(shared_init); I hope to eliminate the other init functions later on (the init_programname_subsystems; defines). (This used to be commit b6d2ad4ce0a91c4be790dd258820c492ff1787ea)
-rw-r--r--source4/auth/auth.c8
-rw-r--r--source4/auth/gensec/gensec.c8
-rw-r--r--source4/build/smb_build/TODO4
-rw-r--r--source4/build/smb_build/input.pm8
-rw-r--r--source4/build/smb_build/makefile.pm1
-rw-r--r--source4/build/smb_build/output.pm2
-rw-r--r--source4/build/smb_build/smb_build_h.pm36
-rw-r--r--source4/dynconfig.c2
-rw-r--r--source4/include/dynconfig.h1
-rw-r--r--source4/include/includes.h5
-rw-r--r--source4/include/smb.h1
-rw-r--r--source4/lib/com/config.mk1
-rw-r--r--source4/lib/com/main.c15
-rw-r--r--source4/lib/module.c58
-rw-r--r--source4/lib/registry/common/reg_interface.c13
-rw-r--r--source4/lib/registry/config.mk1
-rw-r--r--source4/lib/util.c17
-rw-r--r--source4/main.mk4
-rw-r--r--source4/ntptr/config.mk1
-rw-r--r--source4/ntptr/ntptr_base.c13
-rw-r--r--source4/ntvfs/config.mk1
-rw-r--r--source4/ntvfs/ntvfs_base.c13
-rw-r--r--source4/rpc_server/dcerpc_server.c8
-rwxr-xr-xsource4/script/mkproto.pl2
-rw-r--r--source4/smbd/process_model.c13
-rw-r--r--source4/smbd/process_model.mk1
-rw-r--r--source4/smbd/server.c9
-rw-r--r--source4/torture/com/simple.c2
28 files changed, 207 insertions, 41 deletions
diff --git a/source4/auth/auth.c b/source4/auth/auth.c
index db1a0a1c71..c1295f5cf1 100644
--- a/source4/auth/auth.c
+++ b/source4/auth/auth.c
@@ -334,5 +334,13 @@ const struct auth_critical_sizes *auth_interface_version(void)
NTSTATUS server_service_auth_init(void)
{
+ init_module_fn static_init[] = STATIC_AUTH_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "auth");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
return NT_STATUS_OK;
}
diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c
index 26f245787b..65e22c1467 100644
--- a/source4/auth/gensec/gensec.c
+++ b/source4/auth/gensec/gensec.c
@@ -942,5 +942,13 @@ const struct gensec_critical_sizes *gensec_interface_version(void)
*/
NTSTATUS gensec_init(void)
{
+ init_module_fn static_init[] = STATIC_GENSEC_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "gensec");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
return NT_STATUS_OK;
}
diff --git a/source4/build/smb_build/TODO b/source4/build/smb_build/TODO
index 190940fadb..f98a3d2bb5 100644
--- a/source4/build/smb_build/TODO
+++ b/source4/build/smb_build/TODO
@@ -7,6 +7,10 @@
(in Samba or other projects) can use the same (3rd) library.
- add register function to smbtorture
- init functions per shared library / binary
+ - add init functions + use lists of function pointers
+ - rpc_ndr
+ - list not automatically generated
+ - utility function for 'init mutex'
- install shared modules
- call load_modules() from subsystems/libraries/binaries with modules
- remove smb_build.h include from includes.h and INIT_OBJ_FILES. Replace
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 11a5eac1fb..bbf7efd8a0 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -49,6 +49,10 @@ sub check_module($$$)
die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM});
my $use_default = 0;
+
+ if (not exists($INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS})) {
+ $INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS} = [];
+ }
if (!(defined($INPUT->{$mod->{SUBSYSTEM}}))) {
$mod->{ENABLE} = "NO";
@@ -68,12 +72,12 @@ sub check_module($$$)
$mod->{OUTPUT_TYPE} = $default_ot;
}
- if ($mod->{OUTPUT_TYPE} eq "SHARED_LIBRARY" or
- $mod->{OUTPUT_TYPE} eq "STATIC_LIBRARY") {
+ if ($mod->{OUTPUT_TYPE} eq "SHARED_LIBRARY") {
$mod->{INSTALLDIR} = "LIBDIR/$mod->{SUBSYSTEM}";
push (@{$mod->{REQUIRED_SUBSYSTEMS}}, $mod->{SUBSYSTEM});
} else {
push (@{$INPUT->{$mod->{SUBSYSTEM}}{REQUIRED_SUBSYSTEMS}}, $mod->{NAME});
+ push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
}
}
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index b7a6ace404..598aaaba44 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -70,6 +70,7 @@ BINDIR = $self->{config}->{bindir}
SBINDIR = $self->{config}->{sbindir}
datadir = $self->{config}->{datadir}
LIBDIR = $self->{config}->{libdir}
+MODULESDIR = $self->{config}->{libdir}
INCLUDEDIR = $self->{config}->{includedir}
CONFIGDIR = $self->{config}->{configdir}
localstatedir = $self->{config}->{localstatedir}
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index d3d0840350..2fa8e0207a 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -137,8 +137,8 @@ sub create_output($)
push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
}
push(@{$part->{SUBSYSTEM_INIT_FUNCTIONS}}, $elem->{INIT_FUNCTION}) if
- #$part->{OUTPUT_TYPE} eq "BINARY" and
defined($elem->{INIT_FUNCTION}) and
+ $elem->{TYPE} ne "MODULE" and
$part->{OUTPUT_TYPE} ne "SHARED_LIBRARY";
}
}
diff --git a/source4/build/smb_build/smb_build_h.pm b/source4/build/smb_build/smb_build_h.pm
index e06e965ac7..2bb9f35c53 100644
--- a/source4/build/smb_build/smb_build_h.pm
+++ b/source4/build/smb_build/smb_build_h.pm
@@ -24,6 +24,8 @@ sub _prepare_smb_build_h($)
{
my $depend = shift;
my @defines = ();
+ my %declared = ();
+ my $output = "";
#
# loop over all binaries
@@ -42,7 +44,9 @@ sub _prepare_smb_build_h($)
$DEFINE->{KEY} = $name . "_init_subsystems";
$DEFINE->{VAL} = "do { \\\n";
foreach my $subkey (@{$key->{SUBSYSTEM_INIT_FUNCTIONS}}) {
- $DEFINE->{VAL} .= "\t\textern NTSTATUS $subkey(void); \\\n";
+ next if defined($declared{$subkey});
+ $output .= "NTSTATUS $subkey(void);\n";
+ $declared{$subkey} = 1;
}
foreach my $subkey (@{$key->{SUBSYSTEM_INIT_FUNCTIONS}}) {
@@ -53,6 +57,24 @@ sub _prepare_smb_build_h($)
push(@defines,$DEFINE);
}
+ foreach my $key (values %{$depend}) {
+ my $DEFINE = ();
+ next if ($key->{TYPE} ne "LIBRARY" and $key->{TYPE} ne "SUBSYSTEM");
+ next unless defined($key->{INIT_FUNCTIONS});
+
+ $DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
+ $DEFINE->{KEY} = "STATIC_$key->{NAME}_MODULES";
+ $DEFINE->{VAL} = "{ \\\n";
+ foreach (@{$key->{INIT_FUNCTIONS}}) {
+ $DEFINE->{VAL} .= "\t$_, \\\n";
+ $output .= "NTSTATUS $_(void);\n";
+ }
+
+ $DEFINE->{VAL} .= "\tNULL \\\n }";
+
+ push(@defines,$DEFINE);
+ }
+
#
# Shared modules
#
@@ -78,10 +100,7 @@ sub _prepare_smb_build_h($)
#
# loop over all SMB_BUILD_H define sections
#
- my $output = "";
- foreach my $key (@defines) {
- $output .= _add_define_section($key);
- }
+ foreach (@defines) { $output .= _add_define_section($_); }
return $output;
}
@@ -98,15 +117,12 @@ sub _prepare_smb_build_h($)
sub create_smb_build_h($$)
{
my ($CTX, $file) = @_;
- my $output = "/* autogenerated by build/smb_build/main.pl */\n";
-
- $output .= _prepare_smb_build_h($CTX);
open(SMB_BUILD_H,">$file") || die ("Can't open `$file'\n");
- print SMB_BUILD_H $output;
+ print SMB_BUILD_H "/* autogenerated by build/smb_build/main.pl */\n";
+ print SMB_BUILD_H _prepare_smb_build_h($CTX);
close(SMB_BUILD_H);
print __FILE__.": creating $file\n";
- return;
}
1;
diff --git a/source4/dynconfig.c b/source4/dynconfig.c
index caf75762d5..a098aa5086 100644
--- a/source4/dynconfig.c
+++ b/source4/dynconfig.c
@@ -59,6 +59,8 @@ const char *dyn_LMHOSTSFILE = LMHOSTSFILE;
/** Samba library directory. */
const char *dyn_LIBDIR = LIBDIR;
+const char *dyn_MODULESDIR = MODULESDIR;
+
/** Shared library extension */
const char *dyn_SHLIBEXT = SHLIBEXT;
diff --git a/source4/include/dynconfig.h b/source4/include/dynconfig.h
index 303ac1b6a4..8135e53c0b 100644
--- a/source4/include/dynconfig.h
+++ b/source4/include/dynconfig.h
@@ -31,6 +31,7 @@ extern const char *dyn_NCALRPCDIR;
extern const char *dyn_LOGFILEBASE;
extern const char *dyn_LMHOSTSFILE;
extern const char *dyn_LIBDIR;
+extern const char *dyn_MODULESDIR;
extern const char *dyn_SHLIBEXT;
extern const char *dyn_LOCKDIR;
extern const char *dyn_PIDDIR;
diff --git a/source4/include/includes.h b/source4/include/includes.h
index 9f5679fa80..fdd155b0ee 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -23,7 +23,6 @@
#ifndef NO_CONFIG_H /* for some tests */
#include "config.h"
-#include "smb_build.h"
#endif
#include "local.h"
@@ -114,6 +113,10 @@ struct ipv4_addr {
#include "cli_context.h"
#include "auth/credentials/credentials.h"
+#ifndef NO_CONFIG_H
+#include "smb_build.h"
+#endif
+
/***** automatically generated prototypes *****/
#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
#include "include/proto.h"
diff --git a/source4/include/smb.h b/source4/include/smb.h
index 51e7f666ca..73385d4373 100644
--- a/source4/include/smb.h
+++ b/source4/include/smb.h
@@ -608,5 +608,6 @@ enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_READ_LOCK, PENDING_WRITE_LOCK};
#define FS_ATTR_ENCRYPTION 0x00020000
#define FS_ATTR_NAMED_STREAMS 0x00040000
+typedef NTSTATUS (*init_module_fn) (void);
#endif /* _SMB_H */
diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk
index dc4fe644c6..77e3724924 100644
--- a/source4/lib/com/config.mk
+++ b/source4/lib/com/config.mk
@@ -1,4 +1,5 @@
[SUBSYSTEM::COM]
+INIT_FUNCTION = com_init
INIT_OBJ_FILES = \
tables.o \
rot.o \
diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c
index 210e8ba79c..f264c3f25b 100644
--- a/source4/lib/com/main.c
+++ b/source4/lib/com/main.c
@@ -24,7 +24,7 @@
#include "lib/events/events.h"
#include "librpc/gen_ndr/com_dcom.h"
-WERROR com_init(struct com_context **ctx, struct event_context *event_ctx)
+WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx)
{
*ctx = talloc(NULL, struct com_context);
if (event_ctx == NULL) {
@@ -88,3 +88,16 @@ WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct
return IUnknown_QueryInterface(iu, ctx, iid, ip);
}
+
+NTSTATUS com_init(void)
+{
+ init_module_fn static_init[] = STATIC_COM_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "com");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/lib/module.c b/source4/lib/module.c
index abb98cbf7b..672d8df7ce 100644
--- a/source4/lib/module.c
+++ b/source4/lib/module.c
@@ -21,65 +21,77 @@
#include "includes.h"
#include "system/dir.h"
-static BOOL load_module(TALLOC_CTX *mem_ctx, const char *dir, const char *name)
+static void *load_module(TALLOC_CTX *mem_ctx, const char *dir, const char *name)
{
char *path;
void *handle;
- BOOL (*init_module_fn) (void);
- BOOL ret;
+ void *init_fn;
path = talloc_asprintf(mem_ctx, "%s/%s", dir, name);
handle = dlopen(path, RTLD_NOW);
if (handle == NULL) {
DEBUG(0, ("Unable to open %s: %s\n", path, dlerror()));
- return False;
+ talloc_free(path);
+ return NULL;
}
- init_module_fn = dlsym(handle, "init_module");
+ init_fn = dlsym(handle, "init_module");
- if (init_module_fn == NULL) {
+ if (init_fn == NULL) {
DEBUG(0, ("Unable to find init_module() in %s: %s\n", path, dlerror()));
- return False;
- }
-
- ret = init_module_fn();
- if (!ret) {
DEBUG(1, ("Loading module '%s' failed\n", path));
+ dlclose(handle);
+ talloc_free(path);
+ return NULL;
}
- dlclose(handle);
-
talloc_free(path);
- return ret;
+ return init_fn;
}
-BOOL load_modules(const char *path)
+init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
{
DIR *dir;
struct dirent *entry;
- BOOL ret = True;
- TALLOC_CTX *mem_ctx;
-
- mem_ctx = talloc_init(NULL);
+ int success = 0;
+ init_module_fn *ret = talloc_array(mem_ctx, init_module_fn, 2);
+ ret[0] = NULL;
+
dir = opendir(path);
if (dir == NULL) {
- talloc_free(mem_ctx);
- return False;
+ talloc_free(ret);
+ return NULL;
}
while((entry = readdir(dir))) {
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
continue;
- ret &= load_module(mem_ctx, path, entry->d_name);
+ ret[success] = load_module(mem_ctx, path, entry->d_name);
+ if (ret[success]) {
+ ret = talloc_realloc(mem_ctx, ret, init_module_fn, success+2);
+ success++;
+ ret[success] = NULL;
+ }
}
closedir(dir);
- talloc_free(mem_ctx);
+ return ret;
+}
+
+BOOL run_init_functions(NTSTATUS (**fns) (void))
+{
+ int i;
+ BOOL ret;
+
+ if (fns == NULL)
+ return True;
+
+ for (i = 0; fns[i]; i++) { ret &= NT_STATUS_IS_OK(fns[i]()); }
return ret;
}
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index 87bc3fd70c..ac8b90dcdb 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -64,6 +64,19 @@ static struct reg_init_function_entry *reg_find_backend_entry(const char *name)
return NULL;
}
+NTSTATUS registry_init(void)
+{
+ init_module_fn static_init[] = STATIC_REGISTRY_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "registry");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
+ return NT_STATUS_OK;
+}
+
/* Check whether a certain backend is present */
BOOL reg_has_backend(const char *backend)
{
diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk
index 775e201f7e..768697e2a1 100644
--- a/source4/lib/registry/config.mk
+++ b/source4/lib/registry/config.mk
@@ -81,6 +81,7 @@ REQUIRED_SUBSYSTEMS = \
[LIBRARY::REGISTRY]
MAJOR_VERSION = 0
MINOR_VERSION = 0
+INIT_FUNCTION = registry_init
DESCRIPTION = Windows-style registry library
RELEASE_VERSION = 1
INIT_OBJ_FILES = \
diff --git a/source4/lib/util.c b/source4/lib/util.c
index 3b4064098c..3443d137d6 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -690,6 +690,23 @@ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name)
return fname;
}
+char *modules_path(TALLOC_CTX* mem_ctx, const char *name)
+{
+ return talloc_asprintf(mem_ctx, "%s/%s", dyn_MODULESDIR, name);
+}
+
+init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem)
+{
+ char *path = modules_path(mem_ctx, subsystem);
+ init_module_fn *ret;
+
+ ret = load_modules(mem_ctx, path);
+
+ talloc_free(path);
+
+ return ret;
+}
+
void dump_data_pw(const char *msg, const uint8_t * data, size_t len)
{
#ifdef DEBUG_PASSWORD
diff --git a/source4/main.mk b/source4/main.mk
index deb0362386..b6fba87cc5 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -42,6 +42,7 @@ showlayout:
@echo " bindir: $(BINDIR)"
@echo " sbindir: $(SBINDIR)"
@echo " libdir: $(LIBDIR)"
+ @echo " modulesdir: $(MODULESDIR)"
@echo " includedir: $(INCLUDEDIR)"
@echo " vardir: $(VARDIR)"
@echo " privatedir: $(PRIVATEDIR)"
@@ -74,7 +75,8 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" -DSBINDIR=\"$(SBINDIR)\" \
-DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DLIBDIR=\"$(LIBDIR)\" \
-DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"$(SHLIBEXT)\" \
-DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
- -DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\"
+ -DSWATDIR=\"$(SWATDIR)\" -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
+ -DMODULESDIR=\"$(MODULESDIR)\"
install: showlayout installbin installdat installswat installmisc installlib \
installheader installpc
diff --git a/source4/ntptr/config.mk b/source4/ntptr/config.mk
index cbce1d66bd..37150211fc 100644
--- a/source4/ntptr/config.mk
+++ b/source4/ntptr/config.mk
@@ -15,6 +15,7 @@ REQUIRED_SUBSYSTEMS = \
################################################
# Start SUBSYSTEM NTPTR
[SUBSYSTEM::NTPTR]
+INIT_FUNCTION = ntptr_init
INIT_OBJ_FILES = \
ntptr_base.o
ADD_OBJ_FILES = \
diff --git a/source4/ntptr/ntptr_base.c b/source4/ntptr/ntptr_base.c
index f12a58cb4e..9f07ae597b 100644
--- a/source4/ntptr/ntptr_base.c
+++ b/source4/ntptr/ntptr_base.c
@@ -69,6 +69,19 @@ NTSTATUS ntptr_register(const void *_ops)
return NT_STATUS_OK;
}
+NTSTATUS ntptr_init(void)
+{
+ init_module_fn static_init[] = STATIC_NTPTR_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "ntptr");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
+ return NT_STATUS_OK;
+}
+
/*
return the operations structure for a named backend
diff --git a/source4/ntvfs/config.mk b/source4/ntvfs/config.mk
index 95f0886d06..a600a9a9a0 100644
--- a/source4/ntvfs/config.mk
+++ b/source4/ntvfs/config.mk
@@ -77,6 +77,7 @@ ADD_OBJ_FILES = \
PUBLIC_HEADERS = ntvfs.h
MAJOR_VERSION = 0
MINOR_VERSION = 0
+INIT_FUNCTION = ntvfs_init
DESCRIPTION = Virtual File System with NTFS semantics
RELEASE_VERSION = 1
INIT_OBJ_FILES = \
diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c
index b8aeed419c..9cb8293cbc 100644
--- a/source4/ntvfs/ntvfs_base.c
+++ b/source4/ntvfs/ntvfs_base.c
@@ -158,3 +158,16 @@ NTSTATUS ntvfs_init_connection(struct smbsrv_request *req, enum ntvfs_type type)
return NT_STATUS_OK;
}
+
+NTSTATUS ntvfs_init(void)
+{
+ init_module_fn static_init[] = STATIC_NTVFS_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "ntvfs");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 17a097a4cc..276779ef19 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -1338,5 +1338,13 @@ static NTSTATUS dcesrv_init(struct event_context *event_context, const struct mo
NTSTATUS server_service_rpc_init(void)
{
+ init_module_fn static_init[] = STATIC_DCERPC_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "rpc_server");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
return register_server_service("rpc", dcesrv_init);
}
diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl
index 22b012ad8c..7d80c63f99 100755
--- a/source4/script/mkproto.pl
+++ b/source4/script/mkproto.pl
@@ -117,7 +117,7 @@ sub process_file($$$)
next unless ( $line =~ /
^void|^BOOL|^int|^struct|^char|^const|^\w+_[tT]\s|^uint|^unsigned|^long|
^NTSTATUS|^ADS_STATUS|^enum\s.*\(|^DATA_BLOB|^WERROR|^XFILE|^FILE|^DIR|
- ^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME|^FN_|^REG_KEY|^REG_HANDLE|^REG_VAL|
+ ^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME|^FN_|^init_module|
^GtkWidget|^GType|^smb_ucs2_t
/xo);
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index d3e5eeaa48..312cc5e264 100644
--- a/source4/smbd/process_model.c
+++ b/source4/smbd/process_model.c
@@ -80,6 +80,19 @@ NTSTATUS register_process_model(const void *_ops)
return NT_STATUS_OK;
}
+NTSTATUS process_model_init(void)
+{
+ init_module_fn static_init[] = STATIC_PROCESS_MODEL_MODULES;
+ init_module_fn *shared_init = load_samba_modules(NULL, "process_model");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
+ return NT_STATUS_OK;
+}
+
/*
return the operations structure for a named backend of the specified type
*/
diff --git a/source4/smbd/process_model.mk b/source4/smbd/process_model.mk
index 2e71a8fb7a..11df266dc6 100644
--- a/source4/smbd/process_model.mk
+++ b/source4/smbd/process_model.mk
@@ -34,6 +34,7 @@ REQUIRED_SUBSYSTEMS = EXT_LIB_PTHREAD
################################################
# Start SUBSYSTEM PROCESS_MODEL
[SUBSYSTEM::PROCESS_MODEL]
+INIT_FUNCTION = process_model_init
INIT_OBJ_FILES = \
process_model.o
#
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 97b9bf8023..838cb627d7 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -154,6 +154,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
BOOL interactive = False;
int opt;
poptContext pc;
+ init_module_fn static_init[] = STATIC_SERVER_SERVICE_MODULES;
+ init_module_fn *shared_init;
struct event_context *event_ctx;
NTSTATUS status;
const char *model = "standard";
@@ -214,6 +216,13 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
smbd_init_subsystems;
+ shared_init = load_samba_modules(NULL, "service");
+
+ run_init_functions(static_init);
+ run_init_functions(shared_init);
+
+ talloc_free(shared_init);
+
/* the event context is the top level structure in smbd. Everything else
should hang off that */
event_ctx = event_context_init(NULL);
diff --git a/source4/torture/com/simple.c b/source4/torture/com/simple.c
index 12ff6bee3c..de16b113a2 100644
--- a/source4/torture/com/simple.c
+++ b/source4/torture/com/simple.c
@@ -38,7 +38,7 @@ static BOOL test_readwrite(TALLOC_CTX *mem_ctx, const char *host)
char test_data[5];
int i;
- com_init(&ctx, NULL);
+ com_init_ctx(&ctx, NULL);
dcom_client_init(ctx, cmdline_credentials);
GUID_from_string(COM_ISTREAM_UUID, &IID[0]);