- Support absolute paths in vfs and charset modules
authorJelmer Vernooij <jelmer@samba.org>
Mon, 31 Mar 2003 15:06:34 +0000 (15:06 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 31 Mar 2003 15:06:34 +0000 (15:06 +0000)
- Fix typo in Makefile.in
- Fix compatibility with older vfs modules (from patch by metze)
- Build some modules shared by default and some static (and fall
  back to static when dlopen() is not available)
(This used to be commit aa36f462d95f8a3a3a81a89c210b98a6f9fd295f)

source3/Makefile.in
source3/configure.in
source3/lib/iconv.c
source3/lib/module.c
source3/smbd/conn.c
source3/smbd/vfs.c

index 75a8db30c2360f637710891357187266b09d19f1..b05e7692cd53b52123d3d0be4c854c6db37965e8 100644 (file)
@@ -1028,7 +1028,7 @@ bin/audit.@SHLIBEXT@: $(VFS_AUDIT_OBJ)
 
 bin/extd_audit.@SHLIBEXT@: $(VFS_EXTD_AUDIT_OBJ)
        @echo "Building plugin $@"
-       @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_AUDIT_OBJ) \
+       @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_EXTD_AUDIT_OBJ) \
                @SONAMEFLAG@`basename $@`
 
 bin/recycle.@SHLIBEXT@: $(VFS_RECYCLE_OBJ)
index 20c3b2ef0454d7f6f5539092c9da09ae52c7a27f..98e01f5bd5a99f3cd44fa2eaf4e2134172ce98ca 100644 (file)
@@ -239,7 +239,11 @@ AC_VALIDATE_CACHE_SYSTEM_TYPE
 DYNEXP=
 
 dnl Add modules that have to be built by default here
-default_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_recycle vfs_audit vfs_extd_audit vfs_fake_perms vfs_netatalk"
+dnl These have to be built static:
+default_static_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
+
+dnl These are preferably build shared, and static if dlopen() is not available
+default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_fake_perms vfs_netatalk"
 
 #
 # Config CPPFLAG settings for strange OS's that must be set
@@ -2255,7 +2259,7 @@ if test x"$with_ldap_support" = x"yes"; then
   if test x$have_ldap != xyes; then
   AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
        AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])])
-       AC_CHECK_HEADERS([ldap.h lber.h], [default_modules="$default_modules pdb_ldap"])
+       AC_CHECK_HEADERS([ldap.h lber.h], [default_static_modules="$default_static_modules pdb_ldap"])
 
        ########################################################
        # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
@@ -2272,11 +2276,11 @@ fi
 
 ########################################################
 # Compile with MySQL support?
-AM_PATH_MYSQL([0.11.0],[default_modules="$default_modules pdb_mysql"],[])
+AM_PATH_MYSQL([0.11.0],[default_shared_modules="$default_shared_modules pdb_mysql"],[])
 
 ########################################################
 # Compile with XML support?
-AM_PATH_XML2([2.0.0],[default_modules="$default_modules pdb_xml"],[])
+AM_PATH_XML2([2.0.0],[default_shared_modules="$default_shared_modules pdb_xml"],[])
 
 #################################################
 # check for automount support
@@ -3333,13 +3337,22 @@ AC_ARG_WITH(python,
   esac ])
 AC_SUBST(PYTHON)
 
-for i in `echo $default_modules | sed -e's/,/ /g'`
+for i in `echo $default_static_modules | sed -e's/,/ /g'`
 do
-       dnl Set to shared instead of static when dlopen() is available?
        eval MODULE_DEFAULT_$i=STATIC
 done
 
-# Always built these modules static
+for i in `echo $default_shared_modules | sed -e's/,/ /g'`
+do
+       dnl Fall back to static if dlopen() is not available
+       eval MODULE_DEFAULT_$i=STATIC
+
+       if test x"$ac_cv_func_dlopen" = xyes; then
+               eval MODULE_DEFAULT_$i=SHARED
+       fi
+done
+
+dnl Always built these modules static
 MODULE_pdb_guest=STATIC
 MODULE_rpc_spoolss=STATIC
 MODULE_rpc_srv=STATIC
index 6a397f2d9e4b677b1f113ff1c32006a3c2155fe2..a37441b9fabfbc3ced30981e8f1eee05bc3fb33c 100644 (file)
@@ -66,8 +66,12 @@ static struct charset_functions *charsets = NULL;
 static struct charset_functions *find_charset_functions(const char *name) 
 {
        struct charset_functions *c = charsets;
+       pstring stripped;
+
+       module_path_get_name(name, stripped);
+       
        while(c) {
-               if (strcasecmp(name, c->name) == 0)return c;
+               if (strequal(stripped, c->name) == 0)return c;
                c = c->next;
        }
 
@@ -103,9 +107,8 @@ void lazy_initialize_iconv(void)
                initialized = True;
                for(i = 0; builtin_functions[i].name; i++) 
                        smb_register_charset(&builtin_functions[i]);
+               static_init_charset;
        }
-
-       static_init_charset;
 }
 
 /* if there was an error then reset the internal state,
index e400945a8bd343cd05e1c5b3a5f8f5f0332f5d09..700de56953ee945eb1315cae46715d3c231ea47d 100644 (file)
@@ -132,7 +132,7 @@ void module_path_get_name(char *path, pstring name)
        char *s;
 
        /* First, make the path relative */
-       s = strrchr_m(path, '/');
+       s = strrchr(path, '/');
        if(s) pstrcpy(name, s+1);
        else pstrcpy(name, path);
        
index 2a77e23e73dd8be518209588382212028f857660..b6c7aa1076e3bd47bbe70a50a0b6e297da92be36 100644 (file)
@@ -201,10 +201,11 @@ void conn_free(connection_struct *conn)
        /* Free vfs_connection_struct */
        handle = conn->vfs_private;
        while(handle) {
+               /* Only call dlclose for the old modules */
                if (handle->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 {
@@ -212,7 +213,6 @@ void conn_free(connection_struct *conn)
                        }
                        sys_dlclose(handle->handle);
                }
-
                DLIST_REMOVE(conn->vfs_private, handle);
                thandle = handle->next;
                SAFE_FREE(handle);
index 119e2e2f9a08505bb6f160aa185082d36f537f30..465d14abba413ae6c503dbb3bec802d68bde0067 100644 (file)
@@ -141,9 +141,12 @@ static struct vfs_ops default_vfs_ops = {
 struct vfs_init_function_entry *vfs_find_backend_entry(const char *name)
 {
    struct vfs_init_function_entry *entry = backends;
+   pstring stripped;
+
+   module_path_get_name(name, stripped);
 
    while(entry) {
-       if (strequal(entry->name, name)) return entry;
+       if (strequal(entry->name, stripped)) return entry;
        entry = entry->next;
    }
 
@@ -200,7 +203,7 @@ static void vfs_init_default(connection_struct *conn)
  Function to load old VFS modules. Should go away after a while.
  **************************************************************************/
 
-static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
+static vfs_op_tuple *vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
 {
        int vfs_version = -1;
        vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *);
@@ -208,7 +211,7 @@ static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
 
        if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) {
                DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror()));
-               return False;
+               return NULL;
        }
 
        /* Get handle on vfs_init() symbol */
@@ -218,21 +221,21 @@ static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
        if (init_fptr == NULL) {
                DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object));
                sys_dlclose(conn->vfs_private->handle);
-               return False;
+               return NULL;
        }
 
        /* Initialise vfs_ops structure */
        if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) {
                DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object));
                sys_dlclose(conn->vfs_private->handle);
-               return False;
+               return NULL;
        }
 
        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 ));
                sys_dlclose(conn->vfs_private->handle);
-               return False;
+               return NULL;
        }
 
        if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) {
@@ -240,10 +243,10 @@ static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object)
                                  Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n",
                                  vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version ));
                sys_dlclose(conn->vfs_private->handle);
-               return False;
+               return NULL;
        }
        
-       return True;
+       return ops;
 }
 
 
@@ -277,10 +280,14 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object)
                /* If that doesn't work, fall back to the old system 
                 * (This part should go away after a while, it's only here 
                 * for backwards compatibility) */
-               DEBUG(2, ("Can't load module with new modules system, falling back to old\n"));
-               if (!vfs_load_old_plugin(conn, vfs_object)) return False;
+               DEBUG(2, ("Can't load module %s with new modules system, falling back to compatibility\n",
+                       vfs_object));
+               if ((ops = vfs_load_old_plugin(conn, vfs_object)) == NULL) {
+                       DEBUG(0, ("vfs init function from %s failed\n", vfs_object));
+                       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) {