From aa9f67163cd2df2a815ef585edad1951343b82c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 22:46:16 +0000 Subject: r12620: Get rid of automatically generated lists of init functions of subsystems. 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) --- source4/auth/gensec/gensec.c | 5 +++++ source4/build/smb_build/config_mk.pm | 2 -- source4/build/smb_build/smb_build_h.pm | 31 ------------------------------- source4/client/client.c | 4 ++-- source4/gtk/tools/gepdump.c | 3 +-- source4/gtk/tools/gregedit.c | 3 +-- source4/gtk/tools/gwcrontab.c | 6 ++---- source4/gtk/tools/gwsam.c | 6 +----- source4/lib/com/config.mk | 1 - source4/lib/com/main.c | 11 +++++++++-- source4/lib/ldb/tools/cmdline.c | 4 ++-- source4/lib/registry/reg_backend_rpc.c | 1 + source4/lib/registry/tools/regdiff.c | 3 --- source4/lib/registry/tools/regpatch.c | 3 --- source4/lib/registry/tools/regshell.c | 3 --- source4/lib/registry/tools/regtree.c | 3 --- source4/librpc/config.mk | 9 ++------- source4/librpc/rpc/dcerpc.c | 7 +++++++ source4/librpc/tables.pl | 5 +++++ source4/rpc_server/remote/dcesrv_remote.c | 3 +++ source4/scripting/ejs/smbcalls_rpc.c | 2 ++ source4/scripting/ejs/smbscript.c | 4 ++-- source4/smbd/server.c | 3 ++- source4/torture/com/simple.c | 2 ++ source4/torture/gentest.c | 4 ++-- source4/torture/locktest.c | 4 ++-- source4/torture/masktest.c | 4 ++-- source4/torture/torture.c | 3 +-- source4/utils/ndrdump.c | 1 - source4/utils/net/net.c | 3 +-- source4/utils/ntlm_auth.c | 4 +--- 31 files changed, 58 insertions(+), 89 deletions(-) (limited to 'source4') diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c index aaac3ef78c..5ff925c078 100644 --- a/source4/auth/gensec/gensec.c +++ b/source4/auth/gensec/gensec.c @@ -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); diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm index 405298eef2..b7c4ff572a 100644 --- a/source4/build/smb_build/config_mk.pm +++ b/source4/build/smb_build/config_mk.pm @@ -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", diff --git a/source4/build/smb_build/smb_build_h.pm b/source4/build/smb_build/smb_build_h.pm index 2bb9f35c53..52fe0da6da 100644 --- a/source4/build/smb_build/smb_build_h.pm +++ b/source4/build/smb_build/smb_build_h.pm @@ -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"); diff --git a/source4/client/client.c b/source4/client/client.c index fef847e8b2..fb07042496 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -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)); diff --git a/source4/gtk/tools/gepdump.c b/source4/gtk/tools/gepdump.c index ea77b19385..eab3987a9a 100644 --- a/source4/gtk/tools/gepdump.c +++ b/source4/gtk/tools/gepdump.c @@ -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); diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c index 8c243873ca..5dd5ec1a92 100644 --- a/source4/gtk/tools/gregedit.c +++ b/source4/gtk/tools/gregedit.c @@ -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); diff --git a/source4/gtk/tools/gwcrontab.c b/source4/gtk/tools/gwcrontab.c index f294e84392..9ebc7f43fd 100644 --- a/source4/gtk/tools/gwcrontab.c +++ b/source4/gtk/tools/gwcrontab.c @@ -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); diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c index 963397810c..3764afe046 100644 --- a/source4/gtk/tools/gwsam.c +++ b/source4/gtk/tools/gwsam.c @@ -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); diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk index 9e66502046..12f0481b0f 100644 --- a/source4/lib/com/config.mk +++ b/source4/lib/com/config.mk @@ -1,5 +1,4 @@ [SUBSYSTEM::COM] -INIT_FUNCTION = com_init OBJ_FILES = \ tables.o \ rot.o \ diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c index 123ba49b09..f2e4f6473a 100644 --- a/source4/lib/com/main.c +++ b/source4/lib/com/main.c @@ -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); diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index a14434622f..c134c3befd 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -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; diff --git a/source4/lib/registry/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc.c index e799b3a8e4..32ecbec6c6 100644 --- a/source4/lib/registry/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc.c @@ -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(®_backend_rpc); } diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 68cc56f9dd..5b876ca025 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -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); diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index b8b8805486..6f5c79bc0e 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -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); diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index c858b37f4a..89493c761e 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -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); diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 9a9121379b..d8f5d68a94 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -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); diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 06254a6748..03367bdf17 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -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 \ diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index df71be7651..0269eb9919 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -29,6 +29,13 @@ #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 */ diff --git a/source4/librpc/tables.pl b/source4/librpc/tables.pl index 5757dc000a..7ef1dbd14a 100644 --- a/source4/librpc/tables.pl +++ b/source4/librpc/tables.pl @@ -82,6 +82,11 @@ print TABLEC <