[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Fri Oct 28 06:43:03 MDT 2011
The branch, master has been updated
via 1e2f15f lib/util Add ABI to the samba-module library
via 7f8f715 lib/util Rename samba_modules_load -> samba_module_init_fns_for_subsystem
via b256799 lib/util Rename samba_init_module -> samba_module_init
via 0ce09fc lib/util Rename samba_init_module_fns_run -> samba_module_init_fns_run
via 1b7cc4a lib/util Rename samba_init_module_fn -> samba_module_init_fn
via 87354c9 lib/util Split samba-modules library into public and private parts
via b7b798e lib/util Rename load_samba_modules -> samba_modules_load
via ce0ccc2 lib/util Rename run_init_functions -> samba_init_module_fns_run
via 1935b7b lib/util Rename init_module_fn to samba_init_module_fn
via 7cf00e3 gensec: Add parinoia about integer wrapping
via 1bc787d s3-selftest Add all the LOCAL-* smbtorture tests to make test
via 289b03d s3-build: Remove libbigballofmud.so
via f28fda7 s3-torture Remove t_stringoverflow as fstrcpy now uses strlcpy
via 9fe8c3d s3-selftest: Add LOCAL-sprintf_append
via f31fd31 s3-torture run t_strappend tests as LOCAL-sprintf_append
via 4cc0552 s3-torture Run t_strappend test for less time
via de148f7 s3-torture Fix t_strappend test
via 659ec79 selftest: Have only one set of selftest knownfail and skip files
via 8dcfe2e selftest: Remove --target option and the ability to run 'samba4 only' tests
via f54dcc8 s3-torture remove unused t_push_ucs2.c t_strcmp.c t_strstr.c
via 961952e s3-torture remove unused t_asn1.c
via 3167b95 examples: rework wscript to use a loop
from 2330e52 s3-passdb: use tevent_context in passdb.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 1e2f15f773ec97716af7e63562fe142fd619444a
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 25 11:39:47 2011 +1100
lib/util Add ABI to the samba-module library
Autobuild-User: Andrew Bartlett <abartlet at samba.org>
Autobuild-Date: Fri Oct 28 14:42:43 CEST 2011 on sn-devel-104
commit 7f8f7159afbd9cfce4181eeb31a5c575c14d5f81
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 25 10:34:13 2011 +1100
lib/util Rename samba_modules_load -> samba_module_init_fns_for_subsystem
This is to provide a cleaner namespace in the public samba plugin
functions.
Andrew Bartlett
commit b256799eaf829fcb7d6e1d88de4478f77df8ff73
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 25 10:30:14 2011 +1100
lib/util Rename samba_init_module -> samba_module_init
This is to provide a cleaner namespace in the public samba plugin
functions.
Andrew Bartlett
commit 0ce09fcf7ae971a2dc4131fd137c925f0b9a57a4
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 25 10:11:06 2011 +1100
lib/util Rename samba_init_module_fns_run -> samba_module_init_fns_run
This is to provide a cleaner namespace in the public samba plugin
functions.
Andrew Bartlett
commit 1b7cc4ac7c793d4c1829d842c84273ef2d081fdb
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 25 07:43:06 2011 +1100
lib/util Rename samba_init_module_fn -> samba_module_init_fn
This is to provide a cleaner namespace in the public samba plugin
functions.
Andrew Bartlett
commit 87354c9a6de95d5dcebace77a35fc21a73d599ab
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Oct 24 19:39:53 2011 +1100
lib/util Split samba-modules library into public and private parts
This will allow OpenChange to get at the symbols it needs, without
exposing any more of this as a public API than we must.
Andrew Bartlett
commit b7b798e15b7be2d57e20c14cca2f908b301ed894
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Oct 24 19:07:12 2011 +1100
lib/util Rename load_samba_modules -> samba_modules_load
This is to provide a cleaner namespace in the public samba plugin
functions.
Andrew Bartlett
commit ce0ccc2a2ea820cd5d30ffd082d898fcb57431e6
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Oct 24 19:01:16 2011 +1100
lib/util Rename run_init_functions -> samba_init_module_fns_run
This is to provide a cleaner namespace in the public samba plugin
functions.
Andrew Bartlett
commit 1935b7b6c223542c1807e275c44e6ba4b2e90b68
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Oct 24 09:49:26 2011 +1100
lib/util Rename init_module_fn to samba_init_module_fn
This prepares for making the samba_module.h header public again, for OpenChange.
I am keen to avoid too much API namespace pollution if we can.
commit 7cf00e3231da1808a5ad1adf8fbc319846eacabe
Author: Andrew Bartlett <abartlet at samba.org>
Date: Sat Oct 22 11:48:30 2011 +1100
gensec: Add parinoia about integer wrapping
commit 1bc787d27102df0442122139aa290c17909d2dc1
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:59:47 2011 +1100
s3-selftest Add all the LOCAL-* smbtorture tests to make test
The extra knownfail and skip entries are for tests the currently do
not pass or hang. We need to work out why this happens, and fix the
test or the test invocation.
Andrew Bartlett
commit 289b03de5d585263f5356a97119fe5be802744ee
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:32:55 2011 +1100
s3-build: Remove libbigballofmud.so
We no longer need this, as all the small test binaries have either
been converted rolled into python bindings and python-subunit tests, or have
been moved into smbtorture.
--------------
/ \
/ REST \
/ IN \
/ PEACE \
/ \
| libbigballofmud.so |
| |
| |
| 26 October |
| |
| 2011 |
*| * * * | *
_________)/\\_//(\/(/\)/\//\/\///|_)_______
Andrew Bartlett
commit f28fda763869f75646f904d90f13ea40caf8c925
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:30:45 2011 +1100
s3-torture Remove t_stringoverflow as fstrcpy now uses strlcpy
Because we no longer use safe_strcpy() internally, we no longer have a
mode where we write to the end of the buffer in developer mode, and so
there isn't anything for this test to test.
Andrew Bartlett
commit 9fe8c3db910a8545c1719bcfc596a150efc4b663
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:25:59 2011 +1100
s3-selftest: Add LOCAL-sprintf_append
commit f31fd31b71eda4957475fb09de1ef26e3a050414
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:21:04 2011 +1100
s3-torture run t_strappend tests as LOCAL-sprintf_append
commit 4cc0552f6ef4f7985c48d23cc3854b214103bb97
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:13:36 2011 +1100
s3-torture Run t_strappend test for less time
commit de148f748a41d3a5e47167f387fafc4956680562
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 17:13:16 2011 +1100
s3-torture Fix t_strappend test
commit 659ec79245a9d9e5d45c380e8b82ec6236999032
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 13:38:15 2011 +1100
selftest: Have only one set of selftest knownfail and skip files
Listing tests that are not ever proposed (eg samba4.* in the samba3 selftest)
is not an error, so just combine the lists.
This is being done because some folks trying to learn how our 'make
test' works are having trouble following the distributed nature of the
selftest system.
Andrew Bartlett
commit 8dcfe2e5c44184298b0aa5bb1a13e2108b31a9c4
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 15:21:11 2011 +1100
selftest: Remove --target option and the ability to run 'samba4 only' tests
This simplifies the selftest system, and by default we always tested
all of samba3 and samba4 in the waf build. This simply removes a
rarely used option for testing only part of the system. The make test
TESTS="^samba3" syntax remains unchanged, so no functionality is lost.
Andrew Bartlett
commit f54dcc86b8c04bfd3c85ad327d268f5e32dd2cfd
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 09:28:08 2011 +1100
s3-torture remove unused t_push_ucs2.c t_strcmp.c t_strstr.c
These tests were incorportated into
source4/scripting/python/samba/tests/strings.py with
fa3e2fc8bb3e935c65b7043382cad1d649cb68a6.
Andrew Bartlett
commit 961952ee643ab82738840a29cec87c925e91d8c9
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Oct 26 09:22:40 2011 +1100
s3-torture remove unused t_asn1.c
This test was incorportated into lib/util/test/asn1_test.c with
ede98c0e5190bf59461703629d5a4742ad8e044f
Andrew Bartlett
commit 3167b95cad5b7963d6ee9e96f29c83f47362322b
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Oct 25 12:52:00 2011 +1100
examples: rework wscript to use a loop
I think this format is more compact and easier to understand.
Andrew Bartlett
-----------------------------------------------------------------------
Summary of changes:
auth/gensec/gensec_start.c | 14 +-
auth/gensec/wscript_build | 2 +-
auth/ntlmssp/ntlmssp_sign.c | 7 +
buildtools/wafsamba/wafsamba.py | 2 +-
examples/libsmbclient/wscript_build | 107 +++-----------
lib/util/ABI/samba-module-0.0.1.sigs | 2 +
lib/util/internal_module.c | 203 +++++++++++++++++++++++++
lib/util/internal_module.h | 42 +++++
lib/util/modules.c | 240 ------------------------------
lib/util/samba-module.pc.in | 11 ++
lib/util/samba_module.c | 62 ++++++++
lib/util/samba_module.h | 49 ++++++
lib/util/samba_modules.h | 59 --------
lib/util/wscript_build | 16 ++-
selftest/knownfail | 111 ++++++++++++++
selftest/quick | 37 +++++
selftest/selftest.pl | 12 +-
selftest/skip | 104 +++++++++++++
{source4/selftest => selftest}/slow | 0
selftest/wscript | 47 +-----
source3/Makefile.in | 51 +------
source3/exports/modules-darwin.syms | 2 +-
source3/include/includes.h | 2 +-
source3/m4/aclocal.m4 | 2 +-
source3/modules/perfcount_test.c | 2 +-
source3/selftest/knownfail | 16 --
source3/selftest/quick | 1 -
source3/selftest/s3-selftest.sh | 6 +-
source3/selftest/skip | 22 ---
source3/selftest/slow | 1 -
source3/selftest/tests.py | 23 +++-
source3/torture/proto.h | 1 +
source3/torture/t_asn1.c | 65 --------
source3/torture/t_push_ucs2.c | 55 -------
source3/torture/t_strappend.c | 22 ++-
source3/torture/t_strcmp.c | 32 ----
source3/torture/t_stringoverflow.c | 23 ---
source3/torture/t_strstr.c | 38 -----
source3/torture/torture.c | 1 +
source3/winbindd/idmap_ad.c | 2 +-
source3/winbindd/idmap_adex/idmap_adex.c | 2 +-
source3/winbindd/idmap_autorid.c | 2 +-
source3/winbindd/idmap_hash/idmap_hash.c | 2 +-
source3/winbindd/idmap_rid.c | 2 +-
source3/winbindd/idmap_tdb2.c | 2 +-
source3/wscript | 2 +-
source3/wscript_build | 5 +-
source4/auth/ntlm/auth.c | 6 +-
source4/auth/ntlm/wscript_build | 2 +-
source4/ntptr/ntptr_base.c | 10 +-
source4/ntvfs/ntvfs_base.c | 12 +-
source4/ntvfs/posix/pvfs_acl.c | 12 +-
source4/ntvfs/posix/wscript_build | 2 +-
source4/ntvfs/sysdep/sys_lease.c | 6 +-
source4/ntvfs/sysdep/sys_notify.c | 6 +-
source4/ntvfs/wscript_build | 2 +-
source4/param/share.c | 6 +-
source4/param/wscript_build | 2 +-
source4/rpc_server/dcerpc_server.c | 12 +-
source4/selftest/knownfail | 93 ------------
source4/selftest/quick | 37 -----
source4/selftest/skip | 81 ----------
source4/smbd/process_model.c | 12 +-
source4/smbd/server.c | 12 +-
source4/smbd/wscript_build | 2 +-
source4/torture/smbtorture.c | 4 +-
source4/torture/torture.c | 10 +-
67 files changed, 798 insertions(+), 1042 deletions(-)
create mode 100644 lib/util/ABI/samba-module-0.0.1.sigs
create mode 100644 lib/util/internal_module.c
create mode 100644 lib/util/internal_module.h
delete mode 100644 lib/util/modules.c
create mode 100644 lib/util/samba-module.pc.in
create mode 100644 lib/util/samba_module.c
create mode 100644 lib/util/samba_module.h
delete mode 100644 lib/util/samba_modules.h
create mode 100644 selftest/knownfail
create mode 100644 selftest/quick
create mode 100644 selftest/skip
rename {source4/selftest => selftest}/slow (100%)
delete mode 100644 source3/selftest/knownfail
delete mode 100644 source3/selftest/quick
delete mode 100644 source3/selftest/skip
delete mode 100644 source3/selftest/slow
delete mode 100644 source3/torture/t_asn1.c
delete mode 100644 source3/torture/t_push_ucs2.c
delete mode 100644 source3/torture/t_strcmp.c
delete mode 100644 source3/torture/t_stringoverflow.c
delete mode 100644 source3/torture/t_strstr.c
delete mode 100644 source4/selftest/knownfail
delete mode 100644 source4/selftest/quick
delete mode 100644 source4/selftest/skip
Changeset truncated at 500 lines:
diff --git a/auth/gensec/gensec_start.c b/auth/gensec/gensec_start.c
index c38b970..a48606f 100644
--- a/auth/gensec/gensec_start.c
+++ b/auth/gensec/gensec_start.c
@@ -29,7 +29,7 @@
#include "auth/gensec/gensec.h"
#include "lib/param/param.h"
#include "lib/util/tsort.h"
-#include "lib/util/samba_modules.h"
+#include "lib/util/samba_module.h"
/* the list of currently registered GENSEC backends */
static struct gensec_security_ops **generic_security_ops;
@@ -878,19 +878,19 @@ _PUBLIC_ NTSTATUS gensec_init(void)
#define _MODULE_PROTO(init) extern NTSTATUS init(void);
#ifdef STATIC_gensec_MODULES
STATIC_gensec_MODULES_PROTO;
- init_module_fn static_init[] = { STATIC_gensec_MODULES };
+ samba_module_init_fn static_init[] = { STATIC_gensec_MODULES };
#else
- init_module_fn *static_init = NULL;
+ samba_module_init_fn *static_init = NULL;
#endif
- init_module_fn *shared_init;
+ samba_module_init_fn *shared_init;
if (initialized) return NT_STATUS_OK;
initialized = true;
- shared_init = load_samba_modules(NULL, "gensec");
+ shared_init = samba_module_init_fns_for_subsystem(NULL, "gensec");
- run_init_functions(static_init);
- run_init_functions(shared_init);
+ samba_module_init_fns_run(static_init);
+ samba_module_init_fns_run(shared_init);
talloc_free(shared_init);
diff --git a/auth/gensec/wscript_build b/auth/gensec/wscript_build
index e3e9372..6514a06 100644
--- a/auth/gensec/wscript_build
+++ b/auth/gensec/wscript_build
@@ -3,7 +3,7 @@ bld.SAMBA_LIBRARY('gensec',
source='gensec.c gensec_start.c',
pc_files='gensec.pc',
autoproto='gensec_toplevel_proto.h',
- public_deps='tevent-util samba-util errors LIBPACKET auth_system_session samba-modules gensec_util',
+ public_deps='tevent-util samba-util errors LIBPACKET auth_system_session samba-module gensec_util',
public_headers='gensec.h',
deps='com_err',
vnum='0.0.1'
diff --git a/auth/ntlmssp/ntlmssp_sign.c b/auth/ntlmssp/ntlmssp_sign.c
index a5c57d8..4d07a81 100644
--- a/auth/ntlmssp/ntlmssp_sign.c
+++ b/auth/ntlmssp/ntlmssp_sign.c
@@ -402,6 +402,10 @@ NTSTATUS ntlmssp_wrap(struct ntlmssp_state *ntlmssp_state,
DATA_BLOB sig;
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) {
+ if (in->length + NTLMSSP_SIG_SIZE < in->length) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
*out = data_blob_talloc(out_mem_ctx, NULL, in->length + NTLMSSP_SIG_SIZE);
if (!out->data) {
return NT_STATUS_NO_MEMORY;
@@ -422,6 +426,9 @@ NTSTATUS ntlmssp_wrap(struct ntlmssp_state *ntlmssp_state,
return nt_status;
} else if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) {
+ if (in->length + NTLMSSP_SIG_SIZE < in->length) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
*out = data_blob_talloc(out_mem_ctx, NULL, in->length + NTLMSSP_SIG_SIZE);
if (!out->data) {
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 338bc3d..876cec5 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -391,7 +391,7 @@ def SAMBA_MODULE(bld, modname, source,
includes='',
subsystem=None,
init_function=None,
- module_init_name='samba_init_module',
+ module_init_name='samba_module_init',
autoproto=None,
autoproto_extra_source='',
cflags='',
diff --git a/examples/libsmbclient/wscript_build b/examples/libsmbclient/wscript_build
index f9ab3dc..84e03f3 100644
--- a/examples/libsmbclient/wscript_build
+++ b/examples/libsmbclient/wscript_build
@@ -1,86 +1,25 @@
#!/usr/bin/env python
-bld.SAMBA_BINARY('testsmbc',
- source='testsmbc.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testacl',
- source='testacl.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testacl2',
- source='testacl2.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testacl3',
- source='testacl3.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testbrowse',
- source='testbrowse.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testbrowse2',
- source='testbrowse2.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('teststat',
- source='teststat.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('teststat2',
- source='teststat2.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('teststat3',
- source='teststat3.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('teststatvfs',
- source='teststatvfs.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testfstatvfs',
- source='testfstatvfs.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testtruncate',
- source='testtruncate.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testchmod',
- source='testchmod.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testutime',
- source='testutime.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testread',
- source='testread.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testwrite',
- source='testwrite.c',
- deps='smbclient',
- install=False)
-
-bld.SAMBA_BINARY('testctx',
- source='testctx.c',
- deps='smbclient',
- install=False)
+names = ['testsmbc',
+ 'testacl',
+ 'testacl2',
+ 'testacl3',
+ 'testbrowse',
+ 'testbrowse2',
+ 'teststat',
+ 'teststat2',
+ 'teststat3',
+ 'teststatvfs',
+ 'testfstatvfs',
+ 'testtruncate',
+ 'testchmod',
+ 'testutime',
+ 'testread',
+ 'testwrite',
+ 'testctx']
+
+for name in names:
+ bld.SAMBA_BINARY(name,
+ source='%s.c' % name,
+ deps='smbclient',
+ install=False)
diff --git a/lib/util/ABI/samba-module-0.0.1.sigs b/lib/util/ABI/samba-module-0.0.1.sigs
new file mode 100644
index 0000000..ee728d4
--- /dev/null
+++ b/lib/util/ABI/samba-module-0.0.1.sigs
@@ -0,0 +1,2 @@
+samba_module_init_fns_for_subsystem: samba_module_init_fn *(TALLOC_CTX *, const char *)
+samba_module_init_fns_run: bool (samba_module_init_fn *)
diff --git a/lib/util/internal_module.c b/lib/util/internal_module.c
new file mode 100644
index 0000000..a10d1f3
--- /dev/null
+++ b/lib/util/internal_module.c
@@ -0,0 +1,203 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij 2002-2003,2005-2007
+ Copyright (C) Stefan (metze) Metzmacher 2003
+ Copyright (C) Andrew Bartlett 2011
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "dynconfig/dynconfig.h"
+#include "lib/util/internal_module.h"
+#include "system/filesys.h"
+#include "system/dir.h"
+
+/**
+ * Obtain the init function from a shared library file
+ */
+samba_module_init_fn load_module(const char *path, bool is_probe, void **handle_out)
+{
+ void *handle;
+ void *init_fn;
+ char *error;
+
+#if _SAMBA_BUILD_ == 3
+ /* Always try to use LAZY symbol resolving; if the plugin has
+ * backwards compatibility, there might be symbols in the
+ * plugin referencing to old (removed) functions
+ */
+ handle = dlopen(path, RTLD_LAZY);
+#else
+ /* This should be a WAF build, where modules should be built
+ * with no undefined symbols and are already linked against
+ * the libraries that they are loaded by */
+ handle = dlopen(path, RTLD_NOW);
+#endif
+
+ /* This call should reset any possible non-fatal errors that
+ occured since last call to dl* functions */
+ error = dlerror();
+
+ if (handle == NULL) {
+ int level = is_probe ? 5 : 0;
+ DEBUG(level, ("Error loading module '%s': %s\n", path, error ? error : ""));
+ return NULL;
+ }
+
+ init_fn = (samba_module_init_fn)dlsym(handle, SAMBA_MODULE_INIT);
+
+ /* we could check dlerror() to determine if it worked, because
+ dlsym() can validly return NULL, but what would we do with
+ a NULL pointer as a module init function? */
+
+ if (init_fn == NULL) {
+ DEBUG(0, ("Unable to find %s() in %s: %s\n",
+ SAMBA_MODULE_INIT, path, dlerror()));
+ DEBUG(1, ("Loading module '%s' failed\n", path));
+ dlclose(handle);
+ return NULL;
+ }
+
+ if (handle_out) {
+ *handle_out = handle;
+ }
+
+ return (samba_module_init_fn)init_fn;
+}
+
+/**
+ * Obtain list of init functions from the modules in the specified
+ * directory
+ */
+samba_module_init_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
+{
+ DIR *dir;
+ struct dirent *entry;
+ char *filename;
+ int success = 0;
+ samba_module_init_fn *ret = talloc_array(mem_ctx, samba_module_init_fn, 2);
+
+ ret[0] = NULL;
+
+ dir = opendir(path);
+ if (dir == NULL) {
+ talloc_free(ret);
+ return NULL;
+ }
+
+ while((entry = readdir(dir))) {
+ if (ISDOT(entry->d_name) || ISDOTDOT(entry->d_name))
+ continue;
+
+ filename = talloc_asprintf(mem_ctx, "%s/%s", path, entry->d_name);
+
+ ret[success] = load_module(filename, true, NULL);
+ if (ret[success]) {
+ ret = talloc_realloc(mem_ctx, ret, samba_module_init_fn, success+2);
+ success++;
+ ret[success] = NULL;
+ }
+
+ talloc_free(filename);
+ }
+
+ closedir(dir);
+
+ return ret;
+}
+
+/* Load a dynamic module. Only log a level 0 error if we are not checking
+ for the existence of a module (probling). */
+
+static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
+{
+ void *handle;
+ samba_module_init_fn init;
+ NTSTATUS status;
+
+ init = load_module(module_name, is_probe, &handle);
+ if (!init) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ DEBUG(2, ("Module '%s' loaded\n", module_name));
+
+ status = init();
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Module '%s' initialization failed: %s\n",
+ module_name, get_friendly_nt_error_msg(status)));
+ dlclose(handle);
+ }
+
+ return status;
+}
+
+/* Load all modules in list and return number of
+ * modules that has been successfully loaded */
+int smb_load_modules(const char **modules)
+{
+ int i;
+ int success = 0;
+
+ for(i = 0; modules[i]; i++){
+ if(NT_STATUS_IS_OK(do_smb_load_module(modules[i], false))) {
+ success++;
+ }
+ }
+
+ DEBUG(2, ("%d modules successfully loaded\n", success));
+
+ return success;
+}
+
+NTSTATUS smb_probe_module(const char *subsystem, const char *module)
+{
+ char *full_path = NULL;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ NTSTATUS status;
+
+ /* Check for absolute path */
+
+ /* if we make any 'samba multibyte string'
+ calls here, we break
+ for loading string modules */
+
+ DEBUG(5, ("Probing module '%s'\n", module));
+
+ if (module[0] == '/') {
+ status = do_smb_load_module(module, true);
+ TALLOC_FREE(ctx);
+ return status;
+ }
+
+ full_path = talloc_asprintf(ctx,
+ "%s/%s.%s",
+ modules_path(ctx, subsystem),
+ module,
+ shlib_ext());
+ if (!full_path) {
+ TALLOC_FREE(ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ DEBUG(5, ("Probing module '%s': Trying to load from %s\n",
+ module, full_path));
+
+ status = do_smb_load_module(full_path, true);
+
+ TALLOC_FREE(ctx);
+ return status;
+}
diff --git a/lib/util/internal_module.h b/lib/util/internal_module.h
new file mode 100644
index 0000000..9cbddea
--- /dev/null
+++ b/lib/util/internal_module.h
@@ -0,0 +1,42 @@
+/*
+ Unix SMB/CIFS implementation.
+ Handling of idle/exit events
+ Copyright (C) Stefan (metze) Metzmacher 2003
+ Copyright (C) Andrew Bartlett 2011
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _INTERNAL_MODULES_H
+#define _INTERNAL_MODULES_H
+
+#include "lib/util/samba_module.h"
+
+/**
+ * Obtain the init function from a shared library file.
+ *
+ * The handle to dlclose() in case of error is returns in *handle if handle is not NULL
+ */
+samba_module_init_fn load_module(const char *path, bool is_probe, void **handle);
+
+int smb_load_modules(const char **modules);
+NTSTATUS smb_probe_module(const char *subsystem, const char *module);
+
+/**
+ * Obtain list of init functions from the modules in the specified
+ * directory
+ */
+samba_module_init_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path);
+
+#endif /* _INTERNAL_MODULES_H */
diff --git a/lib/util/modules.c b/lib/util/modules.c
deleted file mode 100644
index 52a04be..0000000
--- a/lib/util/modules.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Jelmer Vernooij 2002-2003,2005-2007
- Copyright (C) Stefan (metze) Metzmacher 2003
- Copyright (C) Andrew Bartlett 2011
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "dynconfig/dynconfig.h"
-#include "lib/util/samba_modules.h"
-#include "system/filesys.h"
--
Samba Shared Repository
More information about the samba-cvs
mailing list