r12620: Get rid of automatically generated lists of init functions of subsystems.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 30 Dec 2005 22:46:16 +0000 (22:46 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:49:06 +0000 (13:49 -0500)
This allows Samba libraries to be used by other projects (and parts of
Samba to be built as shared libraries).
(This used to be commit 44f0aba715bfedc7e1ee3d07e9a101a91dbd84b3)

31 files changed:
source4/auth/gensec/gensec.c
source4/build/smb_build/config_mk.pm
source4/build/smb_build/smb_build_h.pm
source4/client/client.c
source4/gtk/tools/gepdump.c
source4/gtk/tools/gregedit.c
source4/gtk/tools/gwcrontab.c
source4/gtk/tools/gwsam.c
source4/lib/com/config.mk
source4/lib/com/main.c
source4/lib/ldb/tools/cmdline.c
source4/lib/registry/reg_backend_rpc.c
source4/lib/registry/tools/regdiff.c
source4/lib/registry/tools/regpatch.c
source4/lib/registry/tools/regshell.c
source4/lib/registry/tools/regtree.c
source4/librpc/config.mk
source4/librpc/rpc/dcerpc.c
source4/librpc/tables.pl
source4/rpc_server/remote/dcesrv_remote.c
source4/scripting/ejs/smbcalls_rpc.c
source4/scripting/ejs/smbscript.c
source4/smbd/server.c
source4/torture/com/simple.c
source4/torture/gentest.c
source4/torture/locktest.c
source4/torture/masktest.c
source4/torture/torture.c
source4/utils/ndrdump.c
source4/utils/net/net.c
source4/utils/ntlm_auth.c

index aaac3ef78cb5353d95f5897a85572e63a40840bf..5ff925c078bf9abfa61d4a801d0fd0ce4fc27266 100644 (file)
@@ -943,9 +943,14 @@ const struct gensec_critical_sizes *gensec_interface_version(void)
 */
 NTSTATUS gensec_init(void)
 {
+       static BOOL initialized = False;
+
        init_module_fn static_init[] = STATIC_GENSEC_MODULES;
        init_module_fn *shared_init = load_samba_modules(NULL, "gensec");
 
+       if (initialized) return NT_STATUS_OK;
+       initialized = False;
+
        run_init_functions(static_init);
        run_init_functions(shared_init);
 
index 405298eef241ff0389ef8f787c7becef578602ac..b7c4ff572ae853c500382b5fdc738f6979a6edd3 100644 (file)
@@ -20,7 +20,6 @@ my $section_types = {
                "LDFLAGS"               => "list",
                },
        "SUBSYSTEM" => {
-               "INIT_FUNCTION"         => "string",
                "OBJ_FILES"             => "list",
 
                "REQUIRED_SUBSYSTEMS"   => "list",
@@ -64,7 +63,6 @@ my $section_types = {
                "MINOR_VERSION"         => "string",
                "RELEASE_VERSION"       => "string",
 
-               "INIT_FUNCTION"         => "string",
                "OBJ_FILES"             => "list",
 
                "DESCRIPTION" => "string",
index 2bb9f35c5390780689aa42d16725261d61352b48..52fe0da6da4abf94bbb7ca9a88c78218984ee760 100644 (file)
@@ -24,39 +24,8 @@ sub _prepare_smb_build_h($)
 {
        my $depend = shift;
        my @defines = ();
-       my %declared = ();
        my $output = "";
 
-       #
-       # loop over all binaries
-       #
-       foreach my $key (values %{$depend}) {
-               next if ($key->{TYPE} ne "BINARY");
-
-               my $NAME = $key->{NAME};
-               my $DEFINE = ();
-               my $name = lc($NAME);
-
-               #
-               # Static modules
-               # 
-               $DEFINE->{COMMENT} = "BINARY $NAME INIT";
-               $DEFINE->{KEY} = $name . "_init_subsystems";
-               $DEFINE->{VAL} = "do { \\\n";
-               foreach my $subkey (@{$key->{SUBSYSTEM_INIT_FUNCTIONS}}) {
-                       next if defined($declared{$subkey});
-                       $output .= "NTSTATUS $subkey(void);\n";
-                       $declared{$subkey} = 1;
-               }
-       
-               foreach my $subkey (@{$key->{SUBSYSTEM_INIT_FUNCTIONS}}) {
-                       $DEFINE->{VAL} .= "\t\tif (NT_STATUS_IS_ERR($subkey())) exit(1); \\\n";
-               }
-               $DEFINE->{VAL} .= "\t} while(0)";
-               
-               push(@defines,$DEFINE);
-       }
-
        foreach my $key (values %{$depend}) {
                my $DEFINE = ();
                next if ($key->{TYPE} ne "LIBRARY" and $key->{TYPE} ne "SUBSYSTEM");
index fef847e8b2eaac5944c6bcf450ad46d99a454238..fb070424960d1a6bc2278b01821f732264936e9c 100644 (file)
@@ -33,7 +33,7 @@
 #include "dlinklist.h"
 #include "system/readline.h"
 #include "pstring.h"
-#include "smb_build.h"
+#include "auth/gensec/gensec.h"
 
 static struct smbcli_state *cli;
 static int port = 0;
@@ -3402,7 +3402,7 @@ static void remember_query_host(const char *arg,
                }
        }
 
-       smbclient_init_subsystems;
+       gensec_init();
 
        if(poptPeekArg(pc)) {
                pstrcpy(service,poptGetArg(pc));  
index ea77b193852a5f5fae90235e089880c2327f19f8..eab3987a9a6c9b1be6c6731278ac237d8a1c2234 100644 (file)
@@ -24,7 +24,6 @@
 #include "librpc/gen_ndr/ndr_mgmt.h"
 #include "gtk/common/gtk-smb.h"
 #include "auth/gensec/gensec.h"
-#include "smb_build.h"
 
 /* 
  * Show: 
@@ -461,7 +460,7 @@ static GtkWidget* create_mainwindow (void)
 
 int main(int argc, char **argv)
 {
-       gepdump_init_subsystems;
+       dcerpc_init();
        lp_load();
        setup_logging(argv[0], DEBUG_STDERR);
 
index 8c243873ca4b9568e69a5c4b7947b6a1e2e13243..5dd5ec1a92a54d53605ff3978e4a1cb0af591bc2 100644 (file)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "lib/registry/registry.h"
 #include "gtk/common/gtk-smb.h"
-#include "smb_build.h"
 
 static GtkTreeStore *store_keys;
 static GtkListStore *store_vals;
@@ -964,8 +963,8 @@ int main(int argc, char *argv[])
 {
        int ret;
 
-       gregedit_init_subsystems;
        registry_init();
+
        lp_load();
        setup_logging(argv[0], DEBUG_STDERR);
 
index f294e8439239b412fdfc95c59815ae85292c571b..9ebc7f43fdcf75b646435ac7f6887f8778a17e04 100644 (file)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "librpc/gen_ndr/ndr_atsvc.h"
 #include "gtk/common/gtk-smb.h"
-#include "smb_build.h"
 
 static struct dcerpc_pipe *at_pipe = NULL;
 static GtkWidget *mainwin;
@@ -489,10 +488,9 @@ static GtkWidget*create_new_job_dialog (void)
 }
 
 
-
- int main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-       gwcrontab_init_subsystems;
+       dcerpc_init();
        lp_load();
        setup_logging(argv[0], DEBUG_STDERR);
 
index 963397810c0af2f18fdaaaeb74d2fc43c797196c..3764afe04679248933c03fa1438cb6e6429067a4 100644 (file)
@@ -23,7 +23,6 @@
 #include "librpc/gen_ndr/ndr_samr.h"
 #include "gtk/common/select.h"
 #include "gtk/common/gtk-smb.h"
-#include "smb_build.h"
 
 struct policy_handle sam_handle;
 struct dcerpc_pipe *sam_pipe = NULL;
@@ -398,11 +397,8 @@ static GtkWidget* create_mainwindow (void)
        return mainwin;
 }
 
-
-
- int main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-       gwsam_init_subsystems;
        lp_load();
        setup_logging(argv[0], DEBUG_STDERR);
 
index 9e66502046c4d73355b6ec1ff8f2774e2eb43593..12f0481b0f866abebfc2301e202b2ae4a0113c76 100644 (file)
@@ -1,5 +1,4 @@
 [SUBSYSTEM::COM]
-INIT_FUNCTION = com_init
 OBJ_FILES = \
                tables.o \
                rot.o \
index 123ba49b09fb74d958d56d829d48affeb0c734e3..f2e4f6473ad64bac664a438c072f59a922588fa0 100644 (file)
@@ -92,8 +92,15 @@ WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct
 
 NTSTATUS com_init(void)
 {
-       init_module_fn static_init[] = STATIC_COM_MODULES;
-       init_module_fn *shared_init = load_samba_modules(NULL, "com");
+       static BOOL initialized = False;
+       
+       init_module_fn static_init[] = STATIC_COM_MODULES; 
+       init_module_fn *shared_init;
+
+       if (initialized) return NT_STATUS_OK;
+       initialized = True;
+
+       shared_init = load_samba_modules(NULL, "com");
 
        run_init_functions(static_init);
        run_init_functions(shared_init);
index a14434622fdfbbaa2c394d1fa3d6e04a82266e5b..c134c3befd1657735bef44a392961fc7beb4bba4 100644 (file)
@@ -28,7 +28,6 @@
 #include "ldb/tools/cmdline.h"
 #ifdef _SAMBA_BUILD_
 #include "lib/cmdline/popt_common.h"
-#include "smb_build.h"
 #include "auth/auth.h"
 #endif
 
@@ -72,7 +71,8 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const
        };
 
 #ifdef _SAMBA_BUILD_
-       ldbsearch_init_subsystems;
+       gensec_init(); 
+
        r = ldb_register_samba_handlers(ldb);
        if (r != 0) {
                goto failed;
index e799b3a8e4a3a7af8721a3e66234cc4da458d093..32ecbec6c6cef6cb8352002e7f3d40ae551bb2f1 100644 (file)
@@ -389,5 +389,6 @@ WERROR reg_open_remote(struct registry_context **ctx, struct cli_credentials *cr
 
 NTSTATUS registry_rpc_init(void)
 {
+       dcerpc_init();
        return registry_register(&reg_backend_rpc);
 }
index 68cc56f9dd386892274515376da81f8c3dc2a25b..5b876ca0250c032a1cb44ebd5af52d0925560484 100644 (file)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
-#include "smb_build.h"
 
 int main(int argc, char **argv)
 {
@@ -45,8 +44,6 @@ int main(int argc, char **argv)
                POPT_TABLEEND
        };
 
-       regdiff_init_subsystems;
-
        registry_init();
 
        pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
index b8b88054863e97ada7adbd2f83975faee7ae8218..6f5c79bc0eb2bc823ae9542ec15cecb65df5319f 100644 (file)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
-#include "smb_build.h"
 
 int main(int argc, char **argv)
 {
@@ -41,8 +40,6 @@ int main(int argc, char **argv)
                POPT_TABLEEND
        };
 
-       regpatch_init_subsystems;
-
        registry_init();
 
        pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
index c858b37f4a1744de50c2c8fd9f7e098c10aa14b9..89493c761e07276463b7c544149ed4db7b9eac53 100644 (file)
@@ -23,7 +23,6 @@
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
 #include "system/time.h"
-#include "smb_build.h"
 
 /* 
  * ck/cd - change key
@@ -415,8 +414,6 @@ static char **reg_completion(const char *text, int start, int end)
                POPT_TABLEEND
        };
 
-       regshell_init_subsystems;
-
        registry_init();
 
        pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
index 9a9121379b9d7265f4bf3a51604910717904da5c..d8f5d68a947586b67cbedd3dd756f2b6f07964de 100644 (file)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "lib/registry/registry.h"
 #include "lib/cmdline/popt_common.h"
-#include "smb_build.h"
 
 static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
 {
@@ -98,8 +97,6 @@ int main(int argc, char **argv)
                POPT_TABLEEND
        };
 
-       regtree_init_subsystems;
-
        registry_init();
 
        pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
index 06254a67482f20367dbb80c5e8e3f3ec363a104e..03367bdf1748734f685aa7c863562a6c7e27b90b 100644 (file)
@@ -302,14 +302,9 @@ librpc/gen_ndr/tables.c: librpc/gen_ndr/ndr_*.h
        @$(PERL) librpc/tables.pl --output=librpc/gen_ndr/tables.c \
                                                                        librpc/gen_ndr/ndr_*.h
 
-[SUBSYSTEM::NDR_IFACE_TABLE]
-NOPROTO = YES
-OBJ_FILES = gen_ndr/tables.o
-
 [SUBSYSTEM::NDR_ALL]
-INIT_FUNCTION = dcerpc_table_init
-OBJ_FILES = rpc/table.o 
-REQUIRED_SUBSYSTEMS = NDR_IFACE_TABLE NDR_AUDIOSRV NDR_ECHO NDR_DCERPC NDR_EXCHANGE \
+OBJ_FILES = rpc/table.o gen_ndr/tables.o
+REQUIRED_SUBSYSTEMS = NDR_AUDIOSRV NDR_ECHO NDR_DCERPC NDR_EXCHANGE \
        NDR_DSBACKUP NDR_EFS NDR_MISC NDR_LSA NDR_DFS NDR_DRSUAPI \
        NDR_POLICYAGENT NDR_UNIXINFO NDR_SAMR NDR_SPOOLSS NDR_WKSSVC NDR_SRVSVC NDR_ATSVC \
        NDR_EVENTLOG NDR_EPMAPPER NDR_DBGIDL NDR_DSSETUP NDR_MSGSVC NDR_WINS \
index df71be7651375c95e26fcf088e7f9ffd9cfacd35..0269eb9919a3b54c215ff86cdf39cfeda641cd2c 100644 (file)
 #include "libcli/composite/composite.h"
 #include "auth/gensec/gensec.h"
 
+NTSTATUS dcerpc_init(void)
+{
+       gensec_init();
+
+       return NT_STATUS_OK;
+}
+
 static void dcerpc_ship_next_request(struct dcerpc_connection *c);
 
 /* destroy a dcerpc connection */
index 5757dc000a3ecbe47b1bc2f03125809ddf84bea5..7ef1dbd14af0451ad2e1d74ae3cb345c9280df42 100644 (file)
@@ -82,6 +82,11 @@ print TABLEC <<EOF;
 
 NTSTATUS dcerpc_table_init(void)
 {
+       static BOOL initialized = False;
+
+       if (initialized) return NT_STATUS_OK;
+       initialized = True;
+
 $init_fns
        
        return NT_STATUS_OK;
index 4cd4b2b507f34d7b46ab89f615334f5d1a1a1514..f7de3031ceae8c5355b453afe7d4dba996050111 100644 (file)
@@ -309,5 +309,8 @@ NTSTATUS dcerpc_server_remote_init(void)
                return ret;
        }
 
+       /* We need the full DCE/RPC interface table */
+       dcerpc_table_init();
+
        return ret;
 }
index dff04a4c404ea812d49efc2ed9047c01c28dd390..a104f0eb16c8f624df380659fd1074b6991a30ad 100644 (file)
@@ -367,6 +367,8 @@ done:
 */
 int ejs_rpc_init(struct MprVar *obj, const char *name)
 {
+       dcerpc_table_init();
+
        mprSetStringCFunction(obj, "connect", ejs_rpc_connect);
        if (mprGetProperty(obj, "pipe_name", NULL) == NULL) {
                mprSetVar(obj, "pipe_name", mprString(name));
index 0e131e0ba53a241e20bd1f8113afe2011873e7b9..20675dadf907f879b634c018f1e48d3d9d2d726e 100644 (file)
@@ -25,7 +25,7 @@
 #include "lib/appweb/ejs/ejs.h"
 #include "lib/appweb/ejs/ejsInternal.h"
 #include "scripting/ejs/smbcalls.h"
-#include "smb_build.h"
+#include "auth/gensec/gensec.h"
 
 static EjsId eid;
 
@@ -50,7 +50,7 @@ void ejs_exception(const char *reason)
        int exit_status, i;
 
        fault_setup(argv[0]);
-       smbscript_init_subsystems;
+       gensec_init();
        mprSetCtx(mem_ctx);
 
        lp_load();
index e09c993f3c81933e2d645e8778dd09f90d3ba649..513fa19c428150d9240473f3a1ef3b2eed4f4c29 100644 (file)
@@ -33,6 +33,7 @@
 #include "registry/registry.h"
 #include "ntvfs/ntvfs.h"
 #include "ntptr/ntptr.h"
+#include "auth/gensec/gensec.h"
 
 /*
   recursively delete a directory tree
@@ -217,7 +218,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
                exit(1);
        }
 
-       smbd_init_subsystems;
+       gensec_init();
 
        registry_init(); /* FIXME: maybe run this in the initialization function 
                                                of the winreg RPC server instead? */
index 09061422f5f6fac254c2d1df0b6e958edd15bcb8..5d3c6250c47bc643eeb60be9cbcd3698effffcc7 100644 (file)
@@ -38,6 +38,8 @@ static BOOL test_readwrite(TALLOC_CTX *mem_ctx, const char *host)
        char test_data[5];
        int i;
 
+       com_init();
+
        com_init_ctx(&ctx, NULL);
        dcom_client_init(ctx, cmdline_credentials);
 
index d4666712523d1f1370f2f6a9c9c6427ceb420988..a576b57458554dd3a552ea9039b5bf6821c435c1 100644 (file)
@@ -24,7 +24,7 @@
 #include "request.h"
 #include "libcli/raw/libcliraw.h"
 #include "librpc/gen_ndr/ndr_security.h"
-#include "smb_build.h"
+#include "auth/gensec/gensec.h"
 
 #define NSERVERS 2
 #define NINSTANCES 2
@@ -2234,7 +2234,7 @@ static void usage(void)
                }
        }
 
-       gentest_init_subsystems;
+       gensec_init();
 
        if (username_count == 0) {
                usage();
index a94a6f1ec9ebec1d409681f1fa6317b30aad82f6..be2d3022da525848be8014ce8a6061dc519c297b 100644 (file)
@@ -22,7 +22,7 @@
 #include "system/filesys.h"
 #include "system/time.h"
 #include "pstring.h"
-#include "smb_build.h"
+#include "auth/gensec/gensec.h"
 
 static int numops = 1000;
 static BOOL showall;
@@ -550,7 +550,7 @@ static void usage(void)
                servers[1] = servers[0];
        }
 
-       locktest_init_subsystems;
+       gensec_init();
 
        argc -= optind;
        argv += optind;
index 5e8f973c4c7cbb341a3e4234b2e02d8b76e04ee2..ca5bdf7c21e96df46778a0c052a4751536974ecc 100644 (file)
@@ -24,7 +24,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "system/time.h"
 #include "pstring.h"
-#include "smb_build.h"
+#include "auth/gensec/gensec.h"
 
 static struct cli_credentials *credentials;
 static BOOL showall = False;
@@ -353,7 +353,7 @@ static void usage(void)
                }
        }
 
-       masktest_init_subsystems;
+       gensec_init();
 
        argc -= optind;
        argv += optind;
index 149ee78065cbc155256b87d6945baabea9ffe0c2..82fda0d4ff58dda89ae639f0d0a6e7d89305fe69 100644 (file)
@@ -25,7 +25,6 @@
 #include "system/wait.h"
 #include "system/filesys.h"
 #include "ioctl.h"
-#include "smb_build.h"
 
 int torture_nprocs=4;
 int torture_numops=10;
@@ -2609,7 +2608,7 @@ static void max_runtime_handler(int sig)
                alarm(max_runtime);
        }
 
-       smbtorture_init_subsystems;
+       dcerpc_init();
 
        dcerpc_table_init();
 
index 33bffe77b58ba4f8ba8ec4ccdd4d41c9356145df..497726279b978d863765291d0f87d8c09bd0823d 100644 (file)
@@ -22,7 +22,6 @@
 #include "lib/cmdline/popt_common.h"
 #include "system/iconv.h"
 #include "system/filesys.h"
-#include "smb_build.h"
 
 static const struct dcerpc_interface_call *find_function(
        const struct dcerpc_interface_table *p,
index 17b12b7103d316a8cb1725710947c1602bafa3b4..f82eddb76364a8d9fa5ff456a1bed6854fa5af37 100644 (file)
@@ -44,7 +44,6 @@
 #include "includes.h"
 #include "utils/net/net.h"
 #include "lib/cmdline/popt_common.h"
-#include "smb_build.h"
 
 /*
   run a function from a function table. If not found then
@@ -186,7 +185,7 @@ static int binary_net(int argc, const char **argv)
                return net_usage(ctx, argc, argv);
        }
 
-       net_init_subsystems;
+       dcerpc_init();
 
        mem_ctx = talloc_init("net_context");
        ctx = talloc(mem_ctx, struct net_context);
index ffdbd2f2f6873fb7f7584244a82c36654511df25..d6b65d75d7d0d633cbc6b56026d2001b698c76be 100644 (file)
@@ -27,7 +27,6 @@
 #include "lib/cmdline/popt_common.h"
 #include "auth/auth.h"
 #include "pstring.h"
-#include "smb_build.h"
 
 #define SQUID_BUFFER_SIZE 2010
 
@@ -931,8 +930,7 @@ int main(int argc, const char **argv)
                return 1;
        }
 
-       ntlm_auth_init_subsystems;
-
+       gensec_init();
 
        if (opt_domain == NULL) {
                opt_domain = lp_workgroup();