[PATCH] add 'modules path' and handle 'configure --with-configdir' right

Stefan (metze) Metzmacher metze at metzemix.de
Fri Nov 22 10:39:37 GMT 2002


Hi Jelmer,

here's a patch that added the 'modules path' parameter.

lp_modules_path() is prefixed to all lp_modules() witch are not start with 
'/' (not absolute pathes)

the default for lp_modules_path() is selectable by ./configure 
--with-modulesdir=/modules
or $(LIBDIR)/samba  (when  --with-fhs) or $(LIBDIR)

make installmodules install the modules to lp_modules_path()

make modules now makes proto_exist


there's a new file modules/Makefile.ext_modules.in:
here can extern modules be added then they're also catches by 'make modules'




metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <metze at metzemix.de>
-------------- next part --------------
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/Makefile.in HEAD-fix/source/Makefile.in
--- HEAD/source/Makefile.in	Fri Nov 22 08:13:27 2002
+++ HEAD-fix/source/Makefile.in	Fri Nov 22 11:17:14 2002
@@ -56,8 +56,11 @@ INSTALLPERMS = 0755
 # These can be overridden by command line switches (see smbd(8))
 # or in smb.conf (see smb.conf(5))
 LOGFILEBASE = @logfilebase@
-CONFIGFILE = $(LIBDIR)/smb.conf
-LMHOSTSFILE = $(LIBDIR)/lmhosts
+CONFIGDIR = @configdir@
+CONFIGFILE = $(CONFIGDIR)/smb.conf
+LMHOSTSFILE = $(CONFIGDIR)/lmhosts
+# This is where modules are installed and searched by default
+MODULESDIR = @modulesdir@
 # This is where smbpasswd et al go
 PRIVATEDIR = @privatedir@
 
@@ -93,7 +96,8 @@ PATH_FLAGS2 = $(PATH_FLAGS1) -DBINDIR=\"
 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_FLAGS = $(PATH_FLAGS5) $(PASSWD_FLAGS)
+PATH_FLAGS6 = $(PATH_FLAGS5) -DMODULESDIR=\"$(MODULESDIR)\"
+PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
 
 SBIN_PROGS = bin/smbd bin/nmbd bin/swat bin/wrepld @EXTRA_SBIN_PROGS@
 
@@ -113,7 +117,8 @@ SCRIPTS = $(srcdir)/script/smbtar $(srcd
 
 QUOTAOBJS=@QUOTAOBJS@
 
-MODULES = bin/vfs_audit. at SHLIBEXT@ bin/vfs_recycle. at SHLIBEXT@ bin/vfs_netatalk. at SHLIBEXT@ bin/developer. at SHLIBEXT@ @MODULE_MYSQL@ @MODULE_XML@
+include modules/Makefile.ext_modules
+MODULES = bin/vfs_audit. at SHLIBEXT@ bin/vfs_recycle. at SHLIBEXT@ bin/vfs_netatalk. at SHLIBEXT@ bin/developer. at SHLIBEXT@ @MODULE_MYSQL@ @MODULE_XML@ $(EXT_MODULES)
 
 ######################################################################
 # object file lists
@@ -569,7 +574,7 @@ nsswitch : SHOWFLAGS bin/winbindd bin/wb
 
 wins : SHOWFLAGS nsswitch/libnss_wins. at SHLIBEXT@
 
-modules: SHOWFLAGS $(MODULES)
+modules: SHOWFLAGS proto_exists $(MODULES)
 
 everything: all libsmbclient debug2html smbfilter talloctort
 
@@ -886,7 +891,7 @@ bin/tdbbackup: $(TDBBACKUP_OBJ) bin/.dum
 install: installbin installman installscripts installdat installswat 
 
 installdirs:
-	@$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR)
+	@$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(MODULESDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(PRIVATEDIR)
 
 installservers: all installdirs
 	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(SBIN_PROGS)
@@ -895,8 +900,8 @@ 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)
 
-installmodules: all installdirs
-	@$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(LIBDIR) $(MODULES)
+installmodules: modules installdirs
+	@$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(MODULESDIR) $(MODULES)
 
 installscripts: installdirs
 	@$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS)

diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/configure.in HEAD-fix/source/configure.in
--- HEAD/source/configure.in	Fri Nov 22 08:13:31 2002
+++ HEAD-fix/source/configure.in	Fri Nov 22 11:18:12 2002
@@ -11,13 +11,15 @@ AC_PREFIX_DEFAULT(/usr/local/samba)
 
 AC_ARG_WITH(fhs, 
 [  --with-fhs              Use FHS-compliant paths (default=no)],
-    configdir="${sysconfdir}/samba"
+    configdir="\${sysconfdir}/samba"
+    modulesdir="\${LIBDIR}/samba"
     lockdir="\${VARDIR}/cache/samba"
     piddir="\$(VARDIR)/run/samba"
     logfilebase="\${VARDIR}/log/samba"
     privatedir="\${CONFIGDIR}/private"
     swatdir="\${DATADIR}/samba/swat",
     configdir="\$(LIBDIR)"
+    modulesdir="\${LIBDIR}"
     logfilebase="\$(VARDIR)"
     lockdir="\${VARDIR}/locks"
     piddir="\$(VARDIR)/locks"
@@ -105,6 +107,22 @@ AC_ARG_WITH(configdir,
   esac])
 
 #################################################
+# set modules directory location
+AC_ARG_WITH(modulesdir,
+[  --with-modulesdir=DIR   Where to put modules (\$libdir)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody does it
+  #
+    AC_MSG_WARN([--with-modulesdir called without argument - will use default])
+  ;;
+  * )
+    modulesdir="$withval"
+    ;;
+  esac])
+
+#################################################
 # set log directory location
 AC_ARG_WITH(logfilebase,
 [  --with-logfilebase=DIR  Where to put log files (\$(VARDIR))],
@@ -121,6 +139,7 @@ AC_ARG_WITH(logfilebase,
   esac])
 
 AC_SUBST(configdir)
+AC_SUBST(modulesdir)
 AC_SUBST(lockdir)
 AC_SUBST(piddir)
 AC_SUBST(logfilebase)
@@ -625,7 +644,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)
@@ -1954,7 +1973,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
@@ -2054,7 +2073,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
@@ -2250,7 +2269,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)
@@ -2767,7 +2786,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)
 
@@ -3174,7 +3193,7 @@ AC_SUBST(builddir)
 # I added make files that are outside /source directory.
 # I know this is not a good solution, will work out a better
 # solution soon.			--simo
-AC_OUTPUT(include/stamp-h Makefile script/findsmb ../examples/sam/Makefile)
+AC_OUTPUT(include/stamp-h Makefile script/findsmb ../examples/sam/Makefile modules/Makefile.ext_modules)
 
 #################################################
 # Print very concise instructions on building/use
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/dynconfig.c HEAD-fix/source/dynconfig.c
--- HEAD/source/dynconfig.c	Tue Nov  5 16:25:26 2002
+++ HEAD-fix/source/dynconfig.c	Fri Nov 22 09:22:08 2002
@@ -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() **/
+const pstring dyn_MODULESDIR = MODULESDIR;
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/lib/module.c HEAD-fix/source/lib/module.c
--- HEAD/source/lib/module.c	Wed Nov 13 19:52:32 2002
+++ HEAD-fix/source/lib/module.c	Fri Nov 22 10:00:56 2002
@@ -27,28 +27,37 @@ NTSTATUS smb_load_module(const char *mod
 	void *handle;
 	init_module_function *init;
 	NTSTATUS nt_status;
+	pstring full_module_name;
+
+	if (module_name[0]=='/') {
+		pstrcpy(full_module_name,module_name);
+	} else {
+		pstrcpy(full_module_name,lp_modules_path());
+		pstrcat(full_module_name,"/");
+		pstrcat(full_module_name,module_name);
+	}
 
 	/* Always try to use LAZY symbol resolving; if the plugin has 
 	 * backwards compatibility, there might be symbols in the 
 	 * plugin referencing to old (removed) functions
 	 */
-	handle = sys_dlopen(module_name, RTLD_LAZY);
+	handle = sys_dlopen(full_module_name, RTLD_LAZY);
 
 	if(!handle) {
-		DEBUG(0, ("Error loading module '%s': %s\n", module_name, sys_dlerror()));
+		DEBUG(0, ("Error loading module '%s': %s\n", full_module_name, sys_dlerror()));
 		return NT_STATUS_UNSUCCESSFUL;
 	}
 
 	init = sys_dlsym(handle, "init_module");
 
 	if(!init) {
-		DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n", module_name, sys_dlerror()));
+		DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n", full_module_name, sys_dlerror()));
 		return NT_STATUS_UNSUCCESSFUL;
 	}
 
 	nt_status = init();
 
-	DEBUG(2, ("Module '%s' loaded\n", module_name));
+	DEBUG(2, ("Module '%s' loaded\n", full_module_name));
 
 	return nt_status;
 }
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/modules/.cvsignore HEAD-fix/source/modules/.cvsignore
--- HEAD/source/modules/.cvsignore	Thu Jan  1 01:00:00 1970
+++ HEAD-fix/source/modules/.cvsignore	Fri Nov 22 11:33:55 2002
@@ -0,0 +1,4 @@
+*.po
+*.po32
+Makefile.ext_modules
+Makefile.ext_modules.in
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/modules/Makefile.ext_modules.in HEAD-fix/source/modules/Makefile.ext_modules.in
--- HEAD/source/modules/Makefile.ext_modules.in	Thu Jan  1 01:00:00 1970
+++ HEAD-fix/source/modules/Makefile.ext_modules.in	Fri Nov 22 11:32:07 2002
@@ -0,0 +1,21 @@
+#
+# This file should not updated to CVS
+#
+#
+
+#
+# list each extern module 
+# (witch is not in the CVS) here 
+#
+#EXT_MODULES = bin/smbtest. at SHLIBEXT@
+EXT_MODULES = 
+
+#
+# section for one extern module
+# (e.g. modules/smbtest.so)
+#EXT_MODULE_SMBTEST_OBJ = modules/smbtest.o
+
+#bin/smbtest. at SHLIBEXT@: $(EXT_MODULE_SMBTEST_OBJ)
+#	@echo "Building plugin $@"
+#	@$(SHLD) $(LDSHFLAGS) -o $@ $(EXT_MODULE_SMBTEST_OBJ) \
+#		@SONAMEFLAG@`basename $@`
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/param/loadparm.c HEAD-fix/source/param/loadparm.c
--- HEAD/source/param/loadparm.c	Fri Nov 22 08:13:31 2002
+++ HEAD-fix/source/param/loadparm.c	Fri Nov 22 10:15:47 2002
@@ -111,6 +111,7 @@ typedef struct
 	char *szPrivateDir;
 	char **szPassdbBackend;
 	char **szSamBackend;
+	char **szModulesPath;
 	char **szModules;
 	char *szPasswordServer;
 	char *szSocketOptions;
@@ -796,6 +797,7 @@ 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 path", P_STRING, P_GLOBAL, &Globals.szModulesPath, NULL, NULL, FLAG_BASIC | FLAG_GLOBAL},
 	{"modules", P_LIST, P_GLOBAL, &Globals.szModules, NULL, NULL, FLAG_BASIC | FLAG_GLOBAL},
 
 	{"Logging Options", P_SEP, P_SEPARATOR},
@@ -1382,6 +1384,8 @@ static void init_globals(void)
 	Globals.ldap_ssl = LDAP_SSL_ON;
 	Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF;
 
+	string_set(&Globals.szModulesPath, dyn_MODULESDIR);
+
 /* these parameters are set to defaults that are more appropriate
    for the increasing samba install base:
 
@@ -1566,6 +1570,7 @@ 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_STRING(lp_modules_path, &Globals.szModulesPath)
 FN_GLOBAL_LIST(lp_modules, &Globals.szModules)
 FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
 FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)


More information about the samba-technical mailing list