here is a new patch for the modules stuff:
- it adds 'modules path' and 'modules' as per share parameter
(vfs path is now an alias for modules path)
- it add two new parameters to the smb_load_modules function
int smb_load_modules(const char **modules, int snum, SMB_MODULE_TYPES types)
int snum - is the number of the current service (share) GLOBAL_SECTION_SNUM (-1) for the global section.
SMB_MODULE_TYPES types - this is the bitmask witch module types should be loaded here, ( we don't need a winsdb module in smbd... also smb_register_winsdb() is not linked to smbd, witch would cause trouble)
now we can use smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPE_CHARSET) to load the charsets before the fork in smbd
smb_load_modules(lp_modules(SNUM(conn)),SNUM(conn),MODULE_TYPE_VFS) for loading the vfs modules per share..
lp_module_path is dyn_LIBDIR by default...
lib_path() for loading upcase.dat,... is replaced by data_path() witch is default dyn_DATADIR
for making jerry and jht happy I use :
DATADIR = @libdir@ in Makefile.in but it should be changed to
DATADIR = @datadir@
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <[EMAIL PROTECTED]>
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/Makefile.in HEAD-modules/source/Makefile.in --- HEAD/source/Makefile.in Mon Dec 2 15:46:11 2002 +++ HEAD-modules/source/Makefile.in Fri Dec 6 09:22:43 2002 @@ -52,6 +52,9 @@ PDBLIBDIR = $(LIBDIR)/pdb CONFIGDIR = @configdir@ VARDIR = @localstatedir@ MANDIR = @mandir@ +# This is where valid.dat,upcase.dat,lowcase.dat are installed and searched by default +# DATADIR = @datadir@ change this if jerry and jht agree +DATADIR = @libdir@ # The permissions to give the executables INSTALLPERMS = 0755 @@ -94,12 +97,11 @@ FLAGS32 = $(ISA32) $(FLAGS5) PASSWD_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" -DPRIVATE_DIR=\"$(PRIVATE_DIR)\" PATH_FLAGS1 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DSBINDIR=\"$(SBINDIR)\" -PATH_FLAGS2 = $(PATH_FLAGS1) -DBINDIR=\"$(BINDIR)\" -DDRIVERFILE=\"$(DRIVERFILE)\" -PATH_FLAGS3 = $(PATH_FLAGS2) -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" -PATH_FLAGS4 = $(PATH_FLAGS3) -DSWATDIR=\"$(SWATDIR)\" -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\"$(LIBDIR)\" -DLOGFILEBASE=\"$(LOGFILEBASE)\" -PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGFIR)\" -PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS) +PATH_FLAGS2 = $(PATH_FLAGS1) -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" +PATH_FLAGS3 = $(PATH_FLAGS2) -DSWATDIR=\"$(SWATDIR)\" -DLOCKDIR=\"$(LOCKDIR)\" +-DPIDDIR=\"$(PIDDIR)\" +PATH_FLAGS4 = $(PATH_FLAGS3) -DLIBDIR=\"$(LIBDIR)\" -DLOGFILEBASE=\"$(LOGFILEBASE)\" +PATH_FLAGS5 = $(PATH_FLAGS4) -DCONFIGDIR=\"$(CONFIGDIR)\" -DDATADIR=\"$(DATADIR)\" +PATH_FLAGS = $(PATH_FLAGS5) $(PASSWD_FLAGS) # Note that all executable programs now provide for an optional executable suffix. @@ -918,24 +920,26 @@ install: installbin installman installsc # is not used installdirs: - @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(VFSLIBDIR) $(DESTDIR)$(PDBLIBDIR) + @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) +$(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DATADIR) +$(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) $(DESTDIR)$(VFSLIBDIR) +$(DESTDIR)$(PDBLIBDIR) + @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) +$(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR) +$(DESTDIR)$(VFSLIBDIR) $(DESTDIR)$(PDBLIBDIR) installservers: all installdirs - @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS) + @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) +$(DESTDIR)$(SBINDIR) $(DESTDIR)$(DATADIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS) installbin: all installdirs - @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS) - @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS) + @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) +$(DESTDIR)$(SBINDIR) $(DESTDIR)$(DATADIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS) + @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) +$(DESTDIR)$(BINDIR) $(DESTDIR)$(DATADIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS) -installmodules: all installdirs +installmodules: modules installdirs @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(VFSLIBDIR) $(VFS_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(PDBLIBDIR) $(PDB_MODULES) + @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) +$(DESTDIR)$(BASEDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(MODULES) installscripts: installdirs @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS) installdat: installdirs - @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir) + @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir) installswat: installdirs @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) @@ -1016,6 +1020,7 @@ showlayout: @echo " libdir: $(LIBDIR)" @echo " vardir: $(VARDIR)" @echo " mandir: $(MANDIR)" + @echo " datadir: $(DATADIR)" uninstall: uninstallman uninstallbin uninstallscripts @@ -1024,8 +1029,8 @@ uninstallman: @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(srcdir) $(man_langs) uninstallbin: - @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS) - @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS) + @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) +$(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(DATADIR) $(DESTDIR)$(VARDIR) +$(DESTDIR)$(SBIN_PROGS) + @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) +$(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(DATADIR) $(DESTDIR)$(VARDIR) +$(DESTDIR)$(BIN_PROGS) uninstallmodules: @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(VFSLIBDIR) $(DESTDIR)$(VFS_MODULES) @@ -1121,7 +1126,7 @@ realclean: clean delheaders distclean: realclean -rm -f include/stamp-h - -rm -f include/config.h Makefile + -rm -f include/config.h Makefile modules/Makefile.ext_modules -rm -f config.status config.cache so_locations -rm -rf .deps diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/configure.in HEAD-modules/source/configure.in --- HEAD/source/configure.in Thu Dec 5 09:43:42 2002 +++ HEAD-modules/source/configure.in Fri Dec 6 09:22:43 2002 @@ -17,9 +17,10 @@ AC_ARG_WITH(fhs, logfilebase="\${VARDIR}/log/samba" privatedir="\${CONFIGDIR}/private" libdir="\${prefix}/lib/samba" - swatdir="\${DATADIR}/samba/swat", - configdir="\${LIBDIR}" - logfilebase="\${VARDIR}" + swatdir="${datadir}/samba/swat" + datadir="${datadir}/samba", + configdir="\$(LIBDIR)" + logfilebase="\$(VARDIR)" lockdir="\${VARDIR}/locks" piddir="\${VARDIR}/locks" privatedir="\${prefix}/private" @@ -129,6 +130,7 @@ AC_SUBST(privatedir) AC_SUBST(swatdir) AC_SUBST(bindir) AC_SUBST(sbindir) +AC_SUBST(datadir) dnl Unique-to-Samba variables we'll be playing with. AC_SUBST(SHELL) @@ -630,7 +632,7 @@ test "${with_readline+set}" != "set" && # test for where we get readline() from AC_MSG_CHECKING(whether to use readline) AC_ARG_WITH(readline, -[ --with-readline[=DIR] Look for readline include/libs in DIR (default=auto) ], +[ --with-readline[=DIR] Look for readline include/libs in DIR (default=auto) ], [ case "$with_readline" in yes) AC_MSG_RESULT(yes) @@ -1969,7 +1971,7 @@ with_ads_support=yes AC_MSG_CHECKING([whether to use Active Directory]) AC_ARG_WITH(ads, -[ --with-ads Active Directory support (default yes)], +[ --with-ads Active Directory support (default yes)], [ case "$withval" in no) with_ads_support=no @@ -2069,7 +2071,7 @@ with_ldap_support=yes AC_MSG_CHECKING([whether to use LDAP]) AC_ARG_WITH(ldap, -[ --with-ldap LDAP support (default yes)], +[ --with-ldap LDAP support (default yes)], [ case "$withval" in no) with_ldap_support=no @@ -2265,7 +2267,7 @@ AC_ARG_WITH(sam, # check for a LDAP password database configuration backwards compatibility AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration) AC_ARG_WITH(ldapsam, -[ --with-ldapsam Include LDAP SAM 2.2 compatible configuration (default=no)], +[ --with-ldapsam Include LDAP SAM 2.2 compatible configuration +(default=no)], [ case "$withval" in yes) AC_MSG_RESULT(yes) @@ -2782,7 +2784,7 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_ with_sendfile_support=yes AC_MSG_CHECKING(whether to check to support sendfile) AC_ARG_WITH(sendfile-support, -[ --with-sendfile-support Check for sendfile support (default=yes)], +[ --with-sendfile-support Check for sendfile support (default=yes)], [ case "$withval" in yes) diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/dynconfig.c HEAD-modules/source/dynconfig.c --- HEAD/source/dynconfig.c Tue Nov 5 16:25:26 2002 +++ HEAD-modules/source/dynconfig.c Fri Dec 6 09:22:43 2002 @@ -54,9 +54,9 @@ pstring dyn_LMHOSTSFILE = LMHOSTSFILE; /** * @brief Samba library directory. * - * @sa lib_path() to get the path to a file inside the LIBDIR. + * @sa data_path() to get the path to a file inside the DATADIR. **/ -pstring dyn_LIBDIR = LIBDIR; +pstring dyn_DATADIR = DATADIR; /** * @brief Directory holding lock files. @@ -68,3 +68,6 @@ const pstring dyn_PIDDIR = PIDDIR; const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE; const pstring dyn_PRIVATE_DIR = PRIVATE_DIR; + +/** default for lp_modules_path(int snum) **/ +const pstring dyn_LIBDIR = LIBDIR; diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/include/dynconfig.h HEAD-modules/source/include/dynconfig.h --- HEAD/source/include/dynconfig.h Tue Nov 5 16:25:26 2002 +++ HEAD-modules/source/include/dynconfig.h Fri Dec 6 09:22:43 2002 @@ -29,8 +29,9 @@ extern char const *dyn_SBINDIR, extern pstring dyn_CONFIGFILE; extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE; -extern pstring dyn_LIBDIR; +extern pstring dyn_DATADIR; extern const pstring dyn_LOCKDIR; extern const pstring dyn_PIDDIR; extern const pstring dyn_SMB_PASSWD_FILE; extern const pstring dyn_PRIVATE_DIR; +extern const pstring dyn_LIBDIR; \ No newline at end of file diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/include/includes.h HEAD-modules/source/include/includes.h --- HEAD/source/include/includes.h Wed Dec 4 07:18:40 2002 +++ HEAD-modules/source/include/includes.h Fri Dec 6 09:22:43 2002 @@ -730,6 +730,7 @@ extern int errno; #include "version.h" #include "smb.h" +#include "modules.h" #include "smbw.h" #include "nameserv.h" diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/include/modules.h HEAD-modules/source/include/modules.h --- HEAD/source/include/modules.h Thu Jan 1 01:00:00 1970 +++ HEAD-modules/source/include/modules.h Fri Dec 6 09:37:02 2002 @@ -0,0 +1,59 @@ +/* + * Unix SMB/CIFS implementation. + * module loading system + + * Cpoyright (C) Stefan (metze) Metzmacher 2002 + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _MODULES_H +#define _MODULES_H + +typedef SMB_BIG_UINT SMB_MODULE_TYPES; + +#define MODULE_TYPE_NONE 0x0000000000000000 +#define MODULE_TYPE_PDB 0x0000000000000001 +#define MODULE_TYPE_VFS 0x0000000000000002 +#define MODULE_TYPE_WINSDB 0x0000000000000004 +#define MODULE_TYPE_SAM 0x0000000000000008 +#define MODULE_TYPE_CHARSET 0x0000000000000010 + +#define MODULE_TYPES_ALL 0xFFFFFFFFFFFFFFFF + +#ifdef WITH_SAM +#define MODULE_TYPES_SMBD MODULE_TYPE_CHARSET | MODULE_TYPE_PDB | +MODULE_TYPE_VFS | MODULE_TYPE_SAM +#else +#define MODULE_TYPES_SMBD MODULE_TYPE_CHARSET | MODULE_TYPE_PDB | +MODULE_TYPE_VFS +#endif /* WITH_SAM */ + +#define MODULE_TYPES_PER_SHARE MODULE_TYPE_VFS + +#define MODULE_TYPES_NMBD MODULE_TYPE_CHARSET | MODULE_TYPE_WINSDB + +#define MODULE_TYPES_WINBINDD MODULE_TYPE_NONE + +#define MODULE_TYPES_WREPLD MODULE_TYPES_NMBD + +#define MODULE_TYPES_NET MODULE_TYPES_SMBD +#define MODULE_TYPES_SMBPASSWD MODULE_TYPES_SMBD +#define MODULE_TYPES_SMBGROUPEDIT MODULE_TYPES_SMBD +#define MODULE_TYPES_PDBEDIT MODULE_TYPES_SMBD +#define MODULE_TYPES_VFSTEST MODULE_TYPES_SMBD + +/* Module support */ +typedef NTSTATUS (init_module_function) (SMB_MODULE_TYPES); + +#endif /* _MODULES_H */ \ No newline at end of file diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/include/smb.h HEAD-modules/source/include/smb.h --- HEAD/source/include/smb.h Thu Dec 5 09:43:43 2002 +++ HEAD-modules/source/include/smb.h Fri Dec 6 09:22:43 2002 @@ -1707,7 +1707,4 @@ extern struct poptOption popt_common_ver extern struct poptOption popt_common_netbios_name[]; extern struct poptOption popt_common_log_base[]; -/* Module support */ -typedef NTSTATUS (init_module_function) (void); - #endif /* _SMB_H */ diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/include/smb_macros.h HEAD-modules/source/include/smb_macros.h --- HEAD/source/include/smb_macros.h Thu Dec 5 09:43:43 2002 +++ HEAD-modules/source/include/smb_macros.h Fri Dec 6 09:22:43 2002 @@ -95,8 +95,11 @@ #define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \ NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) ) +/* the service number for the [globals] defaults */ +#define GLOBAL_SECTION_SNUM (-1) /* translates a connection number into a service number */ -#define SNUM(conn) ((conn)?(conn)->service:-1) +#define SNUM(conn) ((conn)?(conn)->service:GLOBAL_SECTION_SNUM) + /* access various service details */ #define SERVICE(snum) (lp_servicename(snum)) diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/intl/lang_tdb.c HEAD-modules/source/intl/lang_tdb.c --- HEAD/source/intl/lang_tdb.c Sat Nov 23 17:52:43 2002 +++ HEAD-modules/source/intl/lang_tdb.c Fri Dec 6 09:22:43 2002 @@ -123,7 +123,7 @@ BOOL lang_tdb_init(const char *lang) /* if no lang then we don't translate */ if (!lang) return True; - asprintf(&msg_path, "%s.msg", lib_path((char *)lang)); + asprintf(&msg_path, "%s.msg", data_path((char *)lang)); if (stat(msg_path, &st) != 0) { /* the msg file isn't available */ free(msg_path); diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/lib/module.c HEAD-modules/source/lib/module.c --- HEAD/source/lib/module.c Wed Nov 13 19:52:32 2002 +++ HEAD-modules/source/lib/module.c Fri Dec 6 09:22:43 2002 @@ -22,46 +22,64 @@ #include "includes.h" #ifdef HAVE_DLOPEN -NTSTATUS smb_load_module(const char *module_name) +NTSTATUS smb_load_module(const char *module_name, int snum, SMB_MODULE_TYPES types) { void *handle; init_module_function *init; NTSTATUS nt_status; + pstring full_module_name; + + if (module_name[0]=='/') { + pstrcpy(full_module_name,module_name); + } else { + pstrcpy(full_module_name,lp_modules_path(snum)); + pstrcat(full_module_name,"/"); + pstrcat(full_module_name,module_name); + } /* 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 = sys_dlopen(module_name, RTLD_LAZY); + handle = sys_dlopen(full_module_name, RTLD_LAZY); if(!handle) { - DEBUG(0, ("Error loading module '%s': %s\n", module_name, sys_dlerror())); + DEBUG(0, ("Error loading module '%s': %s\n", full_module_name, +sys_dlerror())); return NT_STATUS_UNSUCCESSFUL; } init = sys_dlsym(handle, "init_module"); if(!init) { - DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n", module_name, sys_dlerror())); + DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n", +full_module_name, sys_dlerror())); return NT_STATUS_UNSUCCESSFUL; } - nt_status = init(); + nt_status = init(types); - DEBUG(2, ("Module '%s' loaded\n", module_name)); + DEBUG(2, ("Module '%s' loaded\n", full_module_name)); return nt_status; } /* Load all modules in list and return number of * modules that has been successfully loaded */ -int smb_load_modules(const char **modules) +int smb_load_modules(const char **modules, int snum, SMB_MODULE_TYPES types) { int i; int success = 0; + if (snum>GLOBAL_SECTION_SNUM && + lp_modules(GLOBAL_SECTION_SNUM)==modules) { + /* don't load modules of the global section + * when snum != GLOBAL_SECTION_SNUM !!! + */ + DEBUG(5,("smb_load_modules: don't reload global modules on connection +start\n")); + return success; + } + for(i = 0; modules[i]; i++){ - if(NT_STATUS_IS_OK(smb_load_module(modules[i]))) { + if(NT_STATUS_IS_OK(smb_load_module(modules[i],snum,types))) { success++; } } @@ -73,13 +91,13 @@ int smb_load_modules(const char **module #else /* HAVE_DLOPEN */ -NTSTATUS smb_load_module(const char *module_name) +NTSTATUS smb_load_module(const char *module_name, int snum, SMB_MODULE_TYPES types) { DEBUG(0,("This samba executable has not been build with plugin support")); return NT_STATUS_NOT_SUPPORTED; } -int smb_load_modules(const char **modules) +int smb_load_modules(const char **modules, int snum, SMB_MODULE_TYPES types) { DEBUG(0,("This samba executable has not been build with plugin support")); return -1; diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/lib/util.c HEAD-modules/source/lib/util.c --- HEAD/source/lib/util.c Wed Dec 4 07:18:40 2002 +++ HEAD-modules/source/lib/util.c Fri Dec 6 09:22:43 2002 @@ -2156,15 +2156,15 @@ char *pid_path(const char *name) /** * @brief Returns an absolute path to a file in the Samba lib directory. * - * @param name File to find, relative to LIBDIR. + * @param name File to find, relative to DATADIR. * * @retval Pointer to a static #pstring containing the full path. **/ -char *lib_path(const char *name) +char *data_path(const char *name) { static pstring fname; - snprintf(fname, sizeof(fname), "%s/%s", dyn_LIBDIR, name); + snprintf(fname, sizeof(fname), "%s/%s", dyn_DATADIR, name); return fname; } diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/lib/util_unistr.c HEAD-modules/source/lib/util_unistr.c --- HEAD/source/lib/util_unistr.c Sun Nov 10 00:34:38 2002 +++ HEAD-modules/source/lib/util_unistr.c Fri Dec 6 09:22:43 2002 @@ -43,8 +43,8 @@ void load_case_tables(void) if (initialised) return; initialised = 1; - upcase_table = map_file(lib_path("upcase.dat"), 0x20000); - lowcase_table = map_file(lib_path("lowcase.dat"), 0x20000); + upcase_table = map_file(data_path("upcase.dat"), 0x20000); + lowcase_table = map_file(data_path("lowcase.dat"), 0x20000); /* we would like Samba to limp along even if these tables are not available */ @@ -108,7 +108,7 @@ void init_valid_table(void) if (initialised && mapped_file) return; initialised = 1; - valid_table = map_file(lib_path("valid.dat"), 0x10000); + valid_table = map_file(data_path("valid.dat"), 0x10000); if (valid_table) { mapped_file = 1; return; diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/modules/developer.c HEAD-modules/source/modules/developer.c --- HEAD/source/modules/developer.c Wed Nov 13 20:07:34 2002 +++ HEAD-modules/source/modules/developer.c Fri Dec 6 10:15:44 2002 @@ -125,8 +125,10 @@ static size_t weird_push(void *cd, char struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push}; -int init_module(void) +NTSTATUS init_module(SMB_MODULE_TYPES types) { - smb_register_charset(&weird_functions); - return 0; + if (types & MODULE_TYPE_CHARSET) + smb_register_charset(&weird_functions); + + return NT_STATUS_OK; } diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/modules/mysql.c HEAD-modules/source/modules/mysql.c --- HEAD/source/modules/mysql.c Fri Nov 15 18:01:23 2002 +++ HEAD-modules/source/modules/mysql.c Fri Dec 6 10:11:04 2002 @@ -1032,12 +1032,15 @@ static NTSTATUS mysqlsam_init(struct pdb return NT_STATUS_OK; } -int init_module(void); - -int init_module() +NTSTATUS init_module(SMB_MODULE_TYPES types) { - if(smb_register_passdb("mysql", mysqlsam_init, PASSDB_INTERFACE_VERSION)) - return 0; - - return 1; -} + if (types & MODULE_TYPE_PDB) { + if (smb_register_passdb("mysql", mysqlsam_init, +PASSDB_INTERFACE_VERSION)) { + return NT_STATUS_OK; + } else { + return NT_STATUS_UNSUCCESSFUL; + } + } + + return NT_STATUS_OK; +} \ No newline at end of file diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/modules/xml.c HEAD-modules/source/modules/xml.c --- HEAD/source/modules/xml.c Fri Nov 15 18:01:23 2002 +++ HEAD-modules/source/modules/xml.c Fri Dec 6 10:14:20 2002 @@ -564,12 +564,15 @@ NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_c return NT_STATUS_OK; } -int init_module(void); - -int init_module() +NTSTATUS init_module(SMB_MODULE_TYPES types) { - if(smb_register_passdb("xml", xmlsam_init, PASSDB_INTERFACE_VERSION)) - return 0; - - return 1; + if (types & MODULE_TYPE_PDB) { + if (smb_register_passdb("xml", xmlsam_init, PASSDB_INTERFACE_VERSION)) +{ + return NT_STATUS_OK; + } else { + return NT_STATUS_UNSUCCESSFUL; + } + } + + return NT_STATUS_OK; } diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/nmbd/nmbd.c HEAD-modules/source/nmbd/nmbd.c --- HEAD/source/nmbd/nmbd.c Wed Nov 13 19:52:36 2002 +++ HEAD-modules/source/nmbd/nmbd.c Fri Dec 6 09:22:43 2002 @@ -631,6 +631,9 @@ static BOOL open_sockets(BOOL isdaemon, if ( !reload_nmbd_services(False) ) return(-1); + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_NMBD); + if(!init_names()) return -1; diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/nsswitch/winbindd.c HEAD-modules/source/nsswitch/winbindd.c --- HEAD/source/nsswitch/winbindd.c Mon Dec 2 15:46:20 2002 +++ HEAD-modules/source/nsswitch/winbindd.c Fri Dec 6 09:22:43 2002 @@ -828,6 +828,9 @@ static void usage(void) exit(1); } + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_WINBINDD); + /* Setup names. */ if (!init_names()) diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/smbd/conn.c HEAD-modules/source/smbd/conn.c --- HEAD/source/smbd/conn.c Tue Aug 20 12:48:38 2002 +++ HEAD-modules/source/smbd/conn.c Fri Dec 6 09:22:43 2002 @@ -191,6 +191,7 @@ void conn_free(connection_struct *conn) handle = conn->vfs_private; while(handle) { /* Close dlopen() handle */ + /* we should do this on loading... */ done_fptr = (void (*)(connection_struct *))sys_dlsym(handle->handle, "vfs_done"); if (done_fptr == NULL) { @@ -198,6 +199,7 @@ void conn_free(connection_struct *conn) } else { done_fptr(conn); } + /* we should not unload modules */ sys_dlclose(handle->handle); DLIST_REMOVE(conn->vfs_private, handle); thandle = handle->next; diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/smbd/server.c HEAD-modules/source/smbd/server.c --- HEAD/source/smbd/server.c Tue Nov 26 14:11:04 2002 +++ HEAD-modules/source/smbd/server.c Fri Dec 6 09:22:43 2002 @@ -374,8 +374,8 @@ static BOOL open_sockets_smbd(BOOL is_da } /* Load DSO's */ - if(lp_modules()) - smb_load_modules(lp_modules()); + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_SMBD); return True; } diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/smbd/service.c HEAD-modules/source/smbd/service.c --- HEAD/source/smbd/service.c Thu Nov 21 07:34:44 2002 +++ HEAD-modules/source/smbd/service.c Fri Dec 6 09:22:43 2002 @@ -564,16 +564,7 @@ static connection_struct *make_connectio } } } - /* Initialise VFS function pointers */ - if (!smbd_vfs_init(conn)) { - DEBUG(0, ("vfs_init failed for service %s\n", lp_servicename(SNUM(conn)))); - conn_free(conn); - *status = NT_STATUS_UNSUCCESSFUL; - return NULL; - } - -/* ROOT Activities: */ /* check number of connections */ if (!claim_connection(conn, lp_servicename(SNUM(conn)), @@ -583,7 +574,22 @@ static connection_struct *make_connectio conn_free(conn); *status = NT_STATUS_INSUFFICIENT_RESOURCES; return NULL; - } + } + + /* load per share modules */ + if (lp_modules(SNUM(conn))) + +smb_load_modules(lp_modules(SNUM(conn)),SNUM(conn),MODULE_TYPES_PER_SHARE); + + /* Initialise VFS function pointers */ + + if (!smbd_vfs_init(conn)) { + DEBUG(0, ("vfs_init failed for service %s\n", +lp_servicename(SNUM(conn)))); + conn_free(conn); + *status = NT_STATUS_UNSUCCESSFUL; + return NULL; + } + +/* ROOT Activities: */ /* Preexecs are done here as they might make the dir we are to ChDir to below */ /* execute any "root preexec = " line */ diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/smbd/vfs.c HEAD-modules/source/smbd/vfs.c --- HEAD/source/smbd/vfs.c Wed Dec 4 07:18:44 2002 +++ HEAD-modules/source/smbd/vfs.c Fri Dec 6 09:22:43 2002 @@ -232,7 +232,7 @@ BOOL smbd_vfs_init(connection_struct *co /* We are using default separators: ' \t\r\n' */ vfs_objects = toktocliplist(&nobj, NULL); if (vfs_objects) { - vfs_path = lp_vfs_path(SNUM(conn)); + vfs_path = lp_modules_path(SNUM(conn)); conn->vfs_private = NULL; for(i=nobj-1; i>=0; i--) { handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct)); diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/torture/cmd_vfs.c HEAD-modules/source/torture/cmd_vfs.c --- HEAD/source/torture/cmd_vfs.c Sat Nov 23 17:52:50 2002 +++ HEAD-modules/source/torture/cmd_vfs.c Fri Dec 6 09:22:43 2002 @@ -28,7 +28,7 @@ static char *null_string = ""; static NTSTATUS cmd_load_module(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv) { struct smb_vfs_handle_struct *handle; - char *path = lp_vfs_path(0); + char *path = lp_modules_path(SNUM(vfs->conn)); char name[PATH_MAX]; if (argc != 2) { diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/torture/vfstest.c HEAD-modules/source/torture/vfstest.c --- HEAD/source/torture/vfstest.c Thu Sep 5 11:40:32 2002 +++ HEAD-modules/source/torture/vfstest.c Fri Dec 6 10:36:53 2002 @@ -527,6 +527,9 @@ int main(int argc, char *argv[]) /* TODO: check output */ reload_services(False); + + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_VFSTEST); /* the following functions are part of the Samba debugging facilities. See lib/debug.c */ diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/utils/net.c HEAD-modules/source/utils/net.c --- HEAD/source/utils/net.c Wed Nov 13 19:52:41 2002 +++ HEAD-modules/source/utils/net.c Fri Dec 6 09:22:43 2002 @@ -608,7 +608,10 @@ static struct functable net_func[] = { if (!opt_target_workgroup) { opt_target_workgroup = strdup(lp_workgroup()); } - + + if (lp_modules(GLOBAL_SECTION_SNUM)) + smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM, +MODULE_TYPES_NET); + if (!init_names()) exit(1); diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/utils/pdbedit.c HEAD-modules/source/utils/pdbedit.c --- HEAD/source/utils/pdbedit.c Wed Nov 13 19:52:42 2002 +++ HEAD-modules/source/utils/pdbedit.c Fri Dec 6 09:22:43 2002 @@ -503,8 +503,8 @@ int main (int argc, char **argv) exit(1); } - if(lp_modules()) - smb_load_modules(lp_modules()); + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_PDBEDIT); if (!init_names()) exit(1); diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/utils/smbgroupedit.c HEAD-modules/source/utils/smbgroupedit.c --- HEAD/source/utils/smbgroupedit.c Wed Nov 13 19:52:42 2002 +++ HEAD-modules/source/utils/smbgroupedit.c Fri Dec 6 09:22:43 2002 @@ -279,6 +279,9 @@ int main (int argc, char **argv) exit(1); } + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_SMBGROUPEDIT); + if (!init_names()) exit(1); diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/utils/smbpasswd.c HEAD-modules/source/utils/smbpasswd.c --- HEAD/source/utils/smbpasswd.c Wed Nov 13 19:52:43 2002 +++ HEAD-modules/source/utils/smbpasswd.c Fri Dec 6 09:22:43 2002 @@ -579,6 +579,9 @@ int main(int argc, char **argv) setup_logging("smbpasswd", True); + if (lp_modules(GLOBAL_SECTION_SNUM)) + +smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM,MODULE_TYPES_SMBPASSWD); + /* * Set the machine NETBIOS name if not already * set from the config file. diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/wrepld/server.c HEAD-modules/source/wrepld/server.c --- HEAD/source/wrepld/server.c Wed Nov 13 19:52:43 2002 +++ HEAD-modules/source/wrepld/server.c Fri Dec 6 09:22:43 2002 @@ -661,6 +661,9 @@ static void process(void) if (!reload_services(False)) return(-1); + if (lp_modules(GLOBAL_SECTION_SNUM)) + smb_load_modules(lp_modules(GLOBAL_SECTION_SNUM),GLOBAL_SECTION_SNUM, +MODULE_TYPES_WREPLD); + if (!init_names()) return -1; diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/param/loadparm.c HEAD-modules/source/param/loadparm.c --- HEAD/source/param/loadparm.c Mon Nov 25 06:45:26 2002 +++ HEAD-modules/source/param/loadparm.c Fri Dec 6 10:47:54 2002 @@ -111,7 +111,6 @@ typedef struct char *szPrivateDir; char **szPassdbBackend; char **szSamBackend; - char **szModules; char *szPasswordServer; char *szSocketOptions; char *szRealm; @@ -317,7 +316,8 @@ typedef struct char *fstype; char *szVfsObjectFile; char *szVfsOptions; - char *szVfsPath; + char *szModulesPath; + char **szModules; int iMinPrintSpace; int iMaxPrintJobs; int iWriteCacheSize; @@ -435,7 +435,8 @@ static service sDefault = { NULL, /* fstype */ NULL, /* vfs object */ NULL, /* vfs options */ - NULL, /* vfs path */ + (char *)dyn_LIBDIR, /* modules path */ + NULL, /* modules */ 0, /* iMinPrintSpace */ 1000, /* iMaxPrintJobs */ 0, /* iWriteCacheSize */ @@ -796,7 +797,8 @@ static struct parm_struct parm_table[] = {"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_HIDE}, {"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER}, {"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_HIDE}, - {"modules", P_LIST, P_GLOBAL, &Globals.szModules, NULL, NULL, FLAG_BASIC | FLAG_GLOBAL}, + {"modules path", P_STRING, P_LOCAL, &sDefault.szModulesPath, NULL, NULL, +FLAG_BASIC | FLAG_SHARE| FLAG_GLOBAL | FLAG_ADVANCED | FLAG_DEVELOPER}, + {"modules", P_LIST, P_LOCAL, &sDefault.szModules, NULL, NULL, FLAG_BASIC | +FLAG_SHARE | FLAG_GLOBAL}, {"Logging Options", P_SEP, P_SEPARATOR}, @@ -1073,9 +1075,8 @@ static struct parm_struct parm_table[] = {"vfs object", P_STRING, P_LOCAL, &sDefault.szVfsObjectFile, handle_vfs_object, NULL, FLAG_SHARE}, {"vfs options", P_STRING, P_LOCAL, &sDefault.szVfsOptions, NULL, NULL, FLAG_SHARE}, - {"vfs path", P_STRING, P_LOCAL, &sDefault.szVfsPath, NULL, NULL, FLAG_SHARE}, - - + {"vfs path", P_STRING, P_LOCAL, &sDefault.szModulesPath, NULL, NULL, +FLAG_HIDE}, + {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_SHARE}, {"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, @@ -1566,7 +1567,6 @@ static FN_GLOBAL_STRING(lp_announce_vers FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases) FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend) FN_GLOBAL_LIST(lp_sam_backend, &Globals.szSamBackend) -FN_GLOBAL_LIST(lp_modules, &Globals.szModules) FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction) FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript) FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript) @@ -1722,7 +1722,8 @@ FN_LOCAL_LIST(lp_printer_admin, printer_ FN_LOCAL_STRING(lp_fstype, fstype) FN_LOCAL_STRING(lp_vfsobj, szVfsObjectFile) FN_LOCAL_STRING(lp_vfs_options, szVfsOptions) -FN_LOCAL_STRING(lp_vfs_path, szVfsPath) +FN_LOCAL_STRING(lp_modules_path, szModulesPath) +FN_LOCAL_LIST(lp_modules, szModules) static FN_LOCAL_STRING(lp_volume, volume) FN_LOCAL_STRING(lp_mangled_map, szMangledMap) FN_LOCAL_STRING(lp_veto_files, szVetoFiles)