[PATCH] module path stuff

Stefan (metze) Metzmacher metze at metzemix.de
Fri Jan 10 00:14:32 GMT 2003


Hi Jelmer,

here are the things I changed from the last patch:

in Makefile.in:

DATADIR = @datadir@  jht agree:-)

module stuff:
we now have a

#define SMB_MODULE_INIT_SYMBOL_STR "smb_module_init"
#define SMB_MODULE_INIT_SYMBOL           smb_module_init

maybe we could postfix a version number? ->
         SMB_MODULE_INIT_SYMBOL smb_module_init_0_0


smb_register_vfs stuff:
we now have conn->vfs_objects (a DLIST with all vfs_objects of the connection)

each vfs module got a global id number, with this number or it's registered 
name it can search itsself in the list. and got it's default options , 
opaque options or any other operations from other modules of the connection.

for making it easy for module writers we have:

vfs_get_deafult_ops(conn,module_id)  to get a pointer to a vfs_ops struct
vfs_get_default_op(conn,module_id,operation_type) to get a pointer to a 
specified operation function

vfs_get_default_ops_by_name(conn,module_name)
vfs_get_default_ops_by_name(conn.module_name)

vfs_get_opaque_ops(conn)
vfs_get_opaque_op(conn,operation_type)

the vfs_init() and vfs_done() function are gone...
and only the vfs_op_tuple array is registered by each module.
( if the module needs to init private data it should be done in the connect 
and disconnect functions)

(tridge: I hope your happy now)

- 'vfs options' is removed ( parametric options should be used)
- 'vfs objects = <module1_name>{[<module2_name>]}

-----------------------
here th ething witch were in the last patch:

here is a new patch for the modules stuff, parametric options and new 
smb_register_vfs():

- 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, connection_struct *conn, 
SMB_MODULE_TYPES types)

conn == NULL - 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),NULL,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@

%-Macros can be in 'modules path' and 'modules'

- parametric options now all take a default value.
  char *lp_param_string() and char **lp_param_string_list() can be used as 
every othere
  lp_* function with char * or char **
  you should not try to free() the return values of this function!!!

- smb_register_vfs()
    Each SAMBA module must provide following global function:
     init_module         -- module initalization function

         NTSTATUS init_module(SMB_MODULE_TYPES types)
         {
                 if (types & MODULE_TYPE_VFS) {
                         if (smb_register_vfs("recycle", vfs_recycle_init, 
VFS_INTERFACE_VERSION)) {
                                 return NT_STATUS_OK;
                         } else {
                                 return NT_STATUS_UNSUCCESSFUL;
                         }
                 }

                 return NT_STATUS_OK;
         }

     Each VFS module must provide following global function:
     vfs_*_init          -- vfs initialization function

     vfs_*_init (e.g. vfs_recycle_init ) must return proper initialized 
vfs_op_tuple[] array
     which describes all operations this module claims to intercept. This 
function
     is called whenever module is loaded into smbd process using sys_dlopen().

     vfs_*_init must have a list (indexed by the SNUM(conn) or CNUM(conn))
     for storing the default_vfs_ops and if module wants to store private
     information for further usage.

     Prototypes:
     vfs_op_tuple *vfs_recycle_init(struct connection_struct *conn, struct 
vfs_ops *default_vfs_ops, const char *param);


'vfs path' is removed
'vfs options' is removed ( parametric options should be used)

'vfs object' move to 'vfs objects'  ( but 'vfs object' is an alias)

'vfs objects = <module1_name>{[<module2_name>]}

- vfs_audit.c is installed as audit.so
- vfs_recycle.c is installed as recycle.so
- vfs_nettalk.c is installed as nettalk.so

vfs_audit.c and vfs_recycle.c  are now per connection safe
vfs_netatalk.c should be updated to use SMB_VFS_INTERFACE_VERSION 6 later


I have tested this patch this afternoon and I have no problems...

metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <metze at metzemix.de>
-------------- next part --------------
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/Makefile.in HEAD-modules/source/Makefile.in
--- HEAD/source/Makefile.in	Fri Dec 13 07:25:43 2002
+++ HEAD-modules/source/Makefile.in	Fri Dec 13 07:29:48 2002
@@ -52,6 +52,8 @@ 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@
 
 # The permissions to give the executables
 INSTALLPERMS = 0755
@@ -94,12 +96,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=\"$(CONFIGDIR)\"
-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.
 
@@ -127,7 +128,7 @@ SCRIPTS = $(srcdir)/script/smbtar $(srcd
 
 QUOTAOBJS=@QUOTAOBJS@
 
-VFS_MODULES = bin/vfs_audit. at SHLIBEXT@ bin/vfs_recycle. at SHLIBEXT@ bin/vfs_netatalk. at SHLIBEXT@ 
+VFS_MODULES = bin/audit. at SHLIBEXT@ bin/recycle_bin. at SHLIBEXT@ bin/netatalk. at SHLIBEXT@ 
 PDB_MODULES = @MODULE_MYSQL@ @MODULE_XML@
 MODULES = bin/developer. at SHLIBEXT@ 
 
@@ -874,17 +875,17 @@ bin/xml. at SHLIBEXT@: $(XML_OBJ)
 	@$(SHLD) $(LDSHFLAGS) -o $@ $(XML_OBJ) @XML_LIBS@ \
 		@SONAMEFLAG@`basename $@`
 
-bin/vfs_audit. at SHLIBEXT@: $(VFS_AUDIT_OBJ)
+bin/audit. at SHLIBEXT@: $(VFS_AUDIT_OBJ)
 	@echo "Building plugin $@"
 	@$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_AUDIT_OBJ) \
 		@SONAMEFLAG@`basename $@`
 
-bin/vfs_recycle. at SHLIBEXT@: $(VFS_RECYCLE_OBJ)
+bin/recycle_bin. at SHLIBEXT@: $(VFS_RECYCLE_OBJ)
 	@echo "Building plugin $@"
 	@$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_RECYCLE_OBJ) \
 		@SONAMEFLAG@`basename $@`
 
-bin/vfs_netatalk. at SHLIBEXT@: $(VFS_NETATALK_OBJ)
+bin/netatalk. at SHLIBEXT@: $(VFS_NETATALK_OBJ)
 	@echo "Building plugin $@"
 	@$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_NETATALK_OBJ) \
 		@SONAMEFLAG@`basename $@`
@@ -923,24 +924,28 @@ 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)$(DATADIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR)
 
 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
+installmoduledirs:
+	@$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VFSLIBDIR) $(DESTDIR)$(PDBLIBDIR)
+
+installmodules: modules installmoduledirs
 	@$(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) $(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)
@@ -1021,6 +1026,7 @@ showlayout: 
 	@echo "  libdir:  $(LIBDIR)"
 	@echo "  vardir:  $(VARDIR)"
 	@echo "  mandir:  $(MANDIR)"
+	@echo "  datadir: $(DATADIR)"
 
 
 uninstall: uninstallman uninstallbin uninstallscripts
@@ -1029,8 +1035,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)
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/include/includes.h HEAD-modules/source/include/includes.h
--- HEAD/source/include/includes.h	Thu Dec 12 20:24:26 2002
+++ HEAD-modules/source/include/includes.h	Thu Dec 12 14:04:51 2002
@@ -734,6 +734,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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Mon Dec 16 10:30:57 2002
@@ -0,0 +1,65 @@
+/* 
+ *  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_TYPE_AUTH	0x0000000000000020
+
+#define MODULE_TYPES_ALL	0xFFFFFFFFFFFFFFFF
+
+#ifdef WITH_SAM
+#define MODULE_TYPES_SMBD		MODULE_TYPE_CHARSET | MODULE_TYPE_PDB | MODULE_TYPE_AUTH | MODULE_TYPE_VFS | MODULE_TYPE_SAM
+#else
+#define MODULE_TYPES_SMBD		MODULE_TYPE_CHARSET | MODULE_TYPE_PDB | MODULE_TYPE_AUTH | 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
+
+
+/* This is the FUNCTION SYMBOL witch we're searching for when we load modules */
+#define SMB_MODULE_SYMBOL_STR	"smb_module_init"
+#define SMB_MODULE_SYMBOL	smb_module_init
+
+/* Module support */
+typedef NTSTATUS (SMB_MODULE_INIT_FUNCTION) (SMB_MODULE_TYPES);
+
+#endif /* _MODULES_H */
\ No newline at end of file
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/include/smb.h HEAD-modules/source/include/smb.h
--- HEAD/source/include/smb.h	Fri Dec 13 07:25:43 2002
+++ HEAD-modules/source/include/smb.h	Fri Dec 13 08:35:08 2002
@@ -430,18 +430,10 @@ typedef struct
 #include "smb_acls.h"
 #include "vfs.h"
 
-typedef struct smb_vfs_handle_struct
-{
-    void *data;
-    /* Handle on dlopen() call */
-    void *handle;
-    struct smb_vfs_handle_struct  *next, *prev;
-    
-} smb_vfs_handle_struct;
-
 typedef struct connection_struct
 {
 	struct connection_struct *next, *prev;
+	TALLOC_CTX *mem_ctx;
 	unsigned cnum; /* an index passed over the wire */
 	int service;
 	BOOL force_user;
@@ -456,8 +448,14 @@ typedef struct connection_struct
 	char *connectpath;
 	char *origpath;
 
-	struct vfs_ops vfs_ops;                   /* Filesystem operations */
-	struct smb_vfs_handle_struct *vfs_private;
+	struct vfs_ops vfs_ops;			/* Filesystem operations */
+	vfs_object_function_entry *vfs_objects;	/* DLIST of all objects for this connection 
+						 * (talloc'ed on conn->mem_ctx)
+						 */
+	struct vfs_ops *vfs_opaque_ops;		/* Opaque filesystem operations 
+						 * access them only via vfs_get_opaque_ops(conn)
+						 * (it init them)
+						 */
 
 	char *user; /* name of user who *opened* this connection */
 	uid_t uid; /* uid of user who *opened* this connection */
@@ -1714,8 +1712,5 @@ extern struct poptOption popt_common_soc
 extern struct poptOption popt_common_version[];
 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 13:37:44 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	(-2)
 /* 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/include/vfs.h HEAD-modules/source/include/vfs.h
--- HEAD/source/include/vfs.h	Wed Sep 18 09:44:22 2002
+++ HEAD-modules/source/include/vfs.h	Fri Dec 13 09:58:49 2002
@@ -45,46 +45,45 @@
 /* Changed to version 3 for POSIX acl extensions. JRA. */
 /* Changed to version 4 for cascaded VFS interface. Alexander Bokovoy. */
 /* Changed to version 5 for sendfile addition. JRA. */
-#define SMB_VFS_INTERFACE_VERSION 5
+/* Changed to version 6 for using smb_register_vfs()... metze */
+#define SMB_VFS_INTERFACE_VERSION 6
 
 
-/* Version of supported cascaded interface backward copmatibility.
-   (version 5 corresponds to SMB_VFS_INTERFACE_VERSION 5)
-   It is used in vfs_init_custom() to detect VFS modules which conform to cascaded 
-   VFS interface but implement elder version than current version of Samba uses.
-   This allows to use old modules with new VFS interface as far as combined VFS operation
-   set is coherent (will be in most cases). 
-*/
-#define SMB_VFS_INTERFACE_CASCADED 5
-
 /*
-    Each VFS module must provide following global functions:
-    vfs_init	-- initialization function
-    vfs_done	-- finalization function
-    
-    vfs_init must return proper initialized vfs_op_tuple[] array
+    Each SAMBA module must provide following global function:
+    init_module		-- module initalization function 
+
+	NTSTATUS init_module(SMB_MODULE_TYPES types) 
+	{
+		if (types & MODULE_TYPE_VFS) {
+			if (smb_register_vfs("recycle", vfs_recycle_init, VFS_INTERFACE_VERSION)) {
+				return NT_STATUS_OK;
+			} else {
+				return NT_STATUS_UNSUCCESSFUL;
+			}
+		}
+	
+		return NT_STATUS_OK;
+	}
+
+    Each VFS module must provide following global function:
+    vfs_*_init		-- vfs initialization function
+
+    vfs_*_init (e.g. vfs_recycle_init ) must return proper initialized vfs_op_tuple[] array
     which describes all operations this module claims to intercept. This function
     is called whenever module is loaded into smbd process using sys_dlopen().
-    
-    vfs_init must store somewhere vfs_handle reference if module wants to store per-instance
-    private information for further usage. vfs_handle->data should be used to
-    store such information. Do not try to change other fields in this structure
-    or results likely to be unpredictable.
-    
-    vfs_done must perform finalization of the module. In particular,
-    this function must free vfs_ops structure returned to module from smb_vfs_get_opaque_ops()
-    function if it is used (see below). This function is called whenever module 
-    is unloaded from smbd process using sys_dlclose().
-    
+
+    vfs_*_init must have a list (indexed by the SNUM(conn) or CNUM(conn))
+    for storing the default_vfs_ops and if module wants to store private 
+    information for further usage.
+
     Prototypes:
-    vfs_op_tuple *vfs_init(int *vfs_version, const struct vfs_ops *def_vfs_ops,
-			    struct smb_vfs_handle_struct *vfs_handle);
-    void	  vfs_done(connection_struct *conn);
+    vfs_op_tuple *vfs_recycle_init(struct connection_struct *conn, struct vfs_ops *default_vfs_ops, const char *param);
     
     All intercepted VFS operations must be declared as static functions inside module source
-    in order to keep smbd namespace unpolluted. See source of skel, audit, and recycle bin
+    in order to keep smbd namespace unpolluted. See source of nettalk, audit, and recycle bin
     example VFS modules for more details.
-    
+
 */
 
 /* VFS operations structure */
@@ -93,86 +92,167 @@ struct connection_struct;
 struct files_struct;
 struct security_descriptor_info;
 
-struct vfs_ops {
+#define VFS_OP(x) ((void *) x)
 
+typedef void  (*VFS_OP_PTR);
 	/* Disk operations */
     
-	int (*connect)(struct connection_struct *conn, const char *service, const char *user);
-	void (*disconnect)(struct connection_struct *conn);
-	SMB_BIG_UINT (*disk_free)(struct connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize, 
+typedef	int (*VFS_OP_PTR_CONNECT)(struct connection_struct *conn, const char *service, const char *user);
+typedef	void (*VFS_OP_PTR_DISCONNECT)(struct connection_struct *conn);
+typedef	SMB_BIG_UINT (*VFS_OP_PTR_DISK_FREE)(struct connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize, 
 		SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
     
 	/* Directory operations */
 
-	DIR *(*opendir)(struct connection_struct *conn, const char *fname);
-	struct dirent *(*readdir)(struct connection_struct *conn, DIR *dirp);
-	int (*mkdir)(struct connection_struct *conn, const char *path, mode_t mode);
-	int (*rmdir)(struct connection_struct *conn, const char *path);
-	int (*closedir)(struct connection_struct *conn, DIR *dir);
+typedef	DIR *(*VFS_OP_PTR_OPENDIR)(struct connection_struct *conn, const char *fname);
+typedef	struct dirent *(*VFS_OP_PTR_READDIR)(struct connection_struct *conn, DIR *dirp);
+typedef	int (*VFS_OP_PTR_MKDIR)(struct connection_struct *conn, const char *path, mode_t mode);
+typedef	int (*VFS_OP_PTR_RMDIR)(struct connection_struct *conn, const char *path);
+typedef	int (*VFS_OP_PTR_CLOSEDIR)(struct connection_struct *conn, DIR *dir);
     
 	/* File operations */
     
-	int (*open)(struct connection_struct *conn, const char *fname, int flags, mode_t mode);
-	int (*close)(struct files_struct *fsp, int fd);
-	ssize_t (*read)(struct files_struct *fsp, int fd, void *data, size_t n);
-	ssize_t (*write)(struct files_struct *fsp, int fd, const void *data, size_t n);
-	SMB_OFF_T (*lseek)(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence);
-	ssize_t (*sendfile)(int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
-	int (*rename)(struct connection_struct *conn, const char *old, const char *new);
-	int (*fsync)(struct files_struct *fsp, int fd);
-	int (*stat)(struct connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf);
-	int (*fstat)(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf);
-	int (*lstat)(struct connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf);
-	int (*unlink)(struct connection_struct *conn, const char *path);
-	int (*chmod)(struct connection_struct *conn, const char *path, mode_t mode);
-	int (*fchmod)(struct files_struct *fsp, int fd, mode_t mode);
-	int (*chown)(struct connection_struct *conn, const char *path, uid_t uid, gid_t gid);
-	int (*fchown)(struct files_struct *fsp, int fd, uid_t uid, gid_t gid);
-	int (*chdir)(struct connection_struct *conn, const char *path);
-	char *(*getwd)(struct connection_struct *conn, char *buf);
-	int (*utime)(struct connection_struct *conn, const char *path, struct utimbuf *times);
-	int (*ftruncate)(struct files_struct *fsp, int fd, SMB_OFF_T offset);
-	BOOL (*lock)(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
-	int (*symlink)(struct connection_struct *conn, const char *oldpath, const char *newpath);
-	int (*readlink)(struct connection_struct *conn, const char *path, char *buf, size_t bufsiz);
-	int (*link)(struct connection_struct *conn, const char *oldpath, const char *newpath);
-	int (*mknod)(struct connection_struct *conn, const char *path, mode_t mode, SMB_DEV_T dev);
-	char *(*realpath)(struct connection_struct *conn, const char *path, char *resolved_path);
+typedef	int (*VFS_OP_PTR_OPEN)(struct connection_struct *conn, const char *fname, int flags, mode_t mode);
+typedef	int (*VFS_OP_PTR_CLOSE)(struct files_struct *fsp, int fd);
+typedef	ssize_t (*VFS_OP_PTR_READ)(struct files_struct *fsp, int fd, void *data, size_t n);
+typedef	ssize_t (*VFS_OP_PTR_WRITE)(struct files_struct *fsp, int fd, const void *data, size_t n);
+typedef	SMB_OFF_T (*VFS_OP_PTR_LSEEK)(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence);
+typedef	ssize_t (*VFS_OP_PTR_SENDFILE)(int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
+typedef	int (*VFS_OP_PTR_RENAME)(struct connection_struct *conn, const char *old, const char *new);
+typedef	int (*VFS_OP_PTR_FSYNC)(struct files_struct *fsp, int fd);
+typedef	int (*VFS_OP_PTR_STAT)(struct connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf);
+typedef	int (*VFS_OP_PTR_FSTAT)(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf);
+typedef	int (*VFS_OP_PTR_LSTAT)(struct connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf);
+typedef	int (*VFS_OP_PTR_UNLINK)(struct connection_struct *conn, const char *path);
+typedef	int (*VFS_OP_PTR_CHMOD)(struct connection_struct *conn, const char *path, mode_t mode);
+typedef	int (*VFS_OP_PTR_FCHMOD)(struct files_struct *fsp, int fd, mode_t mode);
+typedef	int (*VFS_OP_PTR_CHOWN)(struct connection_struct *conn, const char *path, uid_t uid, gid_t gid);
+typedef	int (*VFS_OP_PTR_FCHOWN)(struct files_struct *fsp, int fd, uid_t uid, gid_t gid);
+typedef	int (*VFS_OP_PTR_CHDIR)(struct connection_struct *conn, const char *path);
+typedef	char *(*VFS_OP_PTR_GETWD)(struct connection_struct *conn, char *buf);
+typedef	int (*VFS_OP_PTR_UTIME)(struct connection_struct *conn, const char *path, struct utimbuf *times);
+typedef	int (*VFS_OP_PTR_FTRUNCATE)(struct files_struct *fsp, int fd, SMB_OFF_T offset);
+typedef	BOOL (*VFS_OP_PTR_LOCK)(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
+typedef	int (*VFS_OP_PTR_SYMLINK)(struct connection_struct *conn, const char *oldpath, const char *newpath);
+typedef	int (*VFS_OP_PTR_READLINK)(struct connection_struct *conn, const char *path, char *buf, size_t bufsiz);
+typedef	int (*VFS_OP_PTR_LINK)(struct connection_struct *conn, const char *oldpath, const char *newpath);
+typedef	int (*VFS_OP_PTR_MKNOD)(struct connection_struct *conn, const char *path, mode_t mode, SMB_DEV_T dev);
+typedef	char *(*VFS_OP_PTR_REALPATH)(struct connection_struct *conn, const char *path, char *resolved_path);
 
 	/* NT ACL operations. */
 
-	size_t (*fget_nt_acl)(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc);
-	size_t (*get_nt_acl)(struct files_struct *fsp, const char *name, struct security_descriptor_info **ppdesc);
-	BOOL (*fset_nt_acl)(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd);
-	BOOL (*set_nt_acl)(struct files_struct *fsp, const char *name, uint32 security_info_sent, struct security_descriptor_info *psd);
+typedef	size_t (*VFS_OP_PTR_FGET_NT_ACL)(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc);
+typedef	size_t (*VFS_OP_PTR_GET_NT_ACL)(struct files_struct *fsp, const char *name, struct security_descriptor_info **ppdesc);
+typedef	BOOL (*VFS_OP_PTR_FSET_NT_ACL)(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd);
+typedef	BOOL (*VFS_OP_PTR_SET_NT_ACL)(struct files_struct *fsp, const char *name, uint32 security_info_sent, struct security_descriptor_info *psd);
 
 	/* POSIX ACL operations. */
 
-	int (*chmod_acl)(struct connection_struct *conn, const char *name, mode_t mode);
-	int (*fchmod_acl)(struct files_struct *fsp, int fd, mode_t mode);
+typedef	int (*VFS_OP_PTR_CHMOD_ACL)(struct connection_struct *conn, const char *name, mode_t mode);
+typedef	int (*VFS_OP_PTR_FCHMOD_ACL)(struct files_struct *fsp, int fd, mode_t mode);
+
+typedef	int (*VFS_OP_PTR_SYS_ACL_GET_ENTRY)(struct connection_struct *conn, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
+typedef	int (*VFS_OP_PTR_SYS_ACL_GET_TAG_TYPE)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
+typedef	int (*VFS_OP_PTR_SYS_ACL_GET_PERMSET)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
+typedef	void * (*VFS_OP_PTR_SYS_ACL_GET_QUALIFIER)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d);
+typedef	SMB_ACL_T (*VFS_OP_PTR_SYS_ACL_GET_FILE)(struct connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type);
+typedef	SMB_ACL_T (*VFS_OP_PTR_SYS_ACL_GET_FD)(struct files_struct *fsp, int fd);
+typedef	int (*VFS_OP_PTR_SYS_ACL_CLEAR_PERMS)(struct connection_struct *conn, SMB_ACL_PERMSET_T permset);
+typedef	int (*VFS_OP_PTR_SYS_ACL_ADD_PERM)(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
+typedef	char * (*VFS_OP_PTR_SYS_ACL_TO_TEXT)(struct connection_struct *conn, SMB_ACL_T theacl, ssize_t *plen);
+typedef	SMB_ACL_T (*VFS_OP_PTR_SYS_ACL_INIT)(struct connection_struct *conn, int count);
+typedef	int (*VFS_OP_PTR_SYS_ACL_CREATE_ENTRY)(struct connection_struct *conn, SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
+typedef	int (*VFS_OP_PTR_SYS_ACL_SET_TAG_TYPE)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
+typedef	int (*VFS_OP_PTR_SYS_ACL_SET_QUALIFIER)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, void *qual);
+typedef	int (*VFS_OP_PTR_SYS_ACL_SET_PERMSET)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
+typedef	int (*VFS_OP_PTR_SYS_ACL_VALID)(struct connection_struct *conn, SMB_ACL_T theacl );
+typedef	int (*VFS_OP_PTR_SYS_ACL_SET_FILE)(struct connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
+typedef	int (*VFS_OP_PTR_SYS_ACL_SET_FD)(struct files_struct *fsp, int fd, SMB_ACL_T theacl);
+typedef	int (*VFS_OP_PTR_SYS_ACL_DELETE_DEF_FILE)(struct connection_struct *conn, const char *path);
+typedef	int (*VFS_OP_PTR_SYS_ACL_GET_PERM)(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
+typedef	int (*VFS_OP_PTR_SYS_ACL_FREE_TEXT)(struct connection_struct *conn, char *text);
+typedef	int (*VFS_OP_PTR_SYS_ACL_FREE_ACL)(struct connection_struct *conn, SMB_ACL_T posix_acl);
+typedef	int (*VFS_OP_PTR_SYS_ACL_FREE_QUALIFIER)(struct connection_struct *conn, void *qualifier, SMB_ACL_TAG_T tagtype);
 
-	int (*sys_acl_get_entry)(struct connection_struct *conn, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
-	int (*sys_acl_get_tag_type)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
-	int (*sys_acl_get_permset)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
-	void * (*sys_acl_get_qualifier)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d);
-	SMB_ACL_T (*sys_acl_get_file)(struct connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type);
-	SMB_ACL_T (*sys_acl_get_fd)(struct files_struct *fsp, int fd);
-	int (*sys_acl_clear_perms)(struct connection_struct *conn, SMB_ACL_PERMSET_T permset);
-	int (*sys_acl_add_perm)(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
-	char * (*sys_acl_to_text)(struct connection_struct *conn, SMB_ACL_T theacl, ssize_t *plen);
-	SMB_ACL_T (*sys_acl_init)(struct connection_struct *conn, int count);
-	int (*sys_acl_create_entry)(struct connection_struct *conn, SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
-	int (*sys_acl_set_tag_type)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
-	int (*sys_acl_set_qualifier)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, void *qual);
-	int (*sys_acl_set_permset)(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
-	int (*sys_acl_valid)(struct connection_struct *conn, SMB_ACL_T theacl );
-	int (*sys_acl_set_file)(struct connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
-	int (*sys_acl_set_fd)(struct files_struct *fsp, int fd, SMB_ACL_T theacl);
-	int (*sys_acl_delete_def_file)(struct connection_struct *conn, const char *path);
-	int (*sys_acl_get_perm)(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
-	int (*sys_acl_free_text)(struct connection_struct *conn, char *text);
-	int (*sys_acl_free_acl)(struct connection_struct *conn, SMB_ACL_T posix_acl);
-	int (*sys_acl_free_qualifier)(struct connection_struct *conn, void *qualifier, SMB_ACL_TAG_T tagtype);
+
+struct vfs_ops {
+	/* Disk operations */
+    
+	VFS_OP_PTR_CONNECT connect;
+	VFS_OP_PTR_DISCONNECT disconnect;
+	VFS_OP_PTR_DISK_FREE disk_free;
+    
+	/* Directory operations */
+
+	VFS_OP_PTR_OPENDIR opendir;
+	VFS_OP_PTR_READDIR readdir;
+	VFS_OP_PTR_MKDIR mkdir;
+	VFS_OP_PTR_RMDIR rmdir;
+	VFS_OP_PTR_CLOSEDIR closedir;
+    
+	/* File operations */
+    
+	VFS_OP_PTR_OPEN open;
+	VFS_OP_PTR_CLOSE close;
+	VFS_OP_PTR_READ read;
+	VFS_OP_PTR_WRITE write;
+	VFS_OP_PTR_LSEEK lseek;
+	VFS_OP_PTR_SENDFILE sendfile;
+	VFS_OP_PTR_RENAME rename;
+	VFS_OP_PTR_FSYNC fsync;
+	VFS_OP_PTR_STAT stat;
+	VFS_OP_PTR_FSTAT fstat;
+	VFS_OP_PTR_LSTAT lstat;
+	VFS_OP_PTR_UNLINK unlink;
+	VFS_OP_PTR_CHMOD chmod;
+	VFS_OP_PTR_FCHMOD fchmod;
+	VFS_OP_PTR_CHOWN chown;
+	VFS_OP_PTR_FCHOWN fchown;
+	VFS_OP_PTR_CHDIR chdir;
+	VFS_OP_PTR_GETWD getwd;
+	VFS_OP_PTR_UTIME utime;
+	VFS_OP_PTR_FTRUNCATE ftruncate;
+	VFS_OP_PTR_LOCK lock;
+	VFS_OP_PTR_SYMLINK symlink;
+	VFS_OP_PTR_READLINK readlink;
+	VFS_OP_PTR_LINK link;
+	VFS_OP_PTR_MKNOD mknod;
+	VFS_OP_PTR_REALPATH realpath;
+
+	/* NT ACL operations. */
+
+	VFS_OP_PTR_FGET_NT_ACL fget_nt_acl;
+	VFS_OP_PTR_GET_NT_ACL get_nt_acl;
+	VFS_OP_PTR_FSET_NT_ACL fset_nt_acl;
+	VFS_OP_PTR_SET_NT_ACL set_nt_acl;
+
+	/* POSIX ACL operations. */
+
+	VFS_OP_PTR_CHMOD_ACL chmod_acl;
+	VFS_OP_PTR_FCHMOD_ACL fchmod_acl;
+
+	VFS_OP_PTR_SYS_ACL_GET_ENTRY sys_acl_get_entry;
+	VFS_OP_PTR_SYS_ACL_GET_TAG_TYPE sys_acl_get_tag_type;
+	VFS_OP_PTR_SYS_ACL_GET_PERMSET sys_acl_get_permset;
+	VFS_OP_PTR_SYS_ACL_GET_QUALIFIER sys_acl_get_qualifier;
+	VFS_OP_PTR_SYS_ACL_GET_FILE sys_acl_get_file;
+	VFS_OP_PTR_SYS_ACL_GET_FD sys_acl_get_fd;
+	VFS_OP_PTR_SYS_ACL_CLEAR_PERMS sys_acl_clear_perms;
+	VFS_OP_PTR_SYS_ACL_ADD_PERM sys_acl_add_perm;
+	VFS_OP_PTR_SYS_ACL_TO_TEXT sys_acl_to_text;
+	VFS_OP_PTR_SYS_ACL_INIT sys_acl_init;
+	VFS_OP_PTR_SYS_ACL_CREATE_ENTRY sys_acl_create_entry;
+	VFS_OP_PTR_SYS_ACL_SET_TAG_TYPE sys_acl_set_tag_type;
+	VFS_OP_PTR_SYS_ACL_SET_QUALIFIER sys_acl_set_qualifier;
+	VFS_OP_PTR_SYS_ACL_SET_PERMSET sys_acl_set_permset;
+	VFS_OP_PTR_SYS_ACL_VALID sys_acl_valid;
+	VFS_OP_PTR_SYS_ACL_SET_FILE sys_acl_set_file;
+	VFS_OP_PTR_SYS_ACL_SET_FD sys_acl_set_fd;
+	VFS_OP_PTR_SYS_ACL_DELETE_DEF_FILE sys_acl_delete_def_file;
+	VFS_OP_PTR_SYS_ACL_GET_PERM sys_acl_get_perm;
+	VFS_OP_PTR_SYS_ACL_FREE_TEXT sys_acl_free_text;
+	VFS_OP_PTR_SYS_ACL_FREE_ACL sys_acl_free_acl;
+	VFS_OP_PTR_SYS_ACL_FREE_QUALIFIER sys_acl_free_qualifier;
 };
 
 struct vfs_options {
@@ -321,18 +401,15 @@ typedef struct _vfs_op_tuple {
 	vfs_op_layer layer;
 } vfs_op_tuple;
 
-/*
-    Return vfs_ops filled with current opaque VFS operations. This function is designed to
-    be called from VFS module initialization function for those modules which needs 'direct' VFS
-    access (loggers or initiators of file operations other than connection asks for).
-    
-    Returned vfs_ops must be cleaned up in VFS module's finalizer function (vfs_done_<module_name>)
-    using safe_free().
-    
-    Prototype:
-    struct vfs_ops *smb_vfs_get_opaque_ops();
-    
-    This prototype will be available via include/proto.h
-*/
-
+typedef struct _vfs_object_function_entry {
+	struct _vfs_object_function_entry *prev, *next;
+	char *name;
+	vfs_op_tuple *op_tuples;
+	int id;
+	struct vfs_ops *default_ops;	/* only access this with 
+					 * vfs_get_default_ops(conn,module_id) or
+					 * vfs_get_default_ops_by_name(conn,module_name)
+					 */
+}vfs_object_function_entry;
+	
 #endif /* _VFS_H */
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Thu Dec 12 13:12:46 2002
@@ -22,46 +22,72 @@
 #include "includes.h"
 
 #ifdef HAVE_DLOPEN
-NTSTATUS smb_load_module(const char *module_name)
+NTSTATUS smb_load_module(const char *module_name, connection_struct *conn, SMB_MODULE_TYPES types)
 {
 	void *handle;
-	init_module_function *init;
+	SMB_MODULE_INIT_FUNCTION *init;
 	NTSTATUS nt_status;
+	pstring full_module_name;
+
+	if (lp_modules_path(SNUM(conn)) && *lp_modules_path(SNUM(conn)) && *module_name!='/') {
+		pstrcpy(full_module_name,lp_modules_path(SNUM(conn)));
+		pstrcat(full_module_name,"/");
+		pstrcat(full_module_name,module_name);
+	} else {
+		pstrcpy(full_module_name,module_name);
+	}
+
+	/* substitutions  */
+	if (conn) {
+		standard_sub_conn(conn,full_module_name,sizeof(pstring));
+	} else {
+		standard_sub_snum(SNUM(conn),full_module_name,sizeof(pstring));
+	}
 
 	/* 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");
+	init = sys_dlsym(handle, SMB_MODULE_SYMBOL_STR);
 
 	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 '%s' in %s: %s\nMaybe you need to update your module.\n",
+			SMB_MODULE_SYMBOL_STR, 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, connection_struct *conn, SMB_MODULE_TYPES types)
 {
 	int i;
 	int success = 0;
 
+	if (SNUM(conn) != GLOBAL_SECTION_SNUM && 
+		lp_modules(GLOBAL_SECTION_SNUM)==modules) {
+		/* don't load modules of the global section
+		 * when SNUM(conn) != 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],conn,types))) {
 			success++;
 		}
 	}
@@ -73,13 +99,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, connection_struct *conn, 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, connection_struct *conn, 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/lib/util.c HEAD-modules/source/lib/util.c
--- HEAD/source/lib/util.c	Thu Dec 12 20:24:26 2002
+++ HEAD-modules/source/lib/util.c	Mon Dec 16 08:55:12 2002
@@ -2164,15 +2164,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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/lib/util_str.c HEAD-modules/source/lib/util_str.c
--- HEAD/source/lib/util_str.c	Thu Dec 12 20:24:26 2002
+++ HEAD-modules/source/lib/util_str.c	Thu Dec 12 14:04:52 2002
@@ -1232,6 +1232,54 @@ char **str_list_make(const char *string,
 	return list;
 }
 
+char **talloc_str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
+{
+	char **list, **rlist;
+	const char *str;
+	char *s;
+	int num, lsize;
+	pstring tok;
+	
+	if (!string || !*string)
+		return NULL;
+	s = strdup(string);
+	if (!s) {
+		DEBUG(0,("str_list_make: Unable to allocate memory"));
+		return NULL;
+	}
+	if (!sep) sep = LIST_SEP;
+	
+	num = lsize = 0;
+	list = NULL;
+	
+	str = s;
+	while (next_token(&str, tok, sep, sizeof(tok))) {		
+		if (num == lsize) {
+			lsize += S_LIST_ABS;
+			rlist = (char **)talloc_realloc(mem_ctx, list, ((sizeof(char **)) * (lsize +1)));
+			if (!rlist) {
+				DEBUG(0,("str_list_make: Unable to allocate memory"));
+				SAFE_FREE(s);
+				return NULL;
+			} else
+				list = rlist;
+			memset (&list[num], 0, ((sizeof(char**)) * (S_LIST_ABS +1)));
+		}
+		
+		list[num] = talloc_strdup(mem_ctx,tok);
+		if (!list[num]) {
+			DEBUG(0,("str_list_make: Unable to allocate memory"));
+			SAFE_FREE(s);
+			return NULL;
+		}
+	
+		num++;	
+	}
+	
+	SAFE_FREE(s);
+	return list;
+}
+
 BOOL str_list_copy(char ***dest, const char **src)
 {
 	char **list, **rlist;
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Thu Dec 12 13:22:06 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 SMB_MODULE_SYMBOL(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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Thu Dec 12 13:23:10 2002
@@ -25,12 +25,12 @@
 #define CONFIG_LOGON_TIME_DEFAULT			"logon_time"
 #define CONFIG_LOGOFF_TIME_DEFAULT			"logoff_time"
 #define CONFIG_KICKOFF_TIME_DEFAULT			"kickoff_time"
-#define CONFIG_PASS_LAST_SET_TIME_DEFAULT	"pass_last_set_time"
-#define CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT	"pass_can_change_time"
-#define CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT "pass_must_change_time"
+#define CONFIG_PASS_LAST_SET_TIME_DEFAULT		"pass_last_set_time"
+#define CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT		"pass_can_change_time"
+#define CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT 		"pass_must_change_time"
 #define CONFIG_USERNAME_DEFAULT 			"username"
 #define CONFIG_DOMAIN_DEFAULT				"domain"
-#define CONFIG_NT_USERNAME_DEFAULT  		"nt_username"
+#define CONFIG_NT_USERNAME_DEFAULT  			"nt_username"
 #define CONFIG_FULLNAME_DEFAULT				"nt_fullname"
 #define CONFIG_HOME_DIR_DEFAULT				"home_dir"
 #define CONFIG_DIR_DRIVE_DEFAULT			"dir_drive"
@@ -40,8 +40,8 @@
 #define CONFIG_WORKSTATIONS_DEFAULT			"workstations"
 #define CONFIG_UNKNOWN_STR_DEFAULT			"unknown_str"
 #define CONFIG_MUNGED_DIAL_DEFAULT			"munged_dial"
-#define CONFIG_UID_DEFAULT					"uid"
-#define CONFIG_GID_DEFAULT					"gid"
+#define CONFIG_UID_DEFAULT				"uid"
+#define CONFIG_GID_DEFAULT				"gid"
 #define CONFIG_USER_SID_DEFAULT				"user_sid"
 #define CONFIG_GROUP_SID_DEFAULT			"group_sid"
 #define CONFIG_LM_PW_DEFAULT				"lm_pw"
@@ -53,11 +53,11 @@
 #define CONFIG_HOURS_LEN_DEFAULT			"hours_len"
 #define CONFIG_UNKNOWN_5_DEFAULT			"unknown_5"
 #define CONFIG_UNKNOWN_6_DEFAULT			"unknown_6"
-#define CONFIG_HOST_DEFAULT					"localhost"
-#define CONFIG_USER_DEFAULT					"samba"
-#define CONFIG_PASS_DEFAULT					""
-#define CONFIG_PORT_DEFAULT					"3306"
-#define CONFIG_DB_DEFAULT					"samba"
+#define CONFIG_HOST_DEFAULT				"localhost"
+#define CONFIG_USER_DEFAULT				"samba"
+#define CONFIG_PASS_DEFAULT				""
+#define CONFIG_PORT_DEFAULT				"3306"
+#define CONFIG_DB_DEFAULT				"samba"
 
 static int mysqlsam_debug_level = DBGC_ALL;
 
@@ -147,10 +147,7 @@ static NTSTATUS pdb_mysql_string_field(s
 
 static char * config_value(pdb_mysql_data * data, char *name, char *default_value)
 {
-	if (lp_parm_string(NULL, data->location, name))
-		return lp_parm_string(NULL, data->location, name);
-
-	return default_value;
+	return lp_parm_string(GLOBAL_SECTION_SNUM, data->location, name, default_value);
 }
 
 static char * config_value_write(pdb_mysql_data * data, char *name, char *default_value) {
@@ -1032,12 +1029,15 @@ static NTSTATUS mysqlsam_init(struct pdb
 	return NT_STATUS_OK;
 }
 
-int init_module(void);
-
-int init_module() 
+NTSTATUS SMB_MODULE_SYMBOL(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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/modules/vfs_audit.c HEAD-modules/source/modules/vfs_audit.c
--- HEAD/source/modules/vfs_audit.c	Wed Nov 13 14:10:29 2002
+++ HEAD-modules/source/modules/vfs_audit.c	Fri Dec 13 09:21:15 2002
@@ -4,6 +4,7 @@
  *
  * Copyright (C) Tim Potter, 1999-2000
  * Copyright (C) Alexander Bokovoy, 2002
+ * Copyright (C) Stefan (metze) Metzmacher
  *
  * 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
@@ -38,14 +39,6 @@
 #include <includes.h>
 #include <vfs.h>
 
-#ifndef SYSLOG_FACILITY
-#define SYSLOG_FACILITY   LOG_USER
-#endif
-
-#ifndef SYSLOG_PRIORITY
-#define SYSLOG_PRIORITY   LOG_NOTICE
-#endif
-
 /* Function prototypes */
 
 static int audit_connect(struct connection_struct *conn, const char *svc, const char *user);
@@ -62,83 +55,119 @@ static int audit_chmod_acl(struct connec
 static int audit_fchmod(struct files_struct *fsp, int fd, mode_t mode);
 static int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode);
 
-/* VFS operations */
+/* our vfs module id 
+ * for finding us in conn->objects 
+ */
+static int audit_module_id = (-1);
+
+static int audit_syslog_facility(struct connection_struct *conn)
+{
+	/* fix me: let this be configurable by:
+	 *	lp_param_enum(SNUM(conn),"vfs_audit","syslog facility",
+	 *		audit_enum_facility,LOG_USER); 
+	 */
+	return LOG_USER;
+}
+
+static int audit_syslog_priority(struct connection_struct *conn)
+{
+	/* fix me: let this be configurable by:
+	 *	lp_param_enum(SNUM(conn),"vfs_audit","syslog priority",
+	 *		audit_enum_priority,LOG_USER); 
+	 */
+	return LOG_NOTICE;
+}
 
-static struct vfs_ops default_vfs_ops;   /* For passthrough operation */
-static struct smb_vfs_handle_struct *audit_handle;
+static struct vfs_ops *audit_get_def_vfs_ops(struct connection_struct *conn)
+{
+	return vfs_get_default_ops(conn,audit_module_id);	
+}
+
+/* VFS operations */
 
-static vfs_op_tuple audit_ops[] = {
+static vfs_op_tuple audit_op_tuples[] = {
     
 	/* Disk operations */
 
-	{audit_connect, 	SMB_VFS_OP_CONNECT, 	SMB_VFS_LAYER_LOGGER},
-	{audit_disconnect, 	SMB_VFS_OP_DISCONNECT, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_connect), 	SMB_VFS_OP_CONNECT, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_disconnect), 	SMB_VFS_OP_DISCONNECT, 	SMB_VFS_LAYER_LOGGER},
 
 	/* Directory operations */
 
-	{audit_opendir, 	SMB_VFS_OP_OPENDIR, 	SMB_VFS_LAYER_LOGGER},
-	{audit_mkdir, 		SMB_VFS_OP_MKDIR, 	SMB_VFS_LAYER_LOGGER},
-	{audit_rmdir, 		SMB_VFS_OP_RMDIR, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_opendir), 	SMB_VFS_OP_OPENDIR, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_mkdir), 		SMB_VFS_OP_MKDIR, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_rmdir), 		SMB_VFS_OP_RMDIR, 	SMB_VFS_LAYER_LOGGER},
 
 	/* File operations */
 
-	{audit_open, 		SMB_VFS_OP_OPEN, 	SMB_VFS_LAYER_LOGGER},
-	{audit_close, 		SMB_VFS_OP_CLOSE, 	SMB_VFS_LAYER_LOGGER},
-	{audit_rename, 		SMB_VFS_OP_RENAME, 	SMB_VFS_LAYER_LOGGER},
-	{audit_unlink, 		SMB_VFS_OP_UNLINK, 	SMB_VFS_LAYER_LOGGER},
-	{audit_chmod, 		SMB_VFS_OP_CHMOD, 	SMB_VFS_LAYER_LOGGER},
-	{audit_fchmod, 		SMB_VFS_OP_FCHMOD, 	SMB_VFS_LAYER_LOGGER},
-	{audit_chmod_acl, 	SMB_VFS_OP_CHMOD_ACL, 	SMB_VFS_LAYER_LOGGER},
-	{audit_fchmod_acl, 	SMB_VFS_OP_FCHMOD_ACL, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_open), 		SMB_VFS_OP_OPEN, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_close), 		SMB_VFS_OP_CLOSE, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_rename), 		SMB_VFS_OP_RENAME, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_unlink), 		SMB_VFS_OP_UNLINK, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_chmod), 		SMB_VFS_OP_CHMOD, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_fchmod), 		SMB_VFS_OP_FCHMOD, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_chmod_acl), 	SMB_VFS_OP_CHMOD_ACL, 	SMB_VFS_LAYER_LOGGER},
+	{VFS_OP(audit_fchmod_acl), 	SMB_VFS_OP_FCHMOD_ACL, 	SMB_VFS_LAYER_LOGGER},
 	
 	/* Finish VFS operations definition */
 	
 	{NULL, 			SMB_VFS_OP_NOOP, 	SMB_VFS_LAYER_NOOP}
 };
 
-/* VFS initialisation function.  Return vfs_op_tuple array back to SAMBA. */
-
-vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, 
-			struct smb_vfs_handle_struct *vfs_handle)
-{
-	*vfs_version = SMB_VFS_INTERFACE_VERSION;
-	memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops));
-	
-	audit_handle = vfs_handle;
-
-	openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY);
-	syslog(SYSLOG_PRIORITY, "VFS_INIT: vfs_ops loaded\n");
-	return audit_ops;
-}
-
-/* VFS finalization function. */
-void vfs_done(connection_struct *conn)
-{
-	syslog(SYSLOG_PRIORITY, "VFS_DONE: vfs module unloaded\n");
-}
-
 /* Implementation of vfs_ops.  Pass everything on to the default
    operation but log event first. */
 
 static int audit_connect(struct connection_struct *conn, const char *svc, const char *user)
 {
-	syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n", 
+	struct vfs_ops *default_vfs_ops;
+	int ret;
+	
+	openlog("smbd_audit", LOG_PID, audit_syslog_facility(conn));
+
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	syslog(audit_syslog_priority(conn), "connect to service %s by user %s\n", 
 	       svc, user);
 
-	return default_vfs_ops.connect(conn, svc, user);
+	ret = default_vfs_ops->connect(conn, svc, user);
+
+	return ret;
 }
 
 static void audit_disconnect(struct connection_struct *conn)
 {
-	syslog(SYSLOG_PRIORITY, "disconnected\n");
-	default_vfs_ops.disconnect(conn);
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return;
+	}
+	
+	syslog(audit_syslog_priority(conn), "disconnected\n");
+	default_vfs_ops->disconnect(conn);
+
+	return;
 }
 
 static DIR *audit_opendir(struct connection_struct *conn, const char *fname)
 {
-	DIR *result = default_vfs_ops.opendir(conn, fname);
+	DIR *result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return NULL;
+	}
+	
+	result = default_vfs_ops->opendir(conn, fname);
 
-	syslog(SYSLOG_PRIORITY, "opendir %s %s%s\n",
+	syslog(audit_syslog_priority(conn), "opendir %s %s%s\n",
 	       fname,
 	       (result == NULL) ? "failed: " : "",
 	       (result == NULL) ? strerror(errno) : "");
@@ -148,9 +177,18 @@ static DIR *audit_opendir(struct connect
 
 static int audit_mkdir(struct connection_struct *conn, const char *path, mode_t mode)
 {
-	int result = default_vfs_ops.mkdir(conn, path, mode);
-
-	syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n", 
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->mkdir(conn, path, mode);
+	
+	syslog(audit_syslog_priority(conn), "mkdir %s %s%s\n", 
 	       path,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -160,9 +198,18 @@ static int audit_mkdir(struct connection
 
 static int audit_rmdir(struct connection_struct *conn, const char *path)
 {
-	int result = default_vfs_ops.rmdir(conn, path);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->rmdir(conn, path);
 
-	syslog(SYSLOG_PRIORITY, "rmdir %s %s%s\n", 
+	syslog(audit_syslog_priority(conn), "rmdir %s %s%s\n", 
 	       path, 
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -172,9 +219,18 @@ static int audit_rmdir(struct connection
 
 static int audit_open(struct connection_struct *conn, const char *fname, int flags, mode_t mode)
 {
-	int result = default_vfs_ops.open(conn, fname, flags, mode);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->open(conn, fname, flags, mode);
 
-	syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n", 
+	syslog(audit_syslog_priority(conn), "open %s (fd %d) %s%s%s\n", 
 	       fname, result,
 	       ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", 
 	       (result < 0) ? "failed: " : "",
@@ -185,9 +241,18 @@ static int audit_open(struct connection_
 
 static int audit_close(struct files_struct *fsp, int fd)
 {
-	int result = default_vfs_ops.close(fsp, fd);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(fsp->conn))==NULL) {
+		syslog(audit_syslog_priority(fsp->conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(fsp->conn)),SNUM(fsp->conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->close(fsp, fd);
 
-	syslog(SYSLOG_PRIORITY, "close fd %d %s%s\n",
+	syslog(audit_syslog_priority(fsp->conn), "close fd %d %s%s\n",
 	       fd,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -197,9 +262,18 @@ static int audit_close(struct files_stru
 
 static int audit_rename(struct connection_struct *conn, const char *old, const char *new)
 {
-	int result = default_vfs_ops.rename(conn, old, new);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->rename(conn, old, new);
 
-	syslog(SYSLOG_PRIORITY, "rename %s -> %s %s%s\n",
+	syslog(audit_syslog_priority(conn), "rename %s -> %s %s%s\n",
 	       old, new,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -209,9 +283,18 @@ static int audit_rename(struct connectio
 
 static int audit_unlink(struct connection_struct *conn, const char *path)
 {
-	int result = default_vfs_ops.unlink(conn, path);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->unlink(conn, path);
 
-	syslog(SYSLOG_PRIORITY, "unlink %s %s%s\n",
+	syslog(audit_syslog_priority(conn), "unlink %s %s%s\n",
 	       path,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -221,9 +304,18 @@ static int audit_unlink(struct connectio
 
 static int audit_chmod(struct connection_struct *conn, const char *path, mode_t mode)
 {
-	int result = default_vfs_ops.chmod(conn, path, mode);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->chmod(conn, path, mode);
 
-	syslog(SYSLOG_PRIORITY, "chmod %s mode 0x%x %s%s\n",
+	syslog(audit_syslog_priority(conn), "chmod %s mode 0x%x %s%s\n",
 	       path, mode,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -233,9 +325,18 @@ static int audit_chmod(struct connection
 
 static int audit_chmod_acl(struct connection_struct *conn, const char *path, mode_t mode)
 {
-	int result = default_vfs_ops.chmod_acl(conn, path, mode);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(conn))==NULL) {
+		syslog(audit_syslog_priority(conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(conn)),SNUM(conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->chmod_acl(conn, path, mode);
 
-	syslog(SYSLOG_PRIORITY, "chmod_acl %s mode 0x%x %s%s\n",
+	syslog(audit_syslog_priority(conn), "chmod_acl %s mode 0x%x %s%s\n",
 	       path, mode,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -245,9 +346,18 @@ static int audit_chmod_acl(struct connec
 
 static int audit_fchmod(struct files_struct *fsp, int fd, mode_t mode)
 {
-	int result = default_vfs_ops.fchmod(fsp, fd, mode);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(fsp->conn))==NULL) {
+		syslog(audit_syslog_priority(fsp->conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(fsp->conn)),SNUM(fsp->conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->fchmod(fsp, fd, mode);
 
-	syslog(SYSLOG_PRIORITY, "fchmod %s mode 0x%x %s%s\n",
+	syslog(audit_syslog_priority(fsp->conn), "fchmod %s mode 0x%x %s%s\n",
 	       fsp->fsp_name, mode,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
@@ -257,12 +367,41 @@ static int audit_fchmod(struct files_str
 
 static int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode)
 {
-	int result = default_vfs_ops.fchmod_acl(fsp, fd, mode);
+	int result;
+	struct vfs_ops *default_vfs_ops;
+	
+	if ((default_vfs_ops = audit_get_def_vfs_ops(fsp->conn))==NULL) {
+		syslog(audit_syslog_priority(fsp->conn),"can't get default ops for service '%s' [%d]\n",
+			lp_servicename(SNUM(fsp->conn)),SNUM(fsp->conn));
+		return (-1);
+	}
+	
+	result = default_vfs_ops->fchmod_acl(fsp, fd, mode);
 
-	syslog(SYSLOG_PRIORITY, "fchmod_acl %s mode 0x%x %s%s\n",
+	syslog(audit_syslog_priority(fsp->conn), "fchmod_acl %s mode 0x%x %s%s\n",
 	       fsp->fsp_name, mode,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
 
 	return result;
+}
+
+NTSTATUS SMB_MODULE_SYMBOL(SMB_MODULE_TYPES types) 
+{
+	static NTSTATUS nt_status = NT_STATUS_OK;
+	static BOOL init = False;
+	
+	if (init)
+		return nt_status;
+
+	if (types & MODULE_TYPE_VFS) {
+		init = True;
+
+		nt_status = smb_register_vfs("audit", audit_op_tuples, &audit_module_id, SMB_VFS_INTERFACE_VERSION);
+		if (NT_STATUS_IS_ERR(nt_status)) {
+			return nt_status;	
+		}
+	}
+
+	return nt_status;
 }
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/modules/vfs_netatalk.c HEAD-modules/source/modules/vfs_netatalk.c
--- HEAD/source/modules/vfs_netatalk.c	Wed Nov 13 14:10:29 2002
+++ HEAD-modules/source/modules/vfs_netatalk.c	Thu Dec 12 13:20:15 2002
@@ -410,21 +410,36 @@ static vfs_op_tuple atalk_ops[] = {
 	{NULL, 			SMB_VFS_OP_NOOP, 	SMB_VFS_LAYER_NOOP}
 };
 
-/* VFS initialisation function.  Return vfs_op_tuple array back to SAMBA. */
-vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops,
-  struct smb_vfs_handle_struct *vfs_handle)
-{
-	*vfs_version = SMB_VFS_INTERFACE_VERSION;
-	memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops));
+static vfs_op_tuple atalk_op_tuples[] = {
+    
+	/* FIXME: the module is brocken */
+
+	/* Finish VFS operations definition */
 	
-	atalk_handle = vfs_handle;
+	{NULL, 			SMB_VFS_OP_NOOP, 	SMB_VFS_LAYER_NOOP}
+};
 
+/* VFS initialisation function.  Return vfs_op_tuple array back to SAMBA. */
+vfs_op_tuple *vfs_nettalk_init(struct connection_struct *conn, struct vfs_ops *def_vfs_ops)
+{
 	DEBUG(3, ("ATALK: vfs module loaded\n"));
 	return atalk_ops;
 }
 
-/* VFS finalization function. */
-void vfs_done(connection_struct *conn)
+NTSTATUS SMB_MODULE_SYMBOL(SMB_MODULE_TYPES types) 
 {
-	DEBUG(3, ("ATALK: vfs module unloaded\n"));
+	NTSTATUS nt_status = NT_STATUS_OK;
+	if (types & MODULE_TYPE_VFS) {
+		DEBUG(0,("ATALK: module vfs_nettalk (nettalk.so) is broken with the update to SMB_VFS_INTERFACE_VERSION == %d\n",SMB_VFS_INTERFACE_VERSION));
+		DEBUGADD(0,("if anyone is able to fix and test it please send a mail to <samba-technical at lists.samba.org>\n")); 
+		return NT_STATUS_NOT_IMPLEMENTED;
+		
+		/* nt_status = smb_register_vfs("nettalk", atalk_op_tuples, NULL, SMB_VFS_INTERFACE_VERSION);
+		if (NT_STATUS_IS_ERR(nt_status)) {
+			return nt_status;	
+		}
+		*/
+	}
+	
+	return nt_status;
 }
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/modules/vfs_recycle.c HEAD-modules/source/modules/vfs_recycle.c
--- HEAD/source/modules/vfs_recycle.c	Mon Dec  9 16:53:06 2002
+++ HEAD-modules/source/modules/vfs_recycle.c	Fri Dec 13 09:23:06 2002
@@ -6,6 +6,7 @@
  * Copyright (C) 2002, Alexander Bokovoy - cascaded VFS adoption,
  * Copyright (C) 2002, Juergen Hasch - added some options.
  * Copyright (C) 2002, Simo Sorce
+ * Copyright (C) 2002, Stefan (metze) Metzmacher
  *
  * 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
@@ -24,53 +25,21 @@
 
 #include "includes.h"
 
-#define ALLOC_CHECK(ptr, label) do { if ((ptr) == NULL) { DEBUG(0, ("recycle.bin: out of memory!\n")); errno = ENOMEM; goto label; } } while(0)
+#define ALLOC_CHECK(ptr, label) do { if ((ptr) == NULL) { DEBUG(0, ("recycle_bin: out of memory!\n")); errno = ENOMEM; goto label; } } while(0)
 
-static int vfs_recycle_debug_level = DBGC_VFS;
+static int recycle_debug_level = DBGC_VFS;
 
 #undef DBGC_CLASS
-#define DBGC_CLASS vfs_recycle_debug_level
+#define DBGC_CLASS recycle_debug_level
 
 static const char *delimiter = "|";		/* delimiter for options */
 
-/* One per connection */
-
-typedef struct recycle_bin_struct
-{
-	TALLOC_CTX *mem_ctx;
-	char	*repository;		/* name of the recycle bin directory */
-	BOOL	keep_dir_tree;		/* keep directory structure of deleted file in recycle bin */
-	BOOL	versions;		/* create versions of deleted files with identical name */
-	BOOL	touch;			/* touch access date of deleted file */
-	char	*exclude;		/* which files to exclude */
-	char	*exclude_dir;		/* which directories to exclude */
-	char	*noversions;		/* which files to exclude from versioning */
-	SMB_OFF_T maxsize;		/* maximum file size to be saved */
-} recycle_bin_struct;
-
-typedef struct recycle_bin_connections {
-	int conn;
-	recycle_bin_struct *data;
-	struct recycle_bin_connections *next;
-} recycle_bin_connections;
-
-typedef struct recycle_bin_private_data {
-	TALLOC_CTX *mem_ctx;
-	recycle_bin_connections *conns;
-} recycle_bin_private_data;
-
-struct smb_vfs_handle_struct *recycle_bin_private_handle;
-
-/* VFS operations */
-static struct vfs_ops default_vfs_ops;   /* For passthrough operation */
 
 static int recycle_connect(struct connection_struct *conn, const char *service, const char *user);
 static void recycle_disconnect(struct connection_struct *conn);
 static int recycle_unlink(connection_struct *, const char *);
 
-#define VFS_OP(x) ((void *) x)
-
-static vfs_op_tuple recycle_ops[] = {
+static vfs_op_tuple recycle_op_tuples[] = {
 
 	/* Disk operations */
 	{VFS_OP(recycle_connect),	SMB_VFS_OP_CONNECT,	SMB_VFS_LAYER_TRANSPARENT},
@@ -82,221 +51,148 @@ static vfs_op_tuple recycle_ops[] = {
 	{NULL,				SMB_VFS_OP_NOOP,	SMB_VFS_LAYER_NOOP}
 };
 
-/**
- * VFS initialisation function.
- *
- * @retval initialised vfs_op_tuple array
- **/
-vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops,
-			struct smb_vfs_handle_struct *vfs_handle)
+/* our vfs module id 
+ * for finding us in conn->objects 
+ */
+static int recycle_module_id = (-1);
+
+static struct vfs_ops *recycle_get_def_vfs_ops(struct connection_struct *conn)
 {
-	TALLOC_CTX *mem_ctx = NULL;
+	return vfs_get_default_ops(conn,recycle_module_id);	
+}
 
-	DEBUG(10, ("Initializing VFS module recycle\n"));
-	*vfs_version = SMB_VFS_INTERFACE_VERSION;
-	memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops));
-	vfs_recycle_debug_level = debug_add_class("vfs_recycle_bin");
-	if (vfs_recycle_debug_level == -1) {
-		vfs_recycle_debug_level = DBGC_VFS;
-		DEBUG(0, ("vfs_recycle: Couldn't register custom debugging class!\n"));
-	} else {
-		DEBUG(0, ("vfs_recycle: Debug class number of 'vfs_recycle': %d\n", vfs_recycle_debug_level));
-	}
+static const char *recycle_repository(struct connection_struct *conn)
+{
+	char *tmp_str = NULL;
+	
+	tmp_str = lp_parm_string(SNUM(conn), "recycle_bin", "repository",".recycle");
 
-	recycle_bin_private_handle = vfs_handle;
-	if (!(mem_ctx = talloc_init_named("recycle bin data"))) {
-		DEBUG(0, ("Failed to allocate memory in VFS module recycle_bin\n"));
-		return NULL;
-	}
+	DEBUG(10, ("recycle_bin: repository = %s\n", tmp_str));
+	
+	return tmp_str;
+}
 
-	recycle_bin_private_handle->data = talloc(mem_ctx, sizeof(recycle_bin_private_data));
-	if (recycle_bin_private_handle->data == NULL) {
-		DEBUG(0, ("Failed to allocate memory in VFS module recycle_bin\n"));
-		return NULL;
-	}
-	((recycle_bin_private_data *)(recycle_bin_private_handle->data))->mem_ctx = mem_ctx;
-	((recycle_bin_private_data *)(recycle_bin_private_handle->data))->conns = NULL;
+static BOOL recycle_keep_dir_tree(struct connection_struct *conn)
+{
+	BOOL ret;
+	
+	ret = lp_parm_bool(SNUM(conn), "recycle_bin", "keeptree",False);
 
-	return recycle_ops;
+	DEBUG(10, ("recycle_bin: keeptree = %s\n", ret?"True":"False"));
+	
+	return ret;
 }
 
-/**
- * VFS finalization function.
- *
- **/
-void vfs_done(void)
+static BOOL recycle_versions(struct connection_struct *conn)
 {
-	recycle_bin_private_data *recdata;
-	recycle_bin_connections *recconn;
+	BOOL ret;
+	
+	ret = lp_parm_bool(SNUM(conn), "recycle_bin", "versions",False);
 
-	DEBUG(10, ("Unloading/Cleaning VFS module recycle bin\n"));
+	DEBUG(10, ("recycle_bin: versions = %s\n", ret?"True":"False"));
+	
+	return ret;
+}
 
-	if (recycle_bin_private_handle)
-		recdata = (recycle_bin_private_data *)(recycle_bin_private_handle->data);
-	else {
-		DEBUG(0, ("Recycle bin not initialized!\n"));
-		return;
-	}
+static BOOL recycle_touch(struct connection_struct *conn)
+{
+	BOOL ret;
+	
+	ret = lp_parm_bool(SNUM(conn), "recycle_bin", "touch",False);
 
-	if (recdata) {
-		if (recdata->conns) {
-			recconn = recdata->conns;
-			while (recconn) {
-				talloc_destroy(recconn->data->mem_ctx);
-				recconn = recconn->next;
-			}
-		}
-		if (recdata->mem_ctx) {
-			talloc_destroy(recdata->mem_ctx);
-		}
-		recdata = NULL;
-	}
+	DEBUG(10, ("recycle_bin: touch = %s\n", ret?"True":"False"));
+	
+	return ret;
 }
 
-static int recycle_connect(struct connection_struct *conn, const char *service, const char *user)
+static const char **recycle_exclude(struct connection_struct *conn)
 {
-	TALLOC_CTX *ctx = NULL;
-	recycle_bin_struct *recbin;
-	recycle_bin_connections *recconn;
-	recycle_bin_connections *recconnbase;
-	recycle_bin_private_data *recdata;
-	char *tmp_str;
+	const char **tmp_lp;
+	
+	tmp_lp = lp_parm_string_list(SNUM(conn), "recycle_bin", "exclude",delimiter,NULL);
 
-	DEBUG(10, ("Called for service %s (%d) as user %s\n", service, SNUM(conn), user));
+	DEBUG(10, ("recycle_bin: exclude = %s ...\n", tmp_lp?*tmp_lp:""));
+	
+	return tmp_lp;
+}
 
-	if (recycle_bin_private_handle)
-		recdata = (recycle_bin_private_data *)(recycle_bin_private_handle->data);
-	else {
-		DEBUG(0, ("Recycle bin not initialized!\n"));
-		return -1;
-	}
+static const char **recycle_exclude_dir(struct connection_struct *conn)
+{
+	const char **tmp_lp;
+	
+	tmp_lp = lp_parm_string_list(SNUM(conn), "recycle_bin", "exclude_dir",delimiter,NULL);
 
-	if (!(ctx = talloc_init_named("recycle bin connection"))) {
-		DEBUG(0, ("Failed to allocate memory in VFS module recycle_bin\n"));
-		return -1;
-	}
-
-	recbin = talloc(ctx, sizeof(recycle_bin_struct));
-	if (recbin == NULL) {
-		DEBUG(0, ("Failed to allocate memory in VFS module recycle_bin\n"));
-		return -1;
-	}
-	recbin->mem_ctx = ctx;
-
-	/* Set defaults */
-	recbin->repository = talloc_strdup(recbin->mem_ctx, ".recycle");
-	ALLOC_CHECK(recbin->repository, error);
-	recbin->keep_dir_tree = False;
-	recbin->versions = False;
-	recbin->touch = False;
-	recbin->exclude = "";
-	recbin->exclude_dir = "";
-	recbin->noversions = "";
-	recbin->maxsize = 0;
-
-	/* parse configuration options */
-	if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "repository")) != NULL) {
-		recbin->repository = talloc_sub_conn(recbin->mem_ctx, conn, tmp_str);
-		ALLOC_CHECK(recbin->repository, error);
-		trim_string(recbin->repository, "/", "/");
-		DEBUG(5, ("recycle.bin: repository = %s\n", recbin->repository));
-	}
-	
-	recbin->keep_dir_tree = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "keeptree");
-	DEBUG(5, ("recycle.bin: keeptree = %d\n", recbin->keep_dir_tree));
-	
-	recbin->versions = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "versions");
-	DEBUG(5, ("recycle.bin: versions = %d\n", recbin->versions));
-	
-	recbin->touch = lp_parm_bool(SNUM(conn), "vfs_recycle_bin", "touch");
-	DEBUG(5, ("recycle.bin: touch = %d\n", recbin->touch));
-
-	recbin->maxsize = lp_parm_ulong(SNUM(conn), "vfs_recycle_bin", "maxsize");
-	if (recbin->maxsize == 0) {
-		recbin->maxsize = -1;
-		DEBUG(5, ("recycle.bin: maxsize = -infinite-\n"));
-	} else {
-		DEBUG(5, ("recycle.bin: maxsize = %ld\n", (long int)recbin->maxsize));
-	}
+	DEBUG(10, ("recycle_bin: exclude_dir = %s ...\n", tmp_lp?*tmp_lp:""));
+	
+	return tmp_lp;
+}
 
-	if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "exclude")) != NULL) {
-		recbin->exclude = talloc_strdup(recbin->mem_ctx, tmp_str);
-		ALLOC_CHECK(recbin->exclude, error);
-		DEBUG(5, ("recycle.bin: exclude = %s\n", recbin->exclude));
-	}
-	if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "exclude_dir")) != NULL) {
-		recbin->exclude_dir = talloc_strdup(recbin->mem_ctx, tmp_str);
-		ALLOC_CHECK(recbin->exclude_dir, error);
-		DEBUG(5, ("recycle.bin: exclude_dir = %s\n", recbin->exclude_dir));
-	}
-	if ((tmp_str = lp_parm_string(SNUM(conn), "vfs_recycle_bin", "noversions")) != NULL) {
-		recbin->noversions = talloc_strdup(recbin->mem_ctx, tmp_str);
-		ALLOC_CHECK(recbin->noversions, error);
-		DEBUG(5, ("recycle.bin: noversions = %s\n", recbin->noversions));
-	}
-
-	recconn = talloc(recdata->mem_ctx, sizeof(recycle_bin_connections));
-	if (recconn == NULL) {
-		DEBUG(0, ("Failed to allocate memory in VFS module recycle_bin\n"));
-		goto error;
-	}
-	recconn->conn = SNUM(conn);
-	recconn->data = recbin;
-	recconn->next = NULL;
-	if (recdata->conns) {
-		recconnbase = recdata->conns;
-		while (recconnbase->next != NULL) recconnbase = recconnbase->next;
-		recconnbase->next = recconn;
-	} else {
-		recdata->conns = recconn;
+static const char **recycle_noversions(struct connection_struct *conn)
+{
+	const char **tmp_lp;
+	
+	tmp_lp = lp_parm_string_list(SNUM(conn), "recycle_bin", "noversions",delimiter,NULL);
+
+	DEBUG(10, ("recycle_bin: noversions = %s\n", tmp_lp?*tmp_lp:""));
+	
+	return tmp_lp;
+}
+
+static int recycle_maxsize(struct connection_struct *conn)
+{
+	int maxsize;
+	
+	maxsize = lp_parm_int(SNUM(conn), "recycle_bin", "maxsize",0);
+
+	DEBUG(10, ("recycle_bin: maxsize = %d\n", maxsize));
+	
+	return maxsize;
+}
+
+static int recycle_connect(struct connection_struct *conn, const char *service, const char *user)
+{
+	struct vfs_ops *default_vfs_ops;
+	int ret;
+	
+	DEBUG(10, ("recycle_bin: Connect to service %s (%d) as user %s\n", service, SNUM(conn), user));
+
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
+		return (-1);
 	}
-	return default_vfs_ops.connect(conn, service, user);
 
-error:
-	talloc_destroy(ctx);
-	return -1;
+	ret = default_vfs_ops->connect(conn, service, user);
+
+	return ret;
 }
 
 static void recycle_disconnect(struct connection_struct *conn)
 {
-	recycle_bin_private_data *recdata;
-	recycle_bin_connections *recconn;
-
-	DEBUG(10, ("Disconnecting VFS module recycle bin\n"));
+	struct vfs_ops *default_vfs_ops;
+	
+	DEBUG(10, ("Disconnecting VFS module recycle_bin\n"));
 
-	if (recycle_bin_private_handle)
-		recdata = (recycle_bin_private_data *)(recycle_bin_private_handle->data);
-	else {
-		DEBUG(0, ("Recycle bin not initialized!\n"));
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
 		return;
 	}
 
-	if (recdata) {
-		if (recdata->conns) {
-			if (recdata->conns->conn == SNUM(conn)) {
-				talloc_destroy(recdata->conns->data->mem_ctx);
-				recdata->conns = recdata->conns->next;
-			} else {
-				recconn = recdata->conns;
-				while (recconn->next) {
-					if (recconn->next->conn == SNUM(conn)) {
-						talloc_destroy(recconn->next->data->mem_ctx);
-						recconn->next = recconn->next->next;
-						break;
-					}
-					recconn = recconn->next;
-				}
-			}
-		}
-	}
-	default_vfs_ops.disconnect(conn);
+	default_vfs_ops->disconnect(conn);
+
+	return;
 }
 
 static BOOL recycle_directory_exist(connection_struct *conn, const char *dname)
 {
 	SMB_STRUCT_STAT st;
+	struct vfs_ops *default_vfs_ops;
 
-	if (default_vfs_ops.stat(conn, dname, &st) == 0) {
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
+		return False;
+	}
+
+	if (default_vfs_ops->stat(conn, dname, &st) == 0) {
 		if (S_ISDIR(st.st_mode)) {
 			return True;
 		}
@@ -308,8 +204,14 @@ static BOOL recycle_directory_exist(conn
 static BOOL recycle_file_exist(connection_struct *conn, const char *fname)
 {
 	SMB_STRUCT_STAT st;
+	struct vfs_ops *default_vfs_ops;
 
-	if (default_vfs_ops.stat(conn, fname, &st) == 0) {
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
+		return False;
+	}
+
+	if (default_vfs_ops->stat(conn, fname, &st) == 0) {
 		if (S_ISREG(st.st_mode)) {
 			return True;
 		}
@@ -327,10 +229,18 @@ static BOOL recycle_file_exist(connectio
 static SMB_OFF_T recycle_get_file_size(connection_struct *conn, const char *fname)
 {
 	SMB_STRUCT_STAT st;
-	if (default_vfs_ops.stat(conn, fname, &st) != 0) {
-		DEBUG(0,("recycle.bin: stat for %s returned %s\n", fname, strerror(errno)));
+	struct vfs_ops *default_vfs_ops;
+
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
 		return (SMB_OFF_T)0;
 	}
+
+	if (default_vfs_ops->stat(conn, fname, &st) != 0) {
+		DEBUG(0,("recycle_bin: stat for %s returned %s\n", fname, strerror(errno)));
+		return (SMB_OFF_T)0;
+	}
+
 	return(st.st_size);
 }
 
@@ -349,6 +259,12 @@ static BOOL recycle_create_dir(connectio
 	char *token;
 	char *tok_str;
 	BOOL ret = False;
+	struct vfs_ops *default_vfs_ops;
+
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
+		return False;
+	}
 
 	mode = S_IREAD | S_IWRITE | S_IEXEC;
 
@@ -365,10 +281,10 @@ static BOOL recycle_create_dir(connectio
 	for(token = strtok(tok_str, "/"); token; token = strtok(NULL, "/")) {
 		safe_strcat(new_dir, token, len);
 		if (recycle_directory_exist(conn, new_dir))
-			DEBUG(10, ("recycle.bin: dir %s already exists\n", new_dir));
+			DEBUG(10, ("recycle_bin: dir %s already exists\n", new_dir));
 		else {
 			DEBUG(5, ("recycle.bin: creating new dir %s\n", new_dir));
-			if (default_vfs_ops.mkdir(conn, new_dir, mode) != 0) {
+			if (default_vfs_ops->mkdir(conn, new_dir, mode) != 0) {
 				DEBUG(1,("recycle.bin: mkdir failed for %s with error: %s\n", new_dir, strerror(errno)));
 				ret = False;
 				goto done;
@@ -390,30 +306,21 @@ done:
  * @param needle string to be matched exactly to haystack
  * @return True if found
  **/
-static BOOL checkparam(const char *haystack, const char *needle)
+static BOOL checkparam(const char **haystack_list, const char *needle)
 {
-	char *token;
-	char *tok_str;
-	char *tmp_str;
-	BOOL ret = False;
+	int i;
 
-	if (haystack == NULL || strlen(haystack) == 0 || needle == NULL || strlen(needle) == 0) {
+	if (haystack_list == NULL || strlen(*haystack_list) == 0 || needle == NULL || strlen(needle) == 0) {
 		return False;
 	}
 
-	tmp_str = strdup(haystack);
-	ALLOC_CHECK(tmp_str, done);
-	token = tok_str = tmp_str;
-
-	for(token = strtok(tok_str, delimiter); token; token = strtok(NULL, delimiter)) {
-		if(strcmp(token, needle) == 0) {
-			ret = True;
-			goto done;
+	for(i=0; haystack_list[i] ; i++) {
+		if(strequal(haystack_list[i], needle)) {
+			return True;
 		}
 	}
-done:
-	SAFE_FREE(tmp_str);
-	return ret;
+
+	return False;
 }
 
 /**
@@ -422,42 +329,39 @@ done:
  * @param needle string to be matched exectly to haystack including pattern matching
  * @return True if found
  **/
-static BOOL matchparam(const char *haystack, const char *needle)
+static BOOL matchparam(const char **haystack_list, const char *needle)
 {
-	char *token;
-	char *tok_str;
-	char *tmp_str;
-	BOOL ret = False;
+	int i;
 
-	if (haystack == NULL || strlen(haystack) == 0 || needle == NULL || strlen(needle) == 0) {
+	if (haystack_list == NULL || strlen(*haystack_list) == 0 || needle == NULL || strlen(needle) == 0) {
 		return False;
 	}
 
-	tmp_str = strdup(haystack);
-	ALLOC_CHECK(tmp_str, done);
-	token = tok_str = tmp_str;
-
-	for(token = strtok(tok_str, delimiter); token; token = strtok(NULL, delimiter)) {
-		if (!unix_wild_match(token, needle)) {
-			ret = True;
-			goto done;
+	for(i=0; haystack_list[i] ; i++) {
+		if(!unix_wild_match((char *)haystack_list[i], (char *)needle)) {
+			return True;
 		}
 	}
-done:
-	SAFE_FREE(tmp_str);
-	return ret;
+
+	return False;
 }
 
 /**
  * Touch access date
  **/
-static void recycle_touch(connection_struct *conn, const char *fname)
+static void recycle_do_touch(struct connection_struct *conn, const char *fname)
 {
 	SMB_STRUCT_STAT st;
 	struct utimbuf tb;
 	time_t currtime;
+	struct vfs_ops *default_vfs_ops;
+
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
+		return;
+	}
 
-	if (default_vfs_ops.stat(conn, fname, &st) != 0) {
+	if (default_vfs_ops->stat(conn, fname, &st) != 0) {
 		DEBUG(0,("recycle.bin: stat for %s returned %s\n", fname, strerror(errno)));
 		return;
 	}
@@ -465,61 +369,53 @@ static void recycle_touch(connection_str
 	tb.actime = currtime;
 	tb.modtime = st.st_mtime;
 
-	if (default_vfs_ops.utime(conn, fname, &tb) == -1 )
-		DEBUG(0, ("recycle.bin: touching %s failed, reason = %s\n", fname, strerror(errno)));
+	if (default_vfs_ops->utime(conn, fname, &tb) == -1 ) {
+		DEBUG(0, ("recycle_bin: touching %s failed, reason = %s\n", fname, strerror(errno)));
 	}
+}
 
 /**
  * Check if file should be recycled
  **/
 static int recycle_unlink(connection_struct *conn, const char *inname)
 {
-	recycle_bin_private_data *recdata;
-	recycle_bin_connections *recconn;
-	recycle_bin_struct *recbin;
 	char *file_name = NULL;
 	char *path_name = NULL;
        	char *temp_name = NULL;
 	char *final_name = NULL;
 	char *base;
+	char *repository = NULL;
 	int i;
+	int maxsize;
 /*	SMB_BIG_UINT dfree, dsize, bsize;	*/
 	SMB_OFF_T file_size; /* space_avail;	*/
 	BOOL exist;
 	int rc = -1;
+	struct vfs_ops *default_vfs_ops;
+
+	if ((default_vfs_ops = recycle_get_def_vfs_ops(conn))==NULL) {
+		DEBUG(0,("recycle_bin: can't get default ops for service '%s' [%d]\n",lp_servicename(SNUM(conn)),SNUM(conn)));
+		return (-1);
+	}
 
 	file_name = strdup(inname);
 	ALLOC_CHECK(file_name, done);
 
-	recbin = NULL;
-	if (recycle_bin_private_handle) {
-		recdata = (recycle_bin_private_data *)(recycle_bin_private_handle->data);
-		if (recdata) {
-			if (recdata->conns) {
-				recconn = recdata->conns;
-				while (recconn && recconn->conn != SNUM(conn)) recconn = recconn->next;
-				if (recconn != NULL) {
-					recbin = recconn->data;
-				}
-			}
-		}
-	}
-	if (recbin == NULL) {
-		DEBUG(0, ("Recycle bin not initialized!\n"));
-		rc = default_vfs_ops.unlink(conn, file_name);
-		goto done;
-	}
-
-	if(!recbin->repository || *(recbin->repository) == '\0') {
-		DEBUG(3, ("Recycle path not set, purging %s...\n", file_name));
-		rc = default_vfs_ops.unlink(conn, file_name);
+	repository = alloc_sub_conn(conn, (char *)recycle_repository(conn));
+	ALLOC_CHECK(repository, done);
+	/* shouldn't we allow absolute path names here? --metze */
+	trim_string(repository, "/", "/");
+	
+	if(!repository || *(repository) == '\0') {
+		DEBUG(3, ("recycle_bin: repository path not set, purging %s...\n", file_name));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 
 	/* we don't recycle the recycle bin... */
-	if (strncmp(file_name, recbin->repository, strlen(recbin->repository)) == 0) {
-		DEBUG(3, ("File is within recycling bin, unlinking ...\n"));
-		rc = default_vfs_ops.unlink(conn, file_name);
+	if (strncmp(file_name, repository, strlen(repository)) == 0) {
+		DEBUG(3, ("recycle_bin: File is within recycling bin, unlinking ...\n"));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 
@@ -528,8 +424,8 @@ static int recycle_unlink(connection_str
 	 *   --- simo
 	 *
 	if(fsize == 0) {
-		DEBUG(3, ("File %s is empty, purging...\n", file_name));
-		rc = default_vfs_ops.unlink(conn,file_name);
+		DEBUG(3, ("recycle_bin: File %s is empty, purging...\n", file_name));
+		rc = default_vfs_ops->unlink(conn,file_name);
 		goto done;
 	}
 	 */
@@ -538,20 +434,21 @@ static int recycle_unlink(connection_str
 	 * not greater then maxsize, not the size of the single file, also it is better
 	 * to remove older files
 	 */
-	if(recbin->maxsize > 0 && file_size > recbin->maxsize) {
-		DEBUG(3, ("File %s exceeds maximum recycle size, purging... \n", file_name));
-		rc = default_vfs_ops.unlink(conn, file_name);
+	maxsize = recycle_maxsize(conn);
+	if(maxsize > 0 && file_size > maxsize) {
+		DEBUG(3, ("recycle_bin: File %s exceeds maximum recycle size, purging... \n", file_name));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 
 	/* FIXME: this is wrong: moving files with rename does not change the disk space
 	 * allocation
 	 *
-	space_avail = default_vfs_ops.disk_free(conn, ".", True, &bsize, &dfree, &dsize) * 1024L;
+	space_avail = default_vfs_ops->disk_free(conn, ".", True, &bsize, &dfree, &dsize) * 1024L;
 	DEBUG(5, ("space_avail = %Lu, file_size = %Lu\n", space_avail, file_size));
 	if(space_avail < file_size) {
-		DEBUG(3, ("Not enough diskspace, purging file %s\n", file_name));
-		rc = default_vfs_ops.unlink(conn, file_name);
+		DEBUG(3, ("recycle_bin: Not enough diskspace, purging file %s\n", file_name));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 	 */
@@ -571,13 +468,13 @@ static int recycle_unlink(connection_str
 		base++;
 	}
 
-	DEBUG(10, ("recycle.bin: fname = %s\n", file_name));	/* original filename with path */
-	DEBUG(10, ("recycle.bin: fpath = %s\n", path_name));	/* original path */
-	DEBUG(10, ("recycle.bin: base = %s\n", base));		/* filename without path */
-
-	if (matchparam(recbin->exclude, base)) {
-		DEBUG(3, ("recycle.bin: file %s is excluded \n", base));
-		rc = default_vfs_ops.unlink(conn, file_name);
+	DEBUG(10, ("recycle_bin: fname = %s\n", file_name));	/* original filename with path */
+	DEBUG(10, ("recycle_bin: fpath = %s\n", path_name));	/* original path */
+	DEBUG(10, ("recycle_bin: base = %s\n", base));		/* filename without path */
+
+	if (matchparam(recycle_exclude(conn), base)) {
+		DEBUG(3, ("recycle_bin: file %s is excluded \n", base));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 
@@ -585,30 +482,30 @@ static int recycle_unlink(connection_str
 	 * we shoud check for every level 1, 1/2, 1/2/3, 1/2/3/4 .... 
 	 * 	---simo
 	 */
-	if (checkparam(recbin->exclude_dir, path_name)) {
-		DEBUG(3, ("recycle.bin: directory %s is excluded \n", path_name));
-		rc = default_vfs_ops.unlink(conn, file_name);
+	if (checkparam(recycle_exclude_dir(conn), path_name)) {
+		DEBUG(3, ("recycle_bin: directory %s is excluded \n", path_name));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 
 	temp_name = (char *)malloc(PATH_MAX);
 	ALLOC_CHECK(temp_name, done);
-	safe_strcpy(temp_name, recbin->repository, PATH_MAX);
+	safe_strcpy(temp_name, repository, PATH_MAX);
 
 	/* see if we need to recreate the original directory structure in the recycle bin */
-	if (recbin->keep_dir_tree == True) {
+	if (recycle_keep_dir_tree(conn) == True) {
 		safe_strcat(temp_name, "/", PATH_MAX);
 		safe_strcat(temp_name, path_name, PATH_MAX);
 	}
 
 	exist = recycle_directory_exist(conn, temp_name);
 	if (exist) {
-		DEBUG(10, ("recycle.bin: Directory already exists\n"));
+		DEBUG(10, ("recycle_bin: Directory already exists\n"));
 	} else {
-		DEBUG(10, ("recycle.bin: Creating directory %s\n", temp_name));
+		DEBUG(10, ("recycle_bin: Creating directory %s\n", temp_name));
 		if (recycle_create_dir(conn, temp_name) == False) {
-			DEBUG(3, ("Could not create directory, purging %s...\n", file_name));
-			rc = default_vfs_ops.unlink(conn, file_name);
+			DEBUG(3, ("recycle_bin: Could not create directory, purging %s...\n", file_name));
+			rc = default_vfs_ops->unlink(conn, file_name);
 			goto done;
 		}
 	}
@@ -616,14 +513,14 @@ static int recycle_unlink(connection_str
 	final_name = (char *)malloc(PATH_MAX);
 	ALLOC_CHECK(final_name, done);
 	snprintf(final_name, PATH_MAX, "%s/%s", temp_name, base);
-	DEBUG(10, ("recycle.bin: recycled file name%s\n", temp_name));		/* new filename with path */
+	DEBUG(10, ("recycle_bin: recycled file name%s\n", temp_name));		/* new filename with path */
 
 	/* check if we should delete file from recycle bin */
 	if (recycle_file_exist(conn, final_name)) {
-		if (recbin->versions == False || matchparam(recbin->noversions, base) == True) {
-			DEBUG(3, ("recycle.bin: Removing old file %s from recycle bin\n", final_name));
-			if (default_vfs_ops.unlink(conn, final_name) != 0) {
-				DEBUG(1, ("recycle.bin: Error deleting old file: %s\n", strerror(errno)));
+		if (recycle_versions(conn) == False || matchparam(recycle_noversions(conn), base) == True) {
+			DEBUG(3, ("recycle_bin: Removing old file %s from recycle bin\n", final_name));
+			if (default_vfs_ops->unlink(conn, final_name) != 0) {
+				DEBUG(1, ("recycle_bin: Error deleting old file: %s\n", strerror(errno)));
 			}
 		}
 	}
@@ -634,22 +531,54 @@ static int recycle_unlink(connection_str
 		snprintf(final_name, PATH_MAX, "%s/Copy #%d of %s", temp_name, i++, base);
 	}
 
-	DEBUG(10, ("recycle.bin: Moving %s to %s\n", file_name, final_name));
-	rc = default_vfs_ops.rename(conn, file_name, final_name);
+	DEBUG(10, ("recycle_bin: Moving %s to %s\n", file_name, final_name));
+	rc = default_vfs_ops->rename(conn, file_name, final_name);
 	if (rc != 0) {
-		DEBUG(3, ("recycle.bin: Move error %d (%s), purging file %s (%s)\n", errno, strerror(errno), file_name, final_name));
-		rc = default_vfs_ops.unlink(conn, file_name);
+		DEBUG(3, ("recycle_bin: Move error %d (%s), purging file %s (%s)\n", errno, strerror(errno), file_name, final_name));
+		rc = default_vfs_ops->unlink(conn, file_name);
 		goto done;
 	}
 
 	/* touch access date of moved file */
-	if (recbin->touch == True )
-		recycle_touch(conn, final_name);
+	if (recycle_touch(conn) == True )
+		recycle_do_touch(conn, final_name);
 
 done:
 	SAFE_FREE(file_name);
 	SAFE_FREE(path_name);
 	SAFE_FREE(temp_name);
 	SAFE_FREE(final_name);
+	SAFE_FREE(repository);
 	return rc;
 }
+
+NTSTATUS SMB_MODULE_SYMBOL(SMB_MODULE_TYPES types) 
+{
+	static BOOL init = False;
+	static NTSTATUS nt_status = NT_STATUS_OK;
+	
+	if (init)
+		return nt_status;
+		
+	if (types & MODULE_TYPE_VFS) {
+		init = True;
+		nt_status = smb_register_vfs("recycle_bin", recycle_op_tuples, &recycle_module_id, SMB_VFS_INTERFACE_VERSION);
+		if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_COLLISION,nt_status)) {
+			DEBUG(1,("recycle_bin: there's allready a vfs module registered as 'recycle_bin'!\n"));
+			return nt_status;
+		} else if (NT_STATUS_IS_ERR(nt_status)) {
+			DEBUG(0,("recycle_bin: failed to register: %s\n",nt_errstr(nt_status)));
+			return nt_status;	
+		}
+		DEBUG(1,("recycle_bin: successful registered\n"));
+		recycle_debug_level = debug_add_class("recycle_bin");
+		if (recycle_debug_level == -1) {
+			recycle_debug_level = DBGC_VFS;
+			DEBUG(0, ("recycle_bin: Couldn't register custom debugging class!\n"));
+		} else {
+			DEBUG(10, ("recycle_bin: Debug class number of 'recycle_bin': %d\n", recycle_debug_level));
+		}		
+	}
+	
+	return nt_status;
+}
\ No newline at end of file
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Thu Dec 12 13:22:42 2002
@@ -564,12 +564,15 @@ NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_c
 	return NT_STATUS_OK;
 }
 
-int init_module(void);
-
-int init_module() 
+NTSTATUS SMB_MODULE_SYMBOL(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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:13:57 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),NULL,MODULE_TYPES_NMBD);
+
   if(!init_names())
     return -1;
 
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:14:38 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),NULL,MODULE_TYPES_WINBINDD);
+
 	/* Setup names. */
 
 	if (!init_names())
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/param/loadparm.c HEAD-modules/source/param/loadparm.c
--- HEAD/source/param/loadparm.c	Thu Dec 12 20:24:27 2002
+++ HEAD-modules/source/param/loadparm.c	Thu Dec 12 21:13:21 2002
@@ -84,8 +84,11 @@ static BOOL defaults_saved = False;
 typedef struct _param_opt_struct param_opt_struct;
 struct _param_opt_struct {
 	param_opt_struct *prev, *next;
+	TALLOC_CTX *mem_ctx;
 	char *key;
 	char *value;
+	char **list;
+	char *list_sep;
 };
 
 /* 
@@ -119,7 +122,6 @@ typedef struct
 	char *szPrivateDir;
 	char **szPassdbBackend;
 	char **szSamBackend;
-	char **szModules;
 	char *szPasswordServer;
 	char *szSocketOptions;
 	char *szRealm;
@@ -325,9 +327,9 @@ typedef struct
 	char **printer_admin;
 	char *volume;
 	char *fstype;
-	char *szVfsObjectFile;
-	char *szVfsOptions;
-	char *szVfsPath;
+	char **szVfsObjects;
+	char *szModulesPath;
+	char **szModules;
 	int iMinPrintSpace;
 	int iMaxPrintJobs;
 	int iWriteCacheSize;
@@ -445,8 +447,8 @@ static service sDefault = {
 	NULL,			/* volume */
 	NULL,			/* fstype */
 	NULL,			/* vfs object */
-	NULL,			/* vfs options */
-	NULL,			/* vfs path */
+	NULL,			/* modules path */
+	NULL,			/* modules */
 	0,			/* iMinPrintSpace */
 	1000,			/* iMaxPrintJobs */
 	0,			/* iWriteCacheSize */
@@ -535,7 +537,6 @@ static int default_server_announce;
 /* prototypes for the special type handlers */
 static BOOL handle_include(char *pszParmValue, char **ptr);
 static BOOL handle_copy(char *pszParmValue, char **ptr);
-static BOOL handle_vfs_object(char *pszParmValue, char **ptr);
 static BOOL handle_source_env(char *pszParmValue, char **ptr);
 static BOOL handle_netbios_name(char *pszParmValue, char **ptr);
 static BOOL handle_winbind_uid(char *pszParmValue, char **ptr);
@@ -809,7 +810,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},
 
@@ -1085,11 +1087,9 @@ static struct parm_struct parm_table[] =
 
 	{"VFS module options", P_SEP, P_SEPARATOR},
 	
-	{"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 objects", P_LIST, P_LOCAL, &sDefault.szVfsObjects, NULL, NULL, FLAG_SHARE},
+	{"vfs object", P_LIST, P_LOCAL, &sDefault.szVfsObjects, 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},
 
@@ -1243,6 +1243,7 @@ static void init_globals(void)
 				string_set(parm_table[i].ptr, "");
 
 		string_set(&sDefault.fstype, FSTYPE_STRING);
+		string_set(&sDefault.szModulesPath, dyn_LIBDIR);
 
 		init_printer_values();
 
@@ -1397,6 +1398,7 @@ static void init_globals(void)
 	Globals.ldap_ssl = LDAP_SSL_ON;
 	Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
 
+
 /* these parameters are set to defaults that are more appropriate
    for the increasing samba install base:
 
@@ -1581,7 +1583,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)
@@ -1736,9 +1737,9 @@ FN_LOCAL_LIST(lp_readlist, readlist)
 FN_LOCAL_LIST(lp_writelist, writelist)
 FN_LOCAL_LIST(lp_printer_admin, printer_admin)
 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_LIST(lp_vfsobj, szVfsObjects)
+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)
@@ -1831,7 +1832,7 @@ static void init_copymap(service * pserv
 /* This is a helper function for parametrical options support. */
 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
 /* Actual parametrical functions are quite simple */
-static const char *get_parametrics(int lookup_service, const char *type, const char *option)
+static param_opt_struct *get_parametrics(int lookup_service, const char *type, const char *option)
 {
 	char* vfskey;
         param_opt_struct *data;
@@ -1845,26 +1846,25 @@ static const char *get_parametrics(int l
 	while (data) {
 		if (strcmp(data->key, vfskey) == 0) {
 			string_free(&vfskey);
-			return data->value;
+			return data;
 		}
 		data = data->next;
 	}
-
 	if (lookup_service >= 0) {
 		/* Try to fetch the same option but from globals */
 		/* but only if we are not already working with Globals */
 		data = Globals.param_opt;
 		while (data) {
-			if (strcmp(data->key, vfskey) == 0) {
-				string_free(&vfskey);
-				return data->value;
+		        if (strcmp(data->key, vfskey) == 0) {
+			        string_free(&vfskey);
+				return data;
 			}
 			data = data->next;
 		}
 	}
-
-	string_free(&vfskey);
 	
+	string_free(&vfskey);
+
 	return NULL;
 }
 
@@ -1940,87 +1940,101 @@ static int lp_enum(const char *s,const s
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
-/* Returned value is allocated in 'lp_talloc' context */
 
-char *lp_parm_string(int lookup_service, const char *type, const char *option)
+
+char *lp_parm_string(int lookup_service, const char *type, const char *option, char *def)
 {
-	const char *value = get_parametrics(lookup_service, type, option);
+	param_opt_struct *data = get_parametrics(lookup_service, type, option);
 	
-	if (value)
-		return lp_string(value);
-
-	return NULL;
+	if (data == NULL)
+		return def;
+		
+	return data->value;
 }
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
-/* Returned value is allocated in 'lp_talloc' context */
 
-char **lp_parm_string_list(int lookup_service, const char *type, const char *option,
-			   const char *separator)
+const char **lp_parm_string_list(int lookup_service, const char *type, const char *option,
+			   const char *separator,char **def)
 {
-	const char *value = get_parametrics(lookup_service, type, option);
-	
-	if (value)
-		return str_list_make(value, separator);
+	param_opt_struct *data = get_parametrics(lookup_service, type, option);
 
-	return NULL;
+	if (data == NULL)
+		return (const char **)def;
+		
+	if ((data->list_sep == separator)||
+		(data->list_sep && separator && 
+		 strequal(data->list_sep,separator))) {
+		if (data->list==NULL) {
+			data->list = talloc_str_list_make(data->mem_ctx,data->value, separator);
+			if (separator) {
+				data->list_sep = talloc_strdup(data->mem_ctx,separator);
+			}
+		}
+	} else {
+		data->list = talloc_str_list_make(data->mem_ctx,data->value, separator);
+		if (separator) {
+			data->list_sep = talloc_strdup(data->mem_ctx,separator);
+		}	
+	}
+
+	return (const char **)data->list;
 }
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
 
-int lp_parm_int(int lookup_service, const char *type, const char *option)
+int lp_parm_int(int lookup_service, const char *type, const char *option, int def)
 {
-	const char *value = get_parametrics(lookup_service, type, option);
+	param_opt_struct *data = get_parametrics(lookup_service, type, option);
 	
-	if (value)
-		return lp_int(value);
+	if (data && data->value && *data->value)
+		return lp_int(data->value);
 
-	return (-1);
+	return def;
 }
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
 
-unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *option)
+unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *option, unsigned long def)
 {
-	const char *value = get_parametrics(lookup_service, type, option);
+	param_opt_struct *data = get_parametrics(lookup_service, type, option);
 	
-	if (value)
-		return lp_ulong(value);
+	if (data && data->value && *data->value)
+		return lp_ulong(data->value);
 
-	return (0);
+	return def;
 }
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
 
-BOOL lp_parm_bool(int lookup_service, const char *type, const char *option)
+BOOL lp_parm_bool(int lookup_service, const char *type, const char *option, BOOL def)
 {
-	const char *value = get_parametrics(lookup_service, type, option);
+	param_opt_struct *data = get_parametrics(lookup_service, type, option);
 	
-	if (value)
-		return lp_bool(value);
+	if (data && data->value && *data->value)
+		return lp_bool(data->value);
 
-	return False;
+	return def;
 }
 
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
 
 int lp_parm_enum(int lookup_service, const char *type, const char *option,
-		 const struct enum_list *_enum)
+		 const struct enum_list *_enum, int def)
 {
-	const char *value = get_parametrics(lookup_service, type, option);
+	param_opt_struct *data = get_parametrics(lookup_service, type, option);
 	
-	if (value)
-		return lp_enum(value, _enum);
+	if (data && data->value && *data->value)
+		return lp_enum(data->value, _enum);
 
-	return (-1);
+	return def;
 }
 
-
 /***************************************************************************
  Initialise a service to the defaults.
 ***************************************************************************/
@@ -2062,15 +2076,14 @@ static void free_service(service *pservi
 			     		    (((char *)pservice) +
 					     PTR_DIFF(parm_table[i].ptr, &sDefault)));
 	}
-				
-	DEBUG(5,("Freeing parametrics:\n"));
+
 	data = pservice->param_opt;
+	if (data)
+		DEBUG(5,("Freeing parametrics:\n"));
 	while (data) {
-		DEBUG(5,("[%s = %s]\n", data->key, data->value));
-		string_free(&data->key);
-		string_free(&data->value);
+		DEBUGADD(5,("[%s = %s]\n", data->key, data->value));
 		pdata = data->next;
-		SAFE_FREE(data);
+		talloc_destroy(data->mem_ctx);
 		data = pdata;
 	}
 
@@ -2099,10 +2112,8 @@ static int add_a_service(const service *
 			/* They will be added during parsing again */
 			data = ServicePtrs[i]->param_opt;
 			while (data) {
-				string_free(&data->key);
-				string_free(&data->value);
 				pdata = data->next;
-				SAFE_FREE(data);
+				talloc_destroy(data->mem_ctx);
 				data = pdata;
 			}
 			ServicePtrs[i]->param_opt = NULL;
@@ -2351,7 +2362,6 @@ static void copy_service(service * pserv
 	int i;
 	BOOL bcopyall = (pcopymapDest == NULL);
 	param_opt_struct *data, *pdata, *paramo;
-	BOOL not_added;
 
 	for (i = 0; parm_table[i].label; i++)
 		if (parm_table[i].ptr && parm_table[i].class == P_LOCAL &&
@@ -2408,24 +2418,33 @@ static void copy_service(service * pserv
 	
 	data = pserviceSource->param_opt;
 	while (data) {
-		not_added = True;
 		pdata = pserviceDest->param_opt;
 		/* Traverse destination */
 		while (pdata) {
-			/* If we already have same option, override it */
+			/* If we already have same option, remove it */
 			if (strcmp(pdata->key, data->key) == 0) {
-				string_free(&pdata->value);
-				pdata->value = strdup(data->value);
-				not_added = False;
+				DLIST_REMOVE(pserviceDest->param_opt,pdata);
+				talloc_destroy(pdata->mem_ctx);
 				break;
 			}
 			pdata = pdata->next;
 		}
-		if (not_added) {
-		    paramo = smb_xmalloc(sizeof(param_opt_struct));
-		    paramo->key = strdup(data->key);
-		    paramo->value = strdup(data->value);
-		    DLIST_ADD(pserviceDest->param_opt, paramo);
+		{
+			TALLOC_CTX *mem_ctx = NULL;
+			if ((mem_ctx = talloc_init_named("param options entry"))==NULL) {
+				DEBUG(0,("copy_service: talloc_init_named failed!\n"));
+				return;
+			}
+			if ((paramo=(param_opt_struct *)talloc(mem_ctx,sizeof(param_opt_struct)))==NULL) {
+				DEBUG(0,("copy_service: talloc failed!\n"));
+				return;
+			}
+			paramo->key = talloc_strdup(mem_ctx,data->key);
+			paramo->value = talloc_strdup(mem_ctx,data->value);
+			paramo->list = NULL;
+			paramo->list_sep = NULL;
+			paramo->mem_ctx = mem_ctx;
+			DLIST_ADD(pserviceDest->param_opt, paramo);
 		}
 		data = data->next;
 	}
@@ -2685,22 +2704,6 @@ static BOOL handle_source_env(char *pszP
 }
 
 /***************************************************************************
- Handle the interpretation of the vfs object parameter.
-*************************************************************************/
-
-static BOOL handle_vfs_object(char *pszParmValue, char **ptr)
-{
-	/* Set string value */
-
-	string_set(ptr, pszParmValue);
-
-	/* Do any other initialisation required for vfs.  Note that
-	   anything done here may have linking repercussions in nmbd. */
-
-	return True;
-}
-
-/***************************************************************************
  Handle the include operation.
 ***************************************************************************/
 
@@ -3031,39 +3034,51 @@ BOOL lp_do_parameter(int snum, char *psz
 	pstring vfskey;
 	char *sep;
 	param_opt_struct *paramo, *data;
-	BOOL not_added;
 
 	parmnum = map_parameter(pszParmName);
 
 	if (parmnum < 0) {
 		if ((sep=strchr(pszParmName, ':')) != NULL) {
-			*sep = 0;
+			*sep = '\0';
 			ZERO_STRUCT(vfskey);
 			pstr_sprintf(vfskey, "%s:", pszParmName);
 			slen = strlen(vfskey);
 			safe_strcat(vfskey, sep+1, sizeof(pstring));
 			trim_string(vfskey+slen, " ", " ");
-			not_added = True;
 			data = (snum < 0) ? Globals.param_opt : 
 				ServicePtrs[snum]->param_opt;
 			/* Traverse destination */
 			while (data) {
 				/* If we already have same option, override it */
 				if (strcmp(data->key, vfskey) == 0) {
-					string_free(&data->value);
-					data->value = strdup(pszParmValue);
-					not_added = False;
+					if (snum < 0){
+						DLIST_REMOVE(Globals.param_opt,data);
+					} else {
+						DLIST_REMOVE(ServicePtrs[snum]->param_opt,data);	
+					}
+					talloc_destroy(data->mem_ctx);
 					break;
 				}
 				data = data->next;
 			}
-			if (not_added) {
-				paramo = smb_xmalloc(sizeof(param_opt_struct));
-				paramo->key = strdup(vfskey);
-				paramo->value = strdup(pszParmValue);
-				if (snum < 0) {
+			{
+				TALLOC_CTX *mem_ctx = NULL;
+				if ((mem_ctx = talloc_init_named("param options entry"))==NULL) {
+					DEBUG(0,("lp_do_parameter: talloc_init_named failed!\n"));
+					return False;
+				}
+				if ((paramo=(param_opt_struct *)talloc(mem_ctx,sizeof(param_opt_struct)))==NULL) {
+					DEBUG(0,("lp_do_parameter: talloc failed!\n"));
+					return False;
+				}
+				paramo->key = talloc_strdup(mem_ctx,vfskey);
+				paramo->value = talloc_strdup(mem_ctx,pszParmValue);
+				paramo->list = NULL;
+				paramo->list_sep = NULL;
+				paramo->mem_ctx = mem_ctx;
+				if (snum < 0 ) {
 					DLIST_ADD(Globals.param_opt, paramo);
-				} else {
+				} else { 
 					DLIST_ADD(ServicePtrs[snum]->param_opt, paramo);
 				}
 			}
@@ -3830,10 +3845,8 @@ BOOL lp_load(const char *pszFname, BOOL 
 	if (Globals.param_opt != NULL) {
 		data = Globals.param_opt;
 		while (data) {
-			string_free(&data->key);
-			string_free(&data->value);
 			pdata = data->next;
-			SAFE_FREE(data);
+			talloc_destroy(data->mem_ctx);
 			data = pdata;
 		}
 		Globals.param_opt = NULL;
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/sam/sam_ads.c HEAD-modules/source/sam/sam_ads.c
--- HEAD/source/sam/sam_ads.c	Wed Dec  4 07:18:43 2002
+++ HEAD-modules/source/sam/sam_ads.c	Tue Dec 10 16:52:34 2002
@@ -1328,10 +1328,10 @@ NTSTATUS sam_init_ads(SAM_METHODS *sam_m
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	sam_ads_state->ads_bind_dn = talloc_strdup(sam_ads_state->mem_ctx, lp_parm_string(NULL,"sam_ads","bind as"));
-	sam_ads_state->ads_bind_pw = talloc_strdup(sam_ads_state->mem_ctx, lp_parm_string(NULL,"sam_ads","bind pw"));
+	sam_ads_state->ads_bind_dn = talloc_strdup(sam_ads_state->mem_ctx, lp_parm_string(GLOBAL_SECTION_SNUM,"sam_ads","bind as",""));
+	sam_ads_state->ads_bind_pw = talloc_strdup(sam_ads_state->mem_ctx, lp_parm_string(GLOBAL_SECTION_SNUM,"sam_ads","bind pw",""));
 
-	sam_ads_state->bind_plaintext = strequal(lp_parm_string(NULL, "sam_ads", "plaintext bind"), "yes");
+	sam_ads_state->bind_plaintext = lp_parm_bool(GLOBAL_SECTION_SNUM, "sam_ads", "plaintext bind",True);
 
 	if (!sam_ads_state->ads_bind_dn || !sam_ads_state->ads_bind_pw) {
 		DEBUG(0, ("talloc_strdup() failed for bind dn or password\n"));
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Thu Dec 12 21:00:30 2002
@@ -94,6 +94,7 @@ thinking the server is still available.
 connection_struct *conn_new(void)
 {
 	connection_struct *conn;
+	TALLOC_CTX *mem_ctx = NULL;
 	int i;
 
 	i = bitmap_find(bmap, 1);
@@ -103,10 +104,16 @@ connection_struct *conn_new(void)
 		return NULL;
 	}
 
-	conn = (connection_struct *)malloc(sizeof(*conn));
+	if ((mem_ctx = talloc_init_named("connection struct"))==NULL) {
+		DEBUG(0,("talloc_init_named failed for connection struct\n"));
+		return NULL;
+	}
+
+	conn = (connection_struct *)talloc(mem_ctx,sizeof(*conn));
 	if (!conn) return NULL;
 
 	ZERO_STRUCTP(conn);
+	conn->mem_ctx = mem_ctx;
 	conn->cnum = i;
 
 	bitmap_set(bmap, i);
@@ -184,27 +191,8 @@ void conn_clear_vuid_cache(uint16 vuid)
 
 void conn_free(connection_struct *conn)
 {
- 	smb_vfs_handle_struct *handle, *thandle;
- 	void (*done_fptr)(connection_struct *the_conn);
-
-	/* Free vfs_connection_struct */
-	handle = conn->vfs_private;
-	while(handle) {
- 		/* Close dlopen() handle */
- 		done_fptr = (void (*)(connection_struct *))sys_dlsym(handle->handle, "vfs_done");
- 
- 		if (done_fptr == NULL) {
- 			DEBUG(3, ("No vfs_done() symbol found in module with handle %p, ignoring\n", handle->handle));
- 		} else {
- 			done_fptr(conn);
- 		}
-     		sys_dlclose(handle->handle);
-		DLIST_REMOVE(conn->vfs_private, handle);
-		thandle = handle->next;
-		SAFE_FREE(handle);
-		handle = thandle;
-	}
-
+	TALLOC_CTX *mem_ctx;
+	
 	DLIST_REMOVE(Connections, conn);
 
 	if (conn->ngroups && conn->groups) {
@@ -224,8 +212,9 @@ void conn_free(connection_struct *conn)
 	bitmap_clear(bmap, conn->cnum);
 	num_open--;
 
+	mem_ctx = conn->mem_ctx;
 	ZERO_STRUCTP(conn);
-	SAFE_FREE(conn);
+	talloc_destroy(mem_ctx);
 }
 
 
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:05:06 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),NULL,MODULE_TYPES_SMBD);
 
 				return True; 
 			}
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Thu Dec 12 14:29:24 2002
@@ -554,7 +554,7 @@ static connection_struct *make_connectio
 		if (!can_write) {
 			if (!share_access_check(conn, snum, vuser, FILE_READ_DATA)) {
 				/* No access, read or write. */
-				DEBUG(0,( "make_connection: connection to %s denied due to security descriptor.\n",
+				DEBUG(0,( "make_connection_snum: connection to %s denied due to security descriptor.\n",
 					  lp_servicename(snum)));
 				conn_free(conn);
 				*status = NT_STATUS_ACCESS_DENIED;
@@ -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)),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 */
@@ -729,8 +735,8 @@ connection_struct *make_connection_with_
 	 */
 	 
 	if ( conn && vfs_ChDir(conn,conn->connectpath) != 0 ) {
-		DEBUG(0,("move_driver_to_download_area: Can't change directory to %s for [print$] (%s)\n",
-			 conn->connectpath,strerror(errno)));
+		DEBUG(0,("make_connection_with_chdir: Can't change directory to %s for [%s] (%s)\n",
+			 conn->connectpath,lp_servicename(SNUM(conn)),strerror(errno)));
 		yield_connection(conn, lp_servicename(SNUM(conn)));
 		conn_free(conn);
 		*status = NT_STATUS_UNSUCCESSFUL;
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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 13 11:43:22 2002
@@ -1,9 +1,9 @@
 /*
-   Unix SMB/Netbios implementation.
-   Version 1.9.
+   Unix SMB/CIFS implementation.
    VFS initialisation and support functions
-   Copyright (C) Tim Potter 1999
-   Copyright (C) Alexander Bokovoy 2002
+   Copyright (C) Tim Potter			1999
+   Copyright (C) Alexander Bokovoy		2002
+   Copyright (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
@@ -35,11 +35,50 @@ struct vfs_syminfo {
 	void *fptr;
 };
 
-/*
-  Opaque (final) vfs operations. This is a combination of first-met opaque vfs operations
-  across all currently processed modules.  */
+static vfs_object_function_entry *smb_vfs_objects = NULL;
 
-static vfs_op_tuple vfs_opaque_ops[SMB_VFS_OP_LAST];
+NTSTATUS smb_register_vfs(const char *name, vfs_op_tuple *vfs_op_tuples, int *module_id, int version)
+{
+	vfs_object_function_entry *fn_entry = NULL;
+	static int global_module_id = 1; /* 0 is for vfs_default_fn_entry */
+
+	/* check if the interface version is ok */
+	if (version != SMB_VFS_INTERFACE_VERSION) {
+		DEBUG(0,("smb_register_vfs: vfs object '%s' have VFS_INTERFACE_VERSION %d, samba has VFS_INTERFACE_VERSION %d\n",
+		name,version,SMB_VFS_INTERFACE_VERSION));
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
+	/* check if a module is allready registered with this name */
+	for (fn_entry=smb_vfs_objects;fn_entry;fn_entry=fn_entry->next) {
+		if (strequal(fn_entry->name,name)) {
+			DEBUG(1,("smb_register_vfs: a module with name '%s' is allready registered!\n",name));
+			return NT_STATUS_OBJECT_NAME_COLLISION;
+		}
+	}
+
+	if ((fn_entry=(vfs_object_function_entry *)malloc(sizeof(vfs_object_function_entry)))==NULL) {
+		DEBUG(0,("smb_register_vfs: malloc failed!\n"));
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	ZERO_STRUCTP(fn_entry);
+
+	fn_entry->name		= strdup(name);
+	fn_entry->op_tuples	= vfs_op_tuples;
+	fn_entry->id		= global_module_id;
+
+	if (module_id)
+		*module_id = global_module_id;
+		
+	global_module_id++;
+
+	DLIST_ADD(smb_vfs_objects,fn_entry);
+
+	DEBUG(2,("smb_register_vfs: register module '%s'!\n",name));
+
+	return NT_STATUS_OK;
+}
 
 /* Default vfs hooks.  WARNING: The order of these initialisers is
    very important.  They must be in the same order as defined in
@@ -127,80 +166,167 @@ static struct vfs_ops default_vfs_ops = 
 	vfswrap_sys_acl_free_qualifier
 };
 
+static vfs_op_tuple default_vfs_op_tuples[] = {
+
+	/* Disk operations */
+	{VFS_OP(vfswrap_dummy_connect),			SMB_VFS_OP_CONNECT,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_dummy_disconnect),		SMB_VFS_OP_DISCONNECT,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_disk_free),			SMB_VFS_OP_DISK_FREE,			SMB_VFS_LAYER_OPAQUE},
+
+	/* Directory operations */
+	{VFS_OP(vfswrap_opendir),			SMB_VFS_OP_OPENDIR,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_readdir),			SMB_VFS_OP_READDIR,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_mkdir),				SMB_VFS_OP_MKDIR,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_rmdir),				SMB_VFS_OP_RMDIR,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_closedir),			SMB_VFS_OP_CLOSEDIR,			SMB_VFS_LAYER_OPAQUE},
+
+	/* File operations */
+	{VFS_OP(vfswrap_open),				SMB_VFS_OP_OPEN,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_close),				SMB_VFS_OP_CLOSE,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_read),				SMB_VFS_OP_READ,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_write),				SMB_VFS_OP_WRITE,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_lseek),				SMB_VFS_OP_LSEEK,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sendfile),			SMB_VFS_OP_SENDFILE,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_rename),			SMB_VFS_OP_RENAME,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_fsync),				SMB_VFS_OP_FSYNC,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_stat),				SMB_VFS_OP_STAT,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_fstat),				SMB_VFS_OP_FSTAT,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_lstat),				SMB_VFS_OP_LSTAT,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_unlink),			SMB_VFS_OP_UNLINK,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_chmod),				SMB_VFS_OP_CHMOD,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_fchmod),			SMB_VFS_OP_FCHMOD,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_chown),				SMB_VFS_OP_CHOWN,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_fchown),			SMB_VFS_OP_FCHOWN,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_chdir),				SMB_VFS_OP_CHDIR,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_getwd),				SMB_VFS_OP_GETWD,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_utime),				SMB_VFS_OP_UTIME,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_ftruncate),			SMB_VFS_OP_FTRUNCATE,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_lock),				SMB_VFS_OP_LOCK,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_symlink),			SMB_VFS_OP_SYMLINK,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_readlink),			SMB_VFS_OP_READLINK,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_link),				SMB_VFS_OP_LINK,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_mknod),				SMB_VFS_OP_MKNOD,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_realpath),			SMB_VFS_OP_REALPATH,			SMB_VFS_LAYER_OPAQUE},
+
+	{VFS_OP(vfswrap_fget_nt_acl),			SMB_VFS_OP_FGET_NT_ACL,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_get_nt_acl),			SMB_VFS_OP_GET_NT_ACL,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_fset_nt_acl),			SMB_VFS_OP_FSET_NT_ACL,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_set_nt_acl),			SMB_VFS_OP_SET_NT_ACL,			SMB_VFS_LAYER_OPAQUE},
+
+	/* POSIX ACL operations. */
+#if defined(HAVE_NO_ACLS)
+	{VFS_OP(NULL),					SMB_VFS_OP_CHMOD_ACL,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(NULL),					SMB_VFS_OP_FCHMOD_ACL,			SMB_VFS_LAYER_OPAQUE},
+#else
+	{VFS_OP(vfswrap_chmod_acl),			SMB_VFS_OP_CHMOD_ACL,			SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_fchmod_acl),			SMB_VFS_OP_FCHMOD_ACL,			SMB_VFS_LAYER_OPAQUE},
+#endif
+	{VFS_OP(vfswrap_sys_acl_get_entry),		SMB_VFS_OP_SYS_ACL_GET_ENTRY,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_get_tag_type),		SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,	SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_get_permset),		SMB_VFS_OP_SYS_ACL_GET_PERMSET,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_get_qualifier),		SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,	SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_get_file),		SMB_VFS_OP_SYS_ACL_GET_FILE,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_get_fd),		SMB_VFS_OP_SYS_ACL_GET_FD,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_clear_perms),		SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_add_perm),		SMB_VFS_OP_SYS_ACL_ADD_PERM,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_to_text),		SMB_VFS_OP_SYS_ACL_TO_TEXT,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_init),			SMB_VFS_OP_SYS_ACL_INIT,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_create_entry),		SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,	SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_set_tag_type),		SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,	SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_set_qualifier),		SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,	SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_set_permset),		SMB_VFS_OP_SYS_ACL_SET_PERMSET,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_valid),			SMB_VFS_OP_SYS_ACL_VALID,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_set_file),		SMB_VFS_OP_SYS_ACL_SET_FILE,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_set_fd),		SMB_VFS_OP_SYS_ACL_SET_FD,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_delete_def_file),	SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,	SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_get_perm),		SMB_VFS_OP_SYS_ACL_GET_PERM,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_free_text),		SMB_VFS_OP_SYS_ACL_FREE_TEXT,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_free_acl),		SMB_VFS_OP_SYS_ACL_FREE_ACL,		SMB_VFS_LAYER_OPAQUE},
+	{VFS_OP(vfswrap_sys_acl_free_qualifier),	SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,	SMB_VFS_LAYER_OPAQUE},
+
+	{NULL,						SMB_VFS_OP_NOOP,		SMB_VFS_LAYER_NOOP}
+};
+
+static vfs_object_function_entry default_vfs_fn_entry = {
+	NULL,			/* prev */
+	NULL,			/* next */
+	"default",		/* name */
+	default_vfs_op_tuples,	/* op_tuple */
+	0,			/* id */
+	NULL			/* defeault_ops (only per connection)*/
+};
 /****************************************************************************
   initialise default vfs hooks
 ****************************************************************************/
 
-static void vfs_init_default(connection_struct *conn)
+static BOOL vfs_init_default(connection_struct *conn)
 {
-	DEBUG(3, ("Initialising default vfs hooks\n"));
-
+	vfs_object_function_entry *fn_entry;
+	DEBUG(5, ("Initialising default vfs hooks\n"));
+	
 	memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(struct vfs_ops));
-	conn->vfs_private = NULL;
+	
+	fn_entry = (vfs_object_function_entry *)talloc(conn->mem_ctx,sizeof(vfs_object_function_entry));
+	if (fn_entry == NULL) {
+		DEBUG(0,("vfs_init_default: talloc failed\n"));
+		return False;
+	}
+
+	ZERO_STRUCTP(fn_entry);
+
+	fn_entry->name		= default_vfs_fn_entry.name;
+	fn_entry->op_tuples  	= default_vfs_fn_entry.op_tuples;
+	fn_entry->id		= default_vfs_fn_entry.id;
+
+	DLIST_ADD(conn->vfs_objects,fn_entry);
+
+	return True;
 }
 
 /****************************************************************************
   initialise custom vfs hooks
 ****************************************************************************/
 
-BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object)
+BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object_name)
 {
-	int vfs_version = -1;
- 	vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *);
  	int i;
+ 	vfs_object_function_entry *vfs_object = NULL;
+ 	vfs_object_function_entry *fn_entry,*tmp_vfs_object;
 
-	DEBUG(3, ("Initialising custom vfs hooks from %s\n", vfs_object));
+	DEBUG(3, ("Initialising custom vfs hooks from '%s'\n", vfs_object_name));
 
-	/* Open object file */
+	for(tmp_vfs_object = smb_vfs_objects ; tmp_vfs_object; tmp_vfs_object=tmp_vfs_object->next) {
+		if (strequal(vfs_object_name,tmp_vfs_object->name)) {
+			vfs_object = tmp_vfs_object;
+			break;
+		}
+	}
 
-	if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) {
-		DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror()));
+	if (vfs_object == NULL) {
+		DEBUG(0,("vfs_init_custom: don't find a custom vfs module '%s'!\n",vfs_object_name));
 		return False;
 	}
 
-	/* Get handle on vfs_init() symbol */
 
-	init_fptr = (vfs_op_tuple *(*)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *))sys_dlsym(conn->vfs_private->handle, "vfs_init");
+ 	for(i=0; vfs_object->op_tuples[i].op != NULL; i++) {
+		/* Change current VFS disposition*/
+		DEBUG(20, ("Accepting operation type %d from module %s\n", vfs_object->op_tuples[i].type, vfs_object_name));
+		((void**)&conn->vfs_ops)[vfs_object->op_tuples[i].type] = vfs_object->op_tuples[i].op;
+	}
 
-	if (init_fptr == NULL) {
-		DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object));
+	fn_entry = (vfs_object_function_entry *)talloc(conn->mem_ctx,sizeof(vfs_object_function_entry));
+	if (fn_entry == NULL) {
+		DEBUG(0,("vfs_init_default: talloc failed\n"));
 		return False;
 	}
 
-	/* Initialise vfs_ops structure */
+	ZERO_STRUCTP(fn_entry);
+	
+	fn_entry->name		= vfs_object->name;
+	fn_entry->op_tuples	= vfs_object->op_tuples;
+	fn_entry->id		= vfs_object->id;
 
- 	if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) {
- 		DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object));
- 		return False;
- 	}
-  
- 	if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) {
- 		DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n",
- 			vfs_version, SMB_VFS_INTERFACE_VERSION ));
-  		return False;
-  	}
-  
- 	if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) {
- 		DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\
-Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n",
- 			vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version ));
-  		return False;
-  	}
-  
- 	for(i=0; ops[i].op != NULL; i++) {
- 	  DEBUG(3, ("Checking operation #%d (type %d, layer %d)\n", i, ops[i].type, ops[i].layer));
- 	  if(ops[i].layer == SMB_VFS_LAYER_OPAQUE) {
- 	    /* Check whether this operation was already made opaque by different module */
- 	    if(vfs_opaque_ops[ops[i].type].op == ((void**)&default_vfs_ops)[ops[i].type]) {
- 	      /* No, it isn't overloaded yet. Overload. */
- 	      DEBUG(3, ("Making operation type %d opaque [module %s]\n", ops[i].type, vfs_object));
- 	      vfs_opaque_ops[ops[i].type] = ops[i];
- 	    }
- 	  }
- 	  /* Change current VFS disposition*/
- 	  DEBUG(3, ("Accepting operation type %d from module %s\n", ops[i].type, vfs_object));
- 	  ((void**)&conn->vfs_ops)[ops[i].type] = ops[i].op;
-	}
+	DLIST_ADD(conn->vfs_objects,fn_entry);
 
 	return True;
 }
@@ -211,71 +337,302 @@ Proceeding in compatibility mode, new op
 
 BOOL smbd_vfs_init(connection_struct *conn)
 {
-	char **vfs_objects, *vfsobj, *vfs_module, *vfs_path;
-	int nobj, i;
-	struct smb_vfs_handle_struct *handle;
-	
+	const char **vfs_objects;
+	int i;
+
 	/* Normal share - initialise with disk access functions */
-	vfs_init_default(conn);
+	if (!vfs_init_default(conn)) {
+		return False;
+	};
 
-	/* Override VFS functions if 'vfs object' was specified*/
-	if (*lp_vfsobj(SNUM(conn))) {
-		vfsobj = NULL;
-		for(i=0; i<SMB_VFS_OP_LAST; i++) {
-		  vfs_opaque_ops[i].op = ((void**)&default_vfs_ops)[i];
-		  vfs_opaque_ops[i].type = i;
-		  vfs_opaque_ops[i].layer = SMB_VFS_LAYER_OPAQUE;
-		}
-		if (string_set(&vfsobj, lp_vfsobj(SNUM(conn)))) {
-			/* Parse passed modules specification to array of modules */
-			set_first_token(vfsobj);
-			/* We are using default separators: ' \t\r\n' */
-			vfs_objects = toktocliplist(&nobj, NULL);
-			if (vfs_objects) {
-				vfs_path = lp_vfs_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));
-					/* Loadable object file */
-					handle->handle = NULL;
-					DLIST_ADD(conn->vfs_private, handle)
-					vfs_module = NULL;
-					if (vfs_path) {
-						asprintf(&vfs_module, "%s/%s", vfs_path, vfs_objects[i]);
-					} else {
-						asprintf(&vfs_module, "%s", vfs_objects[i]);
-					}
-					if (!vfs_init_custom(conn, vfs_module)) {
-						DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for %s\n", vfs_module));
-						string_free(&vfsobj);
-						SAFE_FREE(vfs_module);
-						return False;
-					}
-					SAFE_FREE(vfs_module);
-				}
+	/* Override VFS functions if 'vfs objects' was specified*/
+	if (((vfs_objects=lp_vfsobj(SNUM(conn)))!=NULL)&&
+		(*vfs_objects!=NULL)) {
+		for (i=(-1);vfs_objects[i+1]!=NULL;i++) {
+			/* count the objects */
+		}
+		for ( ; i>=0; i--) {
+			if (!vfs_init_custom(conn, vfs_objects[i])) {
+				DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed for '%s'\n", vfs_objects[i]));
+				return False;
 			}
-			string_free(&vfsobj);
-			return True;
 		}
 	}
+
 	return True;
 }
 
-/*******************************************************************
- Create vfs_ops reflecting current vfs_opaque_ops
-*******************************************************************/
+struct vfs_ops *vfs_get_ops(struct connection_struct *conn)
+{
+	return &conn->vfs_ops;
+}
+
+void *vfs_get_op(struct connection_struct *conn, int type)
+{
+	if (type <= SMB_VFS_OP_NOOP || type > SMB_VFS_OP_LAST) {
+		DEBUG(0,("vfs_get_op: wrong oparartion type #%d\n",type));
+		return VFS_OP(NULL);
+	}
+
+	if (((void**)&conn->vfs_ops)[type]==NULL) {
+		DEBUG(0,("vfs_get_op: Warning: oparation #%d is not available\n",type));
+	}
+
+	return ((void**)&conn->vfs_ops)[type];
+}
+
+struct _vfs_object_function_entry *vfs_object_find_in_conn(struct connection_struct *conn,int module_id)
+{
+ 	vfs_object_function_entry *vfs_object = NULL;
+ 	vfs_object_function_entry *tmp_vfs_object;
+ 
+	for(tmp_vfs_object = conn->vfs_objects ; tmp_vfs_object; tmp_vfs_object=tmp_vfs_object->next) {
+		if (module_id == tmp_vfs_object->id) {
+			vfs_object = tmp_vfs_object;
+			break;
+		}
+	}
+
+	if (vfs_object == NULL) {
+		DEBUG(0,("vfs_object_find_in_conn: didn't find module %d\n",module_id));
+	}
+
+	return vfs_object;
+}
+
+struct vfs_ops *vfs_get_default_ops(struct connection_struct *conn, int module_id)
+{
+ 	struct vfs_ops *tmp_ops = NULL;
+ 	int i,type;
+ 	vfs_object_function_entry *vfs_object = NULL;
+ 	vfs_object_function_entry *tmp_vfs_object;
+
+	if (module_id<0) {
+		DEBUG(0,("vfs_get_default_ops: invalid module_id %d",module_id));
+		return NULL;
+	}
+
+	if (conn->vfs_objects == NULL) {
+		DEBUG(0,("vfs_get_default_ops: no oparations specified for connection %d\n",SNUM(conn)));
+		return NULL;
+	}
+
+	if ((vfs_object=vfs_object_find_in_conn(conn,module_id))==NULL) {
+		DEBUG(0,("vfs_get_default_ops: Can't find default_ops for module (id = %d)\n",module_id));
+		return NULL;
+	}
+
+	if (vfs_object->default_ops !=NULL) {
+		return vfs_object->default_ops;
+	}
+
+	if ((tmp_ops = (struct vfs_ops *)talloc(conn->mem_ctx,sizeof(struct vfs_ops)))==NULL) {
+		DEBUG(0,("vfs_get_default_ops: talloc() failed\n"));
+		return NULL;
+	}
+
+	for(type=0; type<SMB_VFS_OP_LAST; type++) {
+		((void**)tmp_ops)[type] = NULL;
+		
+		for(tmp_vfs_object = vfs_object->next ; tmp_vfs_object; tmp_vfs_object=tmp_vfs_object->next) {
+			for(i=0; tmp_vfs_object->op_tuples[i].op != NULL; i++) {
+				if (tmp_vfs_object->op_tuples[i].type == type 
+					&& tmp_vfs_object->op_tuples[i].op != NULL) {
+					DEBUG(20, ("vfs_get_default_ops: '%s' using op type #%d from module '%s'\n",
+						vfs_object->name, type, tmp_vfs_object->name));
+					((void**)tmp_ops)[type] = tmp_vfs_object->op_tuples[i].op;
+					goto out;
+				}
+			}
+		}
+out:
+		
+		if (((void**)tmp_ops)[type] == NULL) {
+			DEBUG(1,("vfs_get_default_ops: Warning: no default op #%d found\n",type));
+		}
+	}
+
+	vfs_object->default_ops = tmp_ops;
+
+	return tmp_ops;
+}
+
+void *vfs_get_default_op(struct connection_struct *conn, int module_id, int type)
+{
+	struct vfs_ops *tmp_ops = NULL;
+ 	
+	if (module_id<0) {
+		DEBUG(0,("vfs_get_default_op: invalid module_id %d",module_id));
+		return VFS_OP(NULL);
+	}
+
+	if (type <= SMB_VFS_OP_NOOP || type > SMB_VFS_OP_LAST) {
+		DEBUG(0,("vfs_get_default_op: wrong oparartion type #%d\n",type));
+		return VFS_OP(NULL);
+	}
+
+	if (conn->vfs_objects == NULL) {
+		DEBUG(0,("vfs_get_default_op: no oparations specified for connection %d\n",SNUM(conn)));
+		return VFS_OP(NULL);
+	}
+
+	if ((tmp_ops = vfs_get_default_ops(conn,module_id)) == NULL) {
+		DEBUG(0,("vfs_get_default_op: type: #%d vfs_get_default_ops() failed\n",type));
+		return NULL;
+	}
+
+	return ((void**)&tmp_ops)[type];
+}
+
+int vfs_object_id_by_name(const char *module_name)
+{
+	int module_id = (-1);
+ 	vfs_object_function_entry *tmp_vfs_object;
+ 
+ 	if (!module_name) {
+ 		DEBUG(0,("vfs_object_id_by_name: no name given\n"));
+ 		return module_id;
+ 	}
 
-struct vfs_ops *smb_vfs_get_opaque_ops(void)
+	for(tmp_vfs_object = smb_vfs_objects ; tmp_vfs_object; tmp_vfs_object=tmp_vfs_object->next) {
+		if (strequal(module_name,tmp_vfs_object->name)) {
+			module_id = tmp_vfs_object->id;
+			break;
+		}
+	}
+	
+	if (module_id == (-1)) {
+		DEBUG(0,("vfs_object_id_by_name: object '%s' not found\n",module_name));
+	}
+
+	return module_id;
+}
+
+const char *vfs_object_name_by_id(int module_id)
 {
-  int i;
-  struct vfs_ops *ops;
+	char *module_name = NULL;
+ 	vfs_object_function_entry *tmp_vfs_object;
+ 
+ 	if (module_id<0) {
+		DEBUG(0,("vfs_get_default_ops: invalid module_id %d",module_id));
+ 		return module_name;
+ 	}
 
-  ops = smb_xmalloc(sizeof(struct vfs_ops));
+	for(tmp_vfs_object = smb_vfs_objects ; tmp_vfs_object; tmp_vfs_object=tmp_vfs_object->next) {
+		if (module_id == tmp_vfs_object->id) {
+			module_name = tmp_vfs_object->name;
+			break;
+		}
+	}
+	
+	if (module_name == NULL) {
+		DEBUG(0,("vfs_object_name_by_id: object '%d' not found\n",module_id));
+	}
 
-  for(i=0; i<SMB_VFS_OP_LAST; i++) {
-    ((void**)ops)[i] = vfs_opaque_ops[i].op;
-  }
-  return ops;
+	return module_name;
+}
+
+struct vfs_ops *vfs_get_default_ops_by_name(struct connection_struct *conn, const char *module_name)
+{
+ 	if (!module_name) {
+		DEBUG(0,("vfs_get_default_ops_by_name: no module_name given\n"));
+		return NULL;
+	}
+
+	if (conn->vfs_objects == NULL) {
+		DEBUG(0,("vfs_get_default_ops_by_name: no oparations specified for connection %d\n",SNUM(conn)));
+		return NULL;
+	}
+
+	return vfs_get_default_ops(conn,vfs_object_id_by_name(module_name));
+}
+
+void *vfs_get_default_op_by_name(struct connection_struct *conn, const char *module_name, int type)
+{
+	if (!module_name) {
+		DEBUG(0,("vfs_get_default_ops_by_name: no module_name given\n"));
+		return VFS_OP(NULL);
+	}
+
+	if (type <= SMB_VFS_OP_NOOP || type > SMB_VFS_OP_LAST) {
+		DEBUG(0,("vfs_get_default_op: wrong oparartion type #%d\n",type));
+		return VFS_OP(NULL);
+	}
+
+	if (conn->vfs_objects == NULL) {
+		DEBUG(0,("vfs_get_default_ops_by_name: no oparations specified for connection %d\n",SNUM(conn)));
+		return VFS_OP(NULL);
+	}
+
+	return vfs_get_default_op(conn,vfs_object_id_by_name(module_name),type);
+}
+
+struct vfs_ops *vfs_get_opaque_ops(struct connection_struct *conn)
+{
+ 	struct vfs_ops *tmp_ops = NULL;
+ 	int i,type;
+ 	vfs_object_function_entry *tmp_vfs_object;
+
+	if (conn->vfs_objects == NULL) {
+		DEBUG(0,("vfs_get_opaque_ops: no oparations specified for connection %d\n",SNUM(conn)));
+		return NULL;
+	}
+
+	if (conn->vfs_opaque_ops !=NULL) {
+		return conn->vfs_opaque_ops;
+	}
+
+	if ((tmp_ops = (struct vfs_ops *)talloc(conn->mem_ctx,sizeof(struct vfs_ops)))==NULL) {
+		DEBUG(0,("vfs_get_opaque_ops: tmalloc() failed\n"));
+		return NULL;
+	}
+
+	for(type=0; type<SMB_VFS_OP_LAST; type++) {
+		((void**)tmp_ops)[type] = NULL;
+		
+		for(tmp_vfs_object = conn->vfs_objects ; tmp_vfs_object; tmp_vfs_object=tmp_vfs_object->next) {
+			for(i=0; tmp_vfs_object->op_tuples[i].op != NULL; i++) {
+				if (tmp_vfs_object->op_tuples[i].type == type 
+					&& tmp_vfs_object->op_tuples[i].layer == SMB_VFS_LAYER_OPAQUE) {
+					DEBUG(20, ("vfs_get_opaque_ops: Accepting operation type #%d \n",
+						tmp_vfs_object->op_tuples[i].type));
+					((void**)tmp_ops)[type] = tmp_vfs_object->op_tuples[i].op;
+					goto out;
+				}
+			}
+		}
+		
+out:
+		if (((void**)tmp_ops)[type] == NULL) {
+			DEBUG(1,("vfs_get_opaque_ops: Warning: no default op #%d found\n",type));
+		}
+	}
+
+	conn->vfs_opaque_ops = tmp_ops;
+
+	return tmp_ops;
+}
+
+void *vfs_get_opaque_op(struct connection_struct *conn, int type)
+{
+	struct vfs_ops *tmp_ops = NULL;
+ 	
+	if (type <= SMB_VFS_OP_NOOP || type > SMB_VFS_OP_LAST) {
+		DEBUG(0,("vfs_get_opaque_op: wrong oparartion type #%d\n",type));
+		return VFS_OP(NULL);
+	}
+
+	if (conn->vfs_objects == NULL) {
+		DEBUG(0,("vfs_get_opaque_op: no oparations specified for connection %d\n",SNUM(conn)));
+		return NULL;
+	}
+
+	if ((tmp_ops = vfs_get_opaque_ops(conn)) == NULL) {
+		DEBUG(0,("vfs_get_opaque_op: type: #%d vfs_get_opaque_ops() failed\n",type));
+		return NULL;
+	}
+
+	return ((void**)tmp_ops)[type];
 }
 
 /*******************************************************************
@@ -472,7 +829,7 @@ int vfs_allocate_file_space(files_struct
 
 	len -= st.st_size;
 	len /= 1024; /* Len is now number of 1k blocks needed. */
-	space_avail = conn->vfs_ops.disk_free(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
+	space_avail = vfs_ops->disk_free(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
 
 	DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, needed blocks = %.0f, space avail = %.0f\n",
 			fsp->fsp_name, (double)st.st_size, (double)len, (double)space_avail ));
@@ -560,72 +917,6 @@ char *vfs_readdirname(connection_struct 
 	return(dname);
 }
 
-/* VFS options not quite working yet */
-
-#if 0
-
-/***************************************************************************
-  handle the interpretation of the vfs option parameter
- *************************************************************************/
-static BOOL handle_vfs_option(char *pszParmValue, char **ptr)
-{
-    struct vfs_options *new_option, **options = (struct vfs_options **)ptr;
-    int i;
-
-    /* Create new vfs option */
-
-    new_option = (struct vfs_options *)malloc(sizeof(*new_option));
-    if (new_option == NULL) {
-	return False;
-    }
-
-    ZERO_STRUCTP(new_option);
-
-    /* Get name and value */
-
-    new_option->name = strtok(pszParmValue, "=");
-
-    if (new_option->name == NULL) {
-	return False;
-    }
-
-    while(isspace(*new_option->name)) {
-	new_option->name++;
-    }
-
-    for (i = strlen(new_option->name); i > 0; i--) {
-	if (!isspace(new_option->name[i - 1])) break;
-    }
-
-    new_option->name[i] = '\0';
-    new_option->name = strdup(new_option->name);
-
-    new_option->value = strtok(NULL, "=");
-
-    if (new_option->value != NULL) {
-
-	while(isspace(*new_option->value)) {
-	    new_option->value++;
-	}
-	
-	for (i = strlen(new_option->value); i > 0; i--) {
-	    if (!isspace(new_option->value[i - 1])) break;
-	}
-	
-	new_option->value[i] = '\0';
-	new_option->value = strdup(new_option->value);
-    }
-
-    /* Add to list */
-
-    DLIST_ADD(*options, new_option);
-
-    return True;
-}
-
-#endif
-
-
 /*******************************************************************
  A wrapper for vfs_chdir().
 ********************************************************************/
@@ -641,7 +932,7 @@ int vfs_ChDir(connection_struct *conn, c
 	if (*path == '/' && strcsequal(LastDir,path))
 		return(0);
 
-	DEBUG(3,("vfs_ChDir to %s\n",path));
+	DEBUG(4,("vfs_ChDir to %s\n",path));
 
 	res = vfs_chdir(conn,path);
 	if (!res)
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Wed Dec 11 16:14:15 2002
@@ -2,8 +2,9 @@
    Unix SMB/CIFS implementation.
    VFS module functions
 
-   Copyright (C) Simo Sorce 2002
-   Copyright (C) Eric Lorimer 2002
+   Copyright (C) Simo Sorce			2002
+   Copyright (C) Eric Lorimer			2002
+   Copyright (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
@@ -27,32 +28,40 @@ 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 name[PATH_MAX];
-	
-	if (argc != 2) {
-		printf("Usage: load <module path>\n");
+	if (argc < 2) {
+		printf("Usage: load <module path> {[<module path>]}\n");
 		return NT_STATUS_OK;
 	}
 
-	if (path != NULL && *path != '\0') {
-		snprintf(name, PATH_MAX, "%s/%s", path, argv[1]);
-	} else {
-		snprintf(name, PATH_MAX, "%s", argv[1]);
-	}
-	vfs->conn->vfs_private = NULL;
-	handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct));
-	handle->handle = NULL;
-	DLIST_ADD(vfs->conn->vfs_private, handle)
-	if (!vfs_init_custom(vfs->conn, name)) {
-		DEBUG(0, ("load: error=-1 (vfs_init_custom failed for %s)\n", argv[1]));
+	if (!smb_load_modules((const char **)&argv[1],vfs->conn, MODULE_TYPES_PER_SHARE)) {
+		DEBUG(0, ("load: error=-1 (smb_load_modules) failed for %s ...)\n", argv[1]));
 		return NT_STATUS_UNSUCCESSFUL;
 	}
 	printf("load: ok\n");
 	return NT_STATUS_OK;
 }
 
+static NTSTATUS cmd_load_objects(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
+{
+	int i;
+
+	if (argc < 2) {
+		printf("Usage: objects <vfs object name> {[<vfs object name>]}\n");
+		return NT_STATUS_OK;
+	}
+
+	for (i = argc -1; i>0;i--) {
+				
+		if (!vfs_init_custom(vfs->conn,argv[i])) {
+			DEBUG(0,("objects: vfs_init_custom failed for '%s' with parameter '%s'\n",argv[i]));
+			return NT_STATUS_UNSUCCESSFUL;
+		}
+	}
+
+	printf("objects: ok\n");
+	return NT_STATUS_OK;
+}
+
 static NTSTATUS cmd_populate(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
 {
 	char c;
@@ -1011,7 +1020,8 @@ struct cmd_set vfs_commands[] = {
 
 	{ "VFS Commands" },
 
-	{ "load", cmd_load_module, "Load a module", "load <module.so>" },
+	{ "load", cmd_load_module, "Load modulea", "load <module.so> {[</path/to/module2.so>]}" },
+	{ "objects", cmd_load_objects, "Specify vfs objects", "objects <module>[:<parameter>] {[<module2>[:<parameter2>]]}" },
 	{ "populate", cmd_populate, "Populate a data buffer", "populate <char> <size>" },
 	{ "showdata", cmd_show_data, "Show data currently in data buffer", "show_data [<offset> <len>]"},
 	{ "connect",   cmd_connect,   "VFS connect()",    "connect" },
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:13:19 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),NULL,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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:15:12 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),NULL, MODULE_TYPES_NET);
+
 	if (!init_names())
 		exit(1);
 
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:15:39 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),NULL,MODULE_TYPES_PDBEDIT);
 	
 	if (!init_names())
 		exit(1);
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:16:18 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),NULL,MODULE_TYPES_SMBGROUPEDIT);
+
 	if (!init_names())
 		exit(1);
 	
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* HEAD/source/utils/smbpasswd.c HEAD-modules/source/utils/smbpasswd.c
--- HEAD/source/utils/smbpasswd.c	Fri Dec 13 07:25:46 2002
+++ HEAD-modules/source/utils/smbpasswd.c	Fri Dec 13 07:29:48 2002
@@ -582,6 +582,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),NULL,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=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=auth* --exclude=passdb* 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	Tue Dec 10 16:21:11 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),NULL, MODULE_TYPES_WREPLD);
+
 	if (!init_names())
 		return -1;
 	


More information about the samba-technical mailing list