r12494: Support loading modules from .so files for most subsystems.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 26 Dec 2005 16:46:55 +0000 (16:46 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:47:45 +0000 (13:47 -0500)
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)

28 files changed:
source4/auth/auth.c
source4/auth/gensec/gensec.c
source4/build/smb_build/TODO
source4/build/smb_build/input.pm
source4/build/smb_build/makefile.pm
source4/build/smb_build/output.pm
source4/build/smb_build/smb_build_h.pm
source4/dynconfig.c
source4/include/dynconfig.h
source4/include/includes.h
source4/include/smb.h
source4/lib/com/config.mk
source4/lib/com/main.c
source4/lib/module.c
source4/lib/registry/common/reg_interface.c
source4/lib/registry/config.mk
source4/lib/util.c
source4/main.mk
source4/ntptr/config.mk
source4/ntptr/ntptr_base.c
source4/ntvfs/config.mk
source4/ntvfs/ntvfs_base.c
source4/rpc_server/dcerpc_server.c
source4/script/mkproto.pl
source4/smbd/process_model.c
source4/smbd/process_model.mk
source4/smbd/server.c
source4/torture/com/simple.c

index db1a0a1c719324d6223f8d83bedec751ff21699f..c1295f5cf1d62c8fddd4d6940e8d09bd4ca6648a 100644 (file)
@@ -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;    
 }
index 26f245787bec9c47ff6559dba5c2ddb35853887a..65e22c1467e7561da81d5fc5036ca4076b1f6abd 100644 (file)
@@ -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;
 }
index 190940fadb3170dea405630d1fff011e51a7570d..f98a3d2bb58ba796b482c58110afb947fdd43b14 100644 (file)
@@ -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 
index 11a5eac1fb45584bdbc70856b8e39c58f824a7c1..bbf7efd8a0cb40ed7e6d4e878a3516fd57f78cdc 100644 (file)
@@ -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});
        }
 }
 
index b7a6ace404ca6b283675959545f0b1feacb42660..598aaaba4440a202ce8b2067371e60589d995073 100644 (file)
@@ -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}
index d3d08403500485b5dbdb895356114fed41a24f9b..2fa8e0207a9808a6d3248d1def525190933dc9ba 100644 (file)
@@ -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";
                }
        }
index e06e965ac75a5a5aeb8ade2a9f1200faf88dd863..2bb9f35c5390780689aa42d16725261d61352b48 100644 (file)
@@ -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;
index caf75762d558148203469eb868255036591b270f..a098aa50865706b2a3a06d24f0bfb215d237fefb 100644 (file)
@@ -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;
 
index 303ac1b6a431fee712eaf017a2559cdd523791eb..8135e53c0b136e8ea577462f319e7b60d6ea1cd7 100644 (file)
@@ -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;
index 9f5679fa80ed211d7d73fdea3c58011daa648009..fdd155b0eee95d2608e81ce92e83d86e7ae51841 100644 (file)
@@ -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"
index 51e7f666ca239f17792a84b62d8763bdf21136b7..73385d43737f11592ca5742cc79a5d67e1d96e5d 100644 (file)
@@ -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 */
index dc4fe644c6980b9d0bc607ace0020538e3cd1ba0..77e37249249d4fd3104891329c52781d0f279cb5 100644 (file)
@@ -1,4 +1,5 @@
 [SUBSYSTEM::COM]
+INIT_FUNCTION = com_init
 INIT_OBJ_FILES = \
                tables.o \
                rot.o \
index 210e8ba79c39d3060e35c9349bedbb1cde0077a7..f264c3f25b60828e822fc7d3f2c2a4bc46bb1d7d 100644 (file)
@@ -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;    
+}
index abb98cbf7b2aa3198fe8d75e68df83807fba6326..672d8df7cefd587715d78111a2098cd2b34c514b 100644 (file)
 #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;
 }
index 87bc3fd70c28ee37d1cd0c7193ae82b84fe9f6ef..ac8b90dcdbed80b0be5373fd27677122b3538a8b 100644 (file)
@@ -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)
 {
index 775e201f7e5ecb725b512bca79934bf5fd354932..768697e2a1450c73e1ab641de55ca61bffcdfa1f 100644 (file)
@@ -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 = \
index 3b4064098c6b7a634f4807e9fbf9d3f9a315f921..3443d137d69a2e13a9f01ea6a681c074d17c4e26 100644 (file)
@@ -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
index deb0362386b602356dfc6e89a37130271d6a71eb..b6fba87cc5cdd7bb26e2f1dd1a5e1e577e04e3da 100644 (file)
@@ -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
index cbce1d66bd67d09b45c2170b688d10a418ac680c..37150211fc67706eed5c18abb047bbd81aad9fff 100644 (file)
@@ -15,6 +15,7 @@ REQUIRED_SUBSYSTEMS = \
 ################################################
 # Start SUBSYSTEM NTPTR
 [SUBSYSTEM::NTPTR]
+INIT_FUNCTION = ntptr_init
 INIT_OBJ_FILES = \
                ntptr_base.o
 ADD_OBJ_FILES = \
index f12a58cb4ec6daec50fd90d4812975580f358ae5..9f07ae597bb2e1f01130f241353835fe4b7b2d1c 100644 (file)
@@ -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
index 95f0886d06908a7f0523633a4135296fa50239bb..a600a9a9a0a5be54f3784c4d956a6de2e4ced378 100644 (file)
@@ -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 = \
index b8aeed419cfad2f5f9ff8d54531b2707dce685b3..9cb8293cbc3697a94c5328cf702fce3708245451 100644 (file)
@@ -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;
+}
index 17a097a4cc63a0203fae48ce7f22542402185c52..276779ef19175a6651b2203fa79b095a02cc5303 100644 (file)
@@ -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);
 }
index 22b012ad8cbe8445aa135059ca37dfd9128708ec..7d80c63f9980a8597c74069c048bc1e33954c344 100755 (executable)
@@ -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);
 
index d3e5eeaa48b78303b09d24e283fc1db765d91e45..312cc5e264a915ea0d4aa5b2512fc2323b1345e1 100644 (file)
@@ -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
 */
index 2e71a8fb7ad6f39b56a277d8e05883c59272cf1f..11df266dc6be8c7fb8ece0a4c393f8f8d33c26e6 100644 (file)
@@ -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
 #
index 97b9bf8023048d02802f8e9073ca6c1933dfa513..838cb627d73c174743b22c4aada8cd7903584b11 100644 (file)
@@ -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);
index 12ff6bee3cb07dd998562c652883b097e0939e9e..de16b113a2b9e25afaf16cff452999c54a16664a 100644 (file)
@@ -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]);