diff options
author | Volker Lendecke <vl@sernet.de> | 2007-10-28 11:58:26 +0100 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2007-10-28 12:30:44 -0400 |
commit | 6ca0d8124c26edec1d9232d7380c4b66a2915cad (patch) | |
tree | 55599b6f5f9e8471c47c2e3bd15de3120543ea67 /source3/smbd | |
parent | d4307679b95088d05f0abad440de5e961ee965df (diff) | |
download | samba-6ca0d8124c26edec1d9232d7380c4b66a2915cad.tar.gz samba-6ca0d8124c26edec1d9232d7380c4b66a2915cad.tar.bz2 samba-6ca0d8124c26edec1d9232d7380c4b66a2915cad.zip |
Enable vfs objects = /full/path/to/object.so
Right now I'm testing a vfs object. I can't right now in make test, because
"vfs objects" assumes the .so files to be in $libdir/vfs. This patch parses the
module name out of the object name in case it starts with "/". The module name
is assumed to be the last path component's basename.
(This used to be commit 95cc019af775a6ab28ea602ad767fa54d7c86197)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/vfs.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index b43f37e716..e862710b6c 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -44,6 +44,8 @@ static struct vfs_init_function_entry *backends = NULL; static struct vfs_init_function_entry *vfs_find_backend_entry(const char *name) { struct vfs_init_function_entry *entry = backends; + + DEBUG(10, ("vfs_find_backend_entry called for %s\n", name)); while(entry) { if (strcmp(entry->name, name)==0) return entry; @@ -109,6 +111,7 @@ static inline void vfs_set_operation(struct vfs_ops * vfs, vfs_op_type which, bool vfs_init_custom(connection_struct *conn, const char *vfs_object) { vfs_op_tuple *ops; + char *module_path = NULL; char *module_name = NULL; char *module_param = NULL, *p; int i; @@ -126,9 +129,9 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object) DEBUG(3, ("Initialising custom vfs hooks from [%s]\n", vfs_object)); - module_name = smb_xstrdup(vfs_object); + module_path = smb_xstrdup(vfs_object); - p = strchr_m(module_name, ':'); + p = strchr_m(module_path, ':'); if (p) { *p = 0; @@ -136,31 +139,48 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object) trim_char(module_param, ' ', ' '); } - trim_char(module_name, ' ', ' '); + trim_char(module_path, ' ', ' '); + + module_name = smb_xstrdup(module_path); + + if ((module_name[0] == '/') && + (strcmp(module_path, DEFAULT_VFS_MODULE_NAME) != 0)) { + + /* + * Extract the module name from the path. Just use the base + * name of the last path component. + */ + + SAFE_FREE(module_name); + module_name = smb_xstrdup(strrchr_m(module_path, '/')+1); + + p = strchr_m(module_name, '.'); + + if (p != NULL) { + *p = '\0'; + } + } /* First, try to load the module with the new module system */ if((entry = vfs_find_backend_entry(module_name)) || - (NT_STATUS_IS_OK(smb_probe_module("vfs", module_name)) && + (NT_STATUS_IS_OK(smb_probe_module("vfs", module_path)) && (entry = vfs_find_backend_entry(module_name)))) { DEBUGADD(5,("Successfully loaded vfs module [%s] with the new modules system\n", vfs_object)); if ((ops = entry->vfs_op_tuples) == NULL) { DEBUG(0, ("entry->vfs_op_tuples==NULL for [%s] failed\n", vfs_object)); - SAFE_FREE(module_name); - return False; + goto fail; } } else { DEBUG(0,("Can't find a vfs module [%s]\n",vfs_object)); - SAFE_FREE(module_name); - return False; + goto fail; } handle = TALLOC_ZERO_P(conn->mem_ctx,vfs_handle_struct); if (!handle) { DEBUG(0,("TALLOC_ZERO() failed!\n")); - SAFE_FREE(module_name); - return False; + goto fail; } memcpy(&handle->vfs_next, &conn->vfs, sizeof(struct vfs_ops)); handle->conn = conn; @@ -183,8 +203,14 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object) vfs_set_operation(&conn->vfs, ops[i].type, handle, ops[i].op); } + SAFE_FREE(module_path); SAFE_FREE(module_name); return True; + + fail: + SAFE_FREE(module_path); + SAFE_FREE(module_name); + return False; } /***************************************************************** |