The branch, master has been updated via ad96c11182db093fe41a4f6177580e70271574ea (commit) via 86b1a4cb868ee646326bff8b5c3ba807fb0556be (commit) via 32ee9767088fcd395e1f1a22d781d33b076aa78b (commit) via 637901c24288740d51f28e2378c02d956dd7b17d (commit) via c870043b27dff10010e45358d924cbdd688f6555 (commit) from 42c3eca0d5ccbe116d7b101bc9adaa3b39ca5da2 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit ad96c11182db093fe41a4f6177580e70271574ea Author: Tim Prouty <tpro...@samba.org> Date: Fri Aug 28 22:53:09 2009 +0000 s4 torture: Fix RAW-STREAMS to request more specific permissions This allows RAW-STREAMS to pass when the user isn't root on some systems that don't give full access rights to non-root users. commit 86b1a4cb868ee646326bff8b5c3ba807fb0556be Author: Tim Prouty <tpro...@samba.org> Date: Fri Aug 28 22:53:05 2009 +0000 s3: Add more helpful debugging to some of the streams code commit 32ee9767088fcd395e1f1a22d781d33b076aa78b Author: Aravind Srinivasan <aravind.sriniva...@isilon.com> Date: Wed Sep 23 20:37:04 2009 +0000 vfs catia: Fix a NULL dereference when CATIA is loaded with no mappings specified. When we use the CATIA vfs module and don't have any mapping specified, we return NULL for the mapped_name, thereby resulting in segfaults. When we don't have catia mapping, we should just use the old name instead of returning NULL for the mapped_name. Signed-off-by: Tim Prouty <tpro...@samba.org> commit 637901c24288740d51f28e2378c02d956dd7b17d Author: Aravind Srinivasan <aravind.sriniva...@isilon.com> Date: Thu Sep 3 20:46:10 2009 +0000 vfs catia: Fix the double translation that was happening with createfile and open. Since the catia translation is implemented for open, it should not also be done in createfile. By removing createfile from catia, translation is now done correctly for the primary open path. In order to support systems that have custom createfile implementations that don't eventually call SMB_VFS_OPEN, SMB_VFS_TRANSLATE_NAME has been expanded to take an additional argument that specifies direction. Signed-off-by: Tim Prouty <tpro...@samba.org> commit c870043b27dff10010e45358d924cbdd688f6555 Author: Aravind Srinivasan <aravind.sriniva...@isilon.com> Date: Wed Sep 2 17:20:21 2009 +0000 vfs catia: Fix a possible NULL dereference Also free some unfreed memory. Signed-off-by: Tim Prouty <tpro...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/vfs.h | 11 +++- source3/include/vfs_macros.h | 8 +- source3/modules/onefs_streams.c | 23 ++++++ source3/modules/onefs_system.c | 27 ++++++-- source3/modules/vfs_catia.c | 138 ++++++++++++++----------------------- source3/modules/vfs_full_audit.c | 5 +- source3/smbd/filename.c | 2 +- source3/smbd/vfs.c | 8 ++- source4/torture/raw/streams.c | 3 +- 9 files changed, 120 insertions(+), 105 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 38d60a0..ed49d1f 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -158,6 +158,11 @@ struct smb_filename; handle = handle->next; \ } +enum vfs_translate_direction { + vfs_translate_to_unix = 0, + vfs_translate_to_windows +}; + /* Available VFS operations. These values must be in sync with vfs_ops struct (struct vfs_fn_pointers and struct vfs_handle_pointers inside of struct vfs_ops). @@ -302,7 +307,8 @@ struct vfs_fn_pointers { struct lock_struct *plock); NTSTATUS (*translate_name)(struct vfs_handle_struct *handle, - char **mapped_name); + char **mapped_name, + enum vfs_translate_direction direction); /* NT ACL operations. */ @@ -650,7 +656,8 @@ void smb_vfs_call_strict_unlock(struct vfs_handle_struct *handle, struct files_struct *fsp, struct lock_struct *plock); NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle, - char **mapped_name); + char **mapped_name, + enum vfs_translate_direction direction); NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 security_info, diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 7cc5579..8ca7f37 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -345,10 +345,10 @@ #define SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock) \ smb_vfs_call_strict_unlock((handle)->next, (fsp), (plock)) -#define SMB_VFS_TRANSLATE_NAME(conn, mapped_name) \ - smb_vfs_call_translate_name((conn)->vfs_handles, (mapped_name)) -#define SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name) \ - smb_vfs_call_translate_name((handle)->next, (mapped_name)) +#define SMB_VFS_TRANSLATE_NAME(conn, mapped_name, direction) \ + smb_vfs_call_translate_name((conn)->vfs_handles, (mapped_name), (direction)) +#define SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction) \ + smb_vfs_call_translate_name((handle)->next, (mapped_name), (direction)) #define SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock) \ smb_vfs_call_strict_unlock((handle)->next, (fsp), (plock)) diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c index da26661..fa65b51 100644 --- a/source3/modules/onefs_streams.c +++ b/source3/modules/onefs_streams.c @@ -71,6 +71,13 @@ NTSTATUS onefs_stream_prep_smb_fname(TALLOC_CTX *ctx, stream_name, &smb_fname_in->st, smb_fname_out); TALLOC_FREE(stream_name); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(5, ("Failed to prep stream name for %s: %s\n", + *smb_fname_out ? + smb_fname_str_dbg(*smb_fname_out) : "NULL", + nt_errstr(status))); + } return status; } @@ -96,6 +103,9 @@ static int get_stream_dir_fd(connection_struct *conn, const char *base, int dir_fd; int saved_errno; + DEBUG(10, ("Getting stream directory fd: %s (%d)\n", base, + base_fdp ? *base_fdp : -1)); + /* If a valid base_fdp was given, use it. */ if (base_fdp && *base_fdp >= 0) { base_fd = *base_fdp; @@ -115,6 +125,8 @@ static int get_stream_dir_fd(connection_struct *conn, const char *base, 0, NULL); if (base_fd < 0) { + DEBUG(5, ("Failed getting base fd: %s\n", + strerror(errno))); return -1; } } @@ -147,6 +159,11 @@ static int get_stream_dir_fd(connection_struct *conn, const char *base, *base_fdp = base_fd; } + if (dir_fd < 0) { + DEBUG(5, ("Failed getting stream directory fd: %s\n", + strerror(errno))); + } + return dir_fd; } @@ -173,6 +190,9 @@ int onefs_rename(vfs_handle_struct *handle, /* For now don't allow renames from or to the default stream. */ if (is_ntfs_default_stream_smb_fname(smb_fname_src) || is_ntfs_default_stream_smb_fname(smb_fname_dst)) { + DEBUG(3, ("Unable to rename to/from a default stream: %s -> " + "%s\n", smb_fname_str_dbg(smb_fname_src), + smb_fname_str_dbg(smb_fname_dst))); errno = ENOSYS; goto done; } @@ -311,6 +331,9 @@ static int stat_stream(struct connection_struct *conn, const char *base, /* Stat the stream. */ ret = onefs_sys_fstat_at(dir_fd, stream, sbuf, flags); if (ret != -1) { + DEBUG(10, ("stat of stream '%s' failed: %s\n", stream, + strerror(errno))); + } else { /* Now stat the base file and merge the results. */ ret = onefs_sys_fstat(base_fd, &base_sbuf); if (ret != -1) { diff --git a/source3/modules/onefs_system.c b/source3/modules/onefs_system.c index d2f853f..33bec26 100644 --- a/source3/modules/onefs_system.c +++ b/source3/modules/onefs_system.c @@ -98,9 +98,23 @@ int onefs_sys_create_file(connection_struct *conn, int ret_fd = -1; uint32_t onefs_dos_attributes; struct ifs_createfile_flags cf_flags = CF_FLAGS_NONE; + char *mapped_name = NULL; + NTSTATUS result; START_PROFILE(syscall_createfile); + /* Translate the name to UNIX before calling ifs_createfile */ + mapped_name = talloc_strdup(talloc_tos(), path); + if (mapped_name == NULL) { + errno = ENOMEM; + goto out; + } + result = SMB_VFS_TRANSLATE_NAME(conn, &mapped_name, + vfs_translate_to_unix); + if (!NT_STATUS_IS_OK(result)) { + goto out; + } + /* Setup security descriptor and get secinfo. */ if (sd != NULL) { NTSTATUS status; @@ -148,7 +162,7 @@ int onefs_sys_create_file(connection_struct *conn, PARM_ALLOW_EXECUTE_ALWAYS_DEFAULT) && (open_access_mask & FILE_EXECUTE)) { - DEBUG(3, ("Stripping execute bit from %s: (0x%x)\n", path, + DEBUG(3, ("Stripping execute bit from %s: (0x%x)\n", mapped_name, open_access_mask)); /* Strip execute. */ @@ -164,31 +178,31 @@ int onefs_sys_create_file(connection_struct *conn, open_access_mask)); } - DEBUG(10,("onefs_sys_create_file: base_fd = %d, fname = %s" + DEBUG(10,("onefs_sys_create_file: base_fd = %d, fname = %s " "open_access_mask = 0x%x, flags = 0x%x, mode = 0%o, " "desired_oplock = %s, id = 0x%x, secinfo = 0x%x, sd = %p, " "dos_attributes = 0x%x, path = %s, " - "default_acl=%s\n", base_fd, path, + "default_acl=%s\n", base_fd, mapped_name, (unsigned int)open_access_mask, (unsigned int)flags, (unsigned int)mode, onefs_oplock_str(onefs_oplock), (unsigned int)id, sec_info_effective, sd, - (unsigned int)onefs_dos_attributes, path, + (unsigned int)onefs_dos_attributes, mapped_name, cf_flags_and_bool(cf_flags, CF_FLAGS_DEFAULT_ACL) ? "true" : "false")); /* Initialize smlock struct for files/dirs but not internal opens */ if (!(oplock_request & INTERNAL_OPEN_ONLY)) { - smlock_init(conn, &sml, is_executable(path), access_mask, + smlock_init(conn, &sml, is_executable(mapped_name), access_mask, share_access, create_options); psml = &sml; } smlock_dump(10, psml); - ret_fd = ifs_createfile(base_fd, path, + ret_fd = ifs_createfile(base_fd, mapped_name, (enum ifs_ace_rights)open_access_mask, flags & ~O_ACCMODE, mode, onefs_oplock, id, psml, sec_info_effective, pifs_sd, onefs_dos_attributes, cf_flags, &onefs_granted_oplock); @@ -206,6 +220,7 @@ int onefs_sys_create_file(connection_struct *conn, out: END_PROFILE(syscall_createfile); aclu_free_sd(pifs_sd, false); + TALLOC_FREE(mapped_name); return ret_fd; } diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 0917812..14e404f 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -28,9 +28,6 @@ #include "includes.h" -#define TO_UNIX 0 -#define TO_WINDOWS 1 - #define GLOBAL_SNUM 0xFFFFFFF #define MAP_SIZE 0xFF #define MAP_NUM 0x101 /* max unicode charval / MAP_SIZE */ @@ -61,8 +58,8 @@ static bool build_table(struct char_mappings **cmaps, int value) return False; for (i = 0; i < MAP_SIZE;i++) { - (*cmaps)->entry[i][TO_UNIX] = start + i; - (*cmaps)->entry[i][TO_WINDOWS] = start + i; + (*cmaps)->entry[i][vfs_translate_to_unix] = start + i; + (*cmaps)->entry[i][vfs_translate_to_windows] = start + i; } return True; @@ -76,11 +73,11 @@ static void set_tables(struct char_mappings **cmaps, /* set unix -> windows */ i = T_OFFSET(unix_map); - cmaps[T_PICK(unix_map)]->entry[i][TO_WINDOWS] = windows_map; + cmaps[T_PICK(unix_map)]->entry[i][vfs_translate_to_windows] = windows_map; /* set windows -> unix */ i = T_OFFSET(windows_map); - cmaps[T_PICK(windows_map)]->entry[i][TO_UNIX] = unix_map; + cmaps[T_PICK(windows_map)]->entry[i][vfs_translate_to_unix] = unix_map; } static bool build_ranges(struct char_mappings **cmaps, @@ -227,8 +224,15 @@ static NTSTATUS catia_string_replace_allocate(connection_struct *conn, size_t converted_size; TALLOC_CTX *ctx = talloc_tos(); - if (!init_mappings(conn, &selected)) + if (!init_mappings(conn, &selected)) { + /* No mappings found. Just use the old name */ + *mapped_name = talloc_strdup(NULL, name_in); + if (!*mapped_name) { + errno = ENOMEM; + return NT_STATUS_NO_MEMORY; + } return NT_STATUS_OK; + } if ((push_ucs2_talloc(ctx, &tmpbuf, name_in, &converted_size)) == -1) { @@ -266,7 +270,7 @@ static SMB_STRUCT_DIR *catia_opendir(vfs_handle_struct *handle, SMB_STRUCT_DIR *ret; status = catia_string_replace_allocate(handle->conn, fname, - &name_mapped, TO_UNIX); + &name_mapped, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return NULL; @@ -283,7 +287,8 @@ static SMB_STRUCT_DIR *catia_opendir(vfs_handle_struct *handle, * "WINDOWS displayable" name */ static NTSTATUS catia_translate_name(vfs_handle_struct *handle, - char **mapped_name) + char **mapped_name, + enum vfs_translate_direction direction) { char *name = NULL; NTSTATUS ret; @@ -301,14 +306,14 @@ static NTSTATUS catia_translate_name(vfs_handle_struct *handle, } TALLOC_FREE(*mapped_name); ret = catia_string_replace_allocate(handle->conn, name, - mapped_name, TO_WINDOWS); + mapped_name, direction); TALLOC_FREE(name); if (!NT_STATUS_IS_OK(ret)) { return ret; } - ret = SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name); + ret = SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction); return ret; } @@ -327,7 +332,7 @@ static int catia_open(vfs_handle_struct *handle, tmp_base_name = smb_fname->base_name; status = catia_string_replace_allocate(handle->conn, smb_fname->base_name, - &name_mapped, TO_UNIX); + &name_mapped, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -341,51 +346,6 @@ static int catia_open(vfs_handle_struct *handle, return ret; } -/* @internal - Isilon create file support */ -static NTSTATUS catia_createfile(vfs_handle_struct *handle, - struct smb_request *req, - uint16_t root_dir_fid, - struct smb_filename *smb_fname, - uint32_t access_mask, - uint32_t share_access, - uint32_t create_disposition, - uint32_t create_options, - uint32_t file_attributes, - uint32_t oplock_request, - uint64_t allocation_size, - struct security_descriptor *sd, - struct ea_list *ea_list, - files_struct **result, - int *pinfo) -{ - char *name_mapped = NULL; - char *tmp_base_name; - NTSTATUS ret; - - ret = catia_string_replace_allocate(handle->conn, smb_fname->base_name, - &name_mapped, TO_UNIX); - if (!NT_STATUS_IS_OK(ret)) { - errno = map_errno_from_nt_status(ret); - return ret; - } - - tmp_base_name = smb_fname->base_name; - DEBUG(5, ("catia_createfile converted %s->%s (orginally %s)\n", - tmp_base_name, name_mapped, tmp_base_name)); - smb_fname->base_name = name_mapped; - ret = SMB_VFS_NEXT_CREATE_FILE(handle, req, root_dir_fid, - smb_fname, access_mask, share_access, - create_disposition, create_options, - file_attributes, oplock_request, - allocation_size, sd, ea_list, - result, pinfo); - - smb_fname->base_name = tmp_base_name; - TALLOC_FREE(name_mapped); - - return ret; -} - static int catia_rename(vfs_handle_struct *handle, const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_dst) @@ -393,12 +353,14 @@ static int catia_rename(vfs_handle_struct *handle, TALLOC_CTX *ctx = talloc_tos(); struct smb_filename *smb_fname_src_tmp = NULL; struct smb_filename *smb_fname_dst_tmp = NULL; + char *src_name_mapped = NULL; + char *dst_name_mapped = NULL; NTSTATUS status; int ret = -1; status = catia_string_replace_allocate(handle->conn, smb_fname_src->base_name, - &(smb_fname_src_tmp->base_name), TO_UNIX); + &src_name_mapped, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -406,7 +368,7 @@ static int catia_rename(vfs_handle_struct *handle, status = catia_string_replace_allocate(handle->conn, smb_fname_dst->base_name, - &(smb_fname_dst_tmp->base_name), TO_UNIX); + &dst_name_mapped, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -426,6 +388,8 @@ static int catia_rename(vfs_handle_struct *handle, goto out; } + smb_fname_src_tmp->base_name = src_name_mapped; + smb_fname_dst_tmp->base_name = dst_name_mapped; DEBUG(10, ("converted old name: %s\n", smb_fname_str_dbg(smb_fname_src_tmp))); DEBUG(10, ("converted new name: %s\n", @@ -434,6 +398,8 @@ static int catia_rename(vfs_handle_struct *handle, ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp, smb_fname_dst_tmp); out: + TALLOC_FREE(src_name_mapped); + TALLOC_FREE(dst_name_mapped); TALLOC_FREE(smb_fname_src_tmp); TALLOC_FREE(smb_fname_dst_tmp); return ret; @@ -449,7 +415,7 @@ static int catia_stat(vfs_handle_struct *handle, status = catia_string_replace_allocate(handle->conn, smb_fname->base_name, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -475,7 +441,7 @@ static int catia_lstat(vfs_handle_struct *handle, status = catia_string_replace_allocate(handle->conn, smb_fname->base_name, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -501,7 +467,7 @@ static int catia_unlink(vfs_handle_struct *handle, status = catia_string_replace_allocate(handle->conn, smb_fname->base_name, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -532,7 +498,7 @@ static int catia_chown(vfs_handle_struct *handle, int ret; status = catia_string_replace_allocate(handle->conn, path, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -554,7 +520,7 @@ static int catia_lchown(vfs_handle_struct *handle, int ret; status = catia_string_replace_allocate(handle->conn, path, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -574,7 +540,7 @@ static int catia_rmdir(vfs_handle_struct *handle, int ret; status = catia_string_replace_allocate(handle->conn, path, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -595,7 +561,7 @@ static int catia_mkdir(vfs_handle_struct *handle, int ret; status = catia_string_replace_allocate(handle->conn, path, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -615,7 +581,7 @@ static int catia_chdir(vfs_handle_struct *handle, int ret; status = catia_string_replace_allocate(handle->conn, path, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -638,7 +604,7 @@ static int catia_ntimes(vfs_handle_struct *handle, status = catia_string_replace_allocate(handle->conn, smb_fname->base_name, - &name, TO_UNIX); + &name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return -1; @@ -652,6 +618,7 @@ static int catia_ntimes(vfs_handle_struct *handle, smb_fname_tmp->base_name = name; ret = SMB_VFS_NEXT_NTIMES(handle, smb_fname_tmp, ft); + TALLOC_FREE(name); TALLOC_FREE(smb_fname_tmp); return ret; @@ -666,7 +633,7 @@ catia_realpath(vfs_handle_struct *handle, const char *path, char *ret = NULL; status = catia_string_replace_allocate(handle->conn, path, - &mapped_name, TO_UNIX); + &mapped_name, vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return NULL; -- Samba Shared Repository