diff options
-rw-r--r-- | source3/Makefile.in | 25 | ||||
-rw-r--r-- | source3/configure.in | 33 | ||||
-rw-r--r-- | source3/include/passdb.h | 5 | ||||
-rw-r--r-- | source3/passdb/pdb_interface.c | 7 | ||||
-rw-r--r-- | source3/passdb/pdb_plugin.c | 72 |
5 files changed, 122 insertions, 20 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 449f8d25de..ed82d2f633 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -16,6 +16,7 @@ CPPFLAGS=@CPPFLAGS@ LDFLAGS=@LDFLAGS@ LDSHFLAGS=@LDSHFLAGS@ @LDFLAGS@ @CFLAGS@ AWK=@AWK@ +DYNEXP=@DYNEXP@ TERMLDFLAGS=@TERMLDFLAGS@ TERMLIBS=@TERMLIBS@ @@ -188,7 +189,7 @@ LOCKING_OBJ = locking/locking.o locking/brlock.o locking/posix.o PASSDB_OBJ = passdb/passdb.o passdb/pdb_interface.o passdb/pdb_get_set.o \ passdb/machine_sid.o passdb/pdb_smbpasswd.o \ - passdb/pdb_tdb.o passdb/pdb_ldap.o \ + passdb/pdb_tdb.o passdb/pdb_ldap.o passdb/pdb_plugin.o \ passdb/pdb_nisplus.o GROUPDB_OBJ = groupdb/mapping.o @@ -556,7 +557,7 @@ bin/.dummy: bin/smbd: $(SMBD_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/nmbd: $(NMBD_OBJ) bin/.dummy @echo Linking $@ @@ -568,15 +569,15 @@ bin/wrepld: $(WREPL_OBJ) bin/.dummy bin/swat: $(SWAT_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/rpcclient: $(RPCCLIENT_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(RPCCLIENT_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(RPCCLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) bin/samsync: $(SAMSYNC_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SAMSYNC_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SAMSYNC_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) bin/smbclient: $(CLIENT_OBJ) bin/.dummy @echo Linking $@ @@ -584,7 +585,7 @@ bin/smbclient: $(CLIENT_OBJ) bin/.dummy bin/net: $(NET_OBJ) bin/.dummy @BUILD_POPT@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/smbspool: $(CUPS_OBJ) bin/.dummy @echo Linking $@ @@ -624,11 +625,11 @@ bin/smbtree: $(SMBTREE_OBJ) bin/.dummy bin/smbpasswd: $(SMBPASSWD_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/pdbedit: $(PDBEDIT_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/smbgroupedit: $(SMBGROUPEDIT_OBJ) bin/.dummy @echo Linking $@ @@ -660,7 +661,7 @@ bin/msgtest: $(MSGTEST_OBJ) bin/.dummy bin/smbcacls: $(SMBCACLS_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) bin/locktest: $(LOCKTEST_OBJ) bin/.dummy @echo Linking $@ @@ -676,7 +677,7 @@ bin/locktest2: $(LOCKTEST2_OBJ) bin/.dummy bin/rpctorture: $(RPCTORTURE_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(RPCTORTURE_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(RPCTORTURE_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) bin/debug2html: $(DEBUG2HTML_OBJ) bin/.dummy @echo Linking $@ @@ -719,7 +720,7 @@ nsswitch/libnss_wins.so: $(NSS_OBJ) bin/winbindd: $(WINBINDD_OBJ) bin/.dummy @echo Linking $@ - @$(LINK) -o $@ $(WINBINDD_OBJ) $(LIBS) + @$(LINK) -o $@ $(WINBINDD_OBJ) $(DYNEXP) $(LIBS) nsswitch/libnss_winbind.so: $(WINBIND_NSS_PICOBJS) @echo "Linking $@" @@ -737,7 +738,7 @@ bin/wbinfo: $(WBINFO_OBJ) $(PARAM_OBJ) $(LIB_OBJ) $(NOPROTO_OBJ) \ bin/pam_smbpass.@SHLIBEXT@: $(PAM_SMBPASS_PICOOBJ) @echo "Linking shared library $@" - $(SHLD) $(LDSHFLAGS) -symbolic -o $@ $(PAM_SMBPASS_PICOOBJ) -lpam $(LIBS) -lc + $(SHLD) $(LDSHFLAGS) -symbolic -o $@ $(PAM_SMBPASS_PICOOBJ) -lpam $(DYNEXP) $(LIBS) -lc bin/libmsrpc.a: $(LIBMSRPC_PICOBJ) -$(AR) -rc $@ $(LIBMSRPC_PICOBJ) diff --git a/source3/configure.in b/source3/configure.in index 90bf8a67c5..acd043294d 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -84,6 +84,13 @@ esac AC_VALIDATE_CACHE_SYSTEM_TYPE +DYNEXP= + +# I'm sure gcc supports -rdynamic +if test "$ac_cv_prog_gcc" = yes; then + DYNEXP="-rdynamic" +fi + # # Config CPPFLAG settings for strange OS's that must be set # before other tests. @@ -91,6 +98,7 @@ AC_VALIDATE_CACHE_SYSTEM_TYPE case "$host_os" in # Try to work out if this is the native HPUX compiler that uses the -Ae flag. *hpux*) + AC_PROG_CC_FLAG(Ae) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST) @@ -112,6 +120,7 @@ case "$host_os" in AC_DEFINE(USE_BOTH_CRYPT_CALLS) ;; esac + DYNEXP="-Wl,-E" ;; # @@ -157,6 +166,7 @@ case "$host_os" in ;; esac else + DYNEXP="-dc -dp" CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" fi ;; @@ -342,7 +352,7 @@ if test x"$ac_cv_lib_cups_httpConnect" = x"yes"; then fi ############################################ -# we need libdl for PAM and the new VFS code +# we need libdl for PAM, the password database plugins and the new VFS code AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"; AC_DEFINE(HAVE_LIBDL)]) @@ -700,10 +710,12 @@ case "$host_os" in *linux*) AC_DEFINE(LINUX) BLDSHARED="true" LDSHFLAGS="-shared" + DYNEXP="-Wl,--export-dynamic" PICFLAG="-fPIC" AC_DEFINE(STAT_ST_BLOCKSIZE,512) ;; - *solaris*) AC_DEFINE(SUNOS5) + *solaris*) + AC_DEFINE(SUNOS5) BLDSHARED="true" LDSHFLAGS="-h \$@ -G" if test "${ac_cv_prog_CC}" = "gcc"; then @@ -716,6 +728,7 @@ case "$host_os" in AC_DEFINE(STAT_ST_BLOCKSIZE,512) ;; *sunos*) AC_DEFINE(SUNOS4) +# WL="-Qoption ld " BLDSHARED="true" LDSHFLAGS="-Wl,-h,\$@ -G" PICFLAG="-KPIC" # Is this correct for SunOS @@ -755,15 +768,20 @@ case "$host_os" in LDSHFLAGS="-b -z +h \$@" PICFLAG="+z" fi + DYNEXP="-Wl,-E" AC_DEFINE(STAT_ST_BLOCKSIZE,8192) ;; *qnx*) AC_DEFINE(QNX);; *osf*) AC_DEFINE(OSF1) + WL="-Wl," BLDSHARED="true" LDSHFLAGS="-Wl,-soname,\$@ -shared" PICFLAG="-fPIC" ;; - *sco*) AC_DEFINE(SCO);; + *sco*) + DYNEXP="-Wl,-Bexport" + AC_DEFINE(SCO) + ;; *unixware*) AC_DEFINE(UNIXWARE) BLDSHARED="true" LDSHFLAGS="-Wl,-soname,\$@ -shared" @@ -777,17 +795,24 @@ case "$host_os" in AC_DEFINE(HAVE_MEMSET) fi LDSHFLAGS="-G" + DYNEXP="-Bexport" ;; - *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX);; + *mips-sni-sysv4*) + AC_DEFINE(RELIANTUNIX) + WL="-LD" + ;; esac ;; + *sysv5*) + WL="-Wl," if [ test "$GCC" != yes ]; then AC_DEFINE(HAVE_MEMSET) fi LDSHFLAGS="-G" ;; esac +AC_SUBST(DYNEXP) AC_MSG_RESULT($BLDSHARED) AC_MSG_CHECKING([linker flags for shared libraries]) AC_MSG_RESULT([$LDSHFLAGS]) diff --git a/source3/include/passdb.h b/source3/include/passdb.h index dfcbd46ecf..f17b043fb2 100644 --- a/source3/include/passdb.h +++ b/source3/include/passdb.h @@ -82,8 +82,11 @@ typedef struct pdb_methods } PDB_METHODS; +typedef NTSTATUS (*pdb_init_function)(struct pdb_context *, + struct pdb_methods **, + const char *); -struct pdb_init_function { +struct pdb_init_function_entry { char *name; /* Function to create a member of the authmethods list */ NTSTATUS (*init)(struct pdb_context *pdb_context, diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 13d483fc25..73532984b6 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -22,7 +22,7 @@ /** List of various built-in passdb modules */ -const struct pdb_init_function builtin_pdb_init_functions[] = { +const struct pdb_init_function_entry builtin_pdb_init_functions[] = { { "smbpasswd", pdb_init_smbpasswd }, { "smbpasswd_nua", pdb_init_smbpasswd_nua }, { "tdbsam", pdb_init_tdbsam }, @@ -32,6 +32,7 @@ const struct pdb_init_function builtin_pdb_init_functions[] = { { "nisplus", pdb_init_nisplus }, { "unix", pdb_init_unix }, #endif + { "plugin", pdb_init_plugin }, { NULL, NULL} }; @@ -198,7 +199,7 @@ NTSTATUS make_pdb_context_name(struct pdb_context **context, const char *selecte return nt_status; } - DEBUG(5,("Attempting to find an passdb backend to match %s\n", selected)); + DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name)); for (i = 0; builtin_pdb_init_functions[i].name; i++) { if (strequal(builtin_pdb_init_functions[i].name, module_name)) @@ -214,7 +215,7 @@ NTSTATUS make_pdb_context_name(struct pdb_context **context, const char *selecte break; } } - + if (!(*context)->pdb_selected) { DEBUG(0,("failed to select passdb backed!\n")); talloc_destroy((*context)->mem_ctx); diff --git a/source3/passdb/pdb_plugin.c b/source3/passdb/pdb_plugin.c new file mode 100644 index 0000000000..4ea4245398 --- /dev/null +++ b/source3/passdb/pdb_plugin.c @@ -0,0 +1,72 @@ +/* + Unix SMB/CIFS implementation. + Loadable passdb module interface. + Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Andrew Bartlett 2002 + Copyright (C) Andrew Bartlett 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. +*/ + +#include "includes.h" + +#ifdef HAVE_LIBDL + +NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location) +{ + void * dl_handle; + char *plugin_location, *plugin_name, *p; + pdb_init_function plugin_init; + + if (location == NULL) { + DEBUG(0, ("The plugin module needs an argument!\n")); + return NT_STATUS_UNSUCCESSFUL; + } + + plugin_name = smb_xstrdup(location); + p = strchr(plugin_name, ':'); + if (p) { + *p = 0; + plugin_location = p+1; + trim_string(plugin_location, " ", " "); + } else plugin_location = NULL; + trim_string(plugin_name, " ", " "); + + DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name)); + dl_handle = sys_dlopen(plugin_name, RTLD_NOW | RTLD_GLOBAL ); + if (!dl_handle) { + DEBUG(0, ("Failed to load sam plugin %s using sys_dlopen (%s)\n", plugin_name, sys_dlerror())); + return NT_STATUS_UNSUCCESSFUL; + } + + plugin_init = sys_dlsym(dl_handle, "pdb_init"); + if (!plugin_init){ + DEBUG(0, ("Failed to find function 'pdb_init' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror())); + return NT_STATUS_UNSUCCESSFUL; + } + + DEBUG(5, ("Starting sam plugin %s with location %s\n", plugin_name, plugin_location)); + return plugin_init(pdb_context, pdb_method, plugin_location); +} + +#else + +NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location) +{ + DEBUG(0, ("pdb_init_plugin: No libdl present - cannot use passdb loadable modules\n")); + return NT_STATUS_UNSUCCESSFUL; +} + +#endif |