>From 8a6053b9ac5e2e31068a09f0a9ca8d54f60d3d4a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Mar 2016 14:01:47 -0800 Subject: [PATCH 1/5] s3: VFS: vfs_fruit. If we have an fsp, use it in preference to a pathname in vfs_streaminfo. Signed-off-by: Jeremy Allison --- source3/modules/vfs_fruit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 73b5f3a..e0d1fae 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -3791,7 +3791,7 @@ static void fruit_copy_chunk_done(struct tevent_req *subreq) * streams, because we're in vfs_fruit. We don't do this async * because streams are few and small. */ - status = vfs_streaminfo(state->handle->conn, NULL, + status = vfs_streaminfo(state->handle->conn, state->src_fsp, state->src_fsp->fsp_name->base_name, req, &num_streams, &streams); if (tevent_req_nterror(req, status)) { -- 2.5.0 >From 8a14f571e1ca06c20d78b8aa434bafbece8b70d6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Mar 2016 14:07:04 -0800 Subject: [PATCH 2/5] s3: smbd: Change delete_all_streams() to take a const struct smb_filename *. Prepare for changing the interface to vfs_streaminfo(). Signed-off-by: Jeremy Allison --- source3/smbd/close.c | 15 +++++++++------ source3/smbd/open.c | 2 +- source3/smbd/proto.h | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index f3d6620..144998f 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -161,7 +161,8 @@ static NTSTATUS close_filestruct(files_struct *fsp) Delete all streams ****************************************************************************/ -NTSTATUS delete_all_streams(connection_struct *conn, const char *fname) +NTSTATUS delete_all_streams(connection_struct *conn, + const struct smb_filename *smb_fname) { struct stream_struct *stream_info = NULL; int i; @@ -169,7 +170,7 @@ NTSTATUS delete_all_streams(connection_struct *conn, const char *fname) TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; - status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), + status = vfs_streaminfo(conn, NULL, smb_fname->base_name, talloc_tos(), &num_streams, &stream_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { @@ -200,8 +201,10 @@ NTSTATUS delete_all_streams(connection_struct *conn, const char *fname) continue; } - smb_fname_stream = synthetic_smb_fname( - talloc_tos(), fname, stream_info[i].name, NULL); + smb_fname_stream = synthetic_smb_fname(talloc_tos(), + smb_fname->base_name, + stream_info[i].name, + NULL); if (smb_fname_stream == NULL) { DEBUG(0, ("talloc_aprintf failed\n")); @@ -427,7 +430,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp, if ((conn->fs_capabilities & FILE_NAMED_STREAMS) && !is_ntfs_stream_smb_fname(fsp->fsp_name)) { - status = delete_all_streams(conn, fsp->fsp_name->base_name); + status = delete_all_streams(conn, fsp->fsp_name); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("delete_all_streams failed: %s\n", @@ -1145,7 +1148,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, if ((fsp->conn->fs_capabilities & FILE_NAMED_STREAMS) && !is_ntfs_stream_smb_fname(fsp->fsp_name)) { - status = delete_all_streams(fsp->conn, fsp->fsp_name->base_name); + status = delete_all_streams(fsp->conn, fsp->fsp_name); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("delete_all_streams failed: %s\n", nt_errstr(status))); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 2cc1415..0b3a4c2 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3060,7 +3060,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* Delete streams if create_disposition requires it */ if (!new_file_created && clear_ads(create_disposition) && !is_ntfs_stream_smb_fname(smb_fname)) { - status = delete_all_streams(conn, smb_fname->base_name); + status = delete_all_streams(conn, smb_fname); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(lck); fd_close(fsp); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 8df3197..1963fb3 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -144,7 +144,8 @@ void msg_close_file(struct messaging_context *msg_ctx, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); -NTSTATUS delete_all_streams(connection_struct *conn, const char *fname); +NTSTATUS delete_all_streams(connection_struct *conn, + const struct smb_filename *smb_fname); bool recursive_rmdir(TALLOC_CTX *ctx, connection_struct *conn, struct smb_filename *smb_dname); -- 2.5.0 >From c1351104a251cfdadb4df24938cfd16d1e7f8a3b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Mar 2016 14:13:22 -0800 Subject: [PATCH 3/5] s3: smbd: Change open_streams_for_delete() to static. Not used outside of open.c Signed-off-by: Jeremy Allison --- source3/smbd/open.c | 2 +- source3/smbd/proto.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 0b3a4c2..d2e79ca 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3849,7 +3849,7 @@ void msg_file_was_renamed(struct messaging_context *msg, * If that works, delete them all by setting the delete on close and close. */ -NTSTATUS open_streams_for_delete(connection_struct *conn, +static NTSTATUS open_streams_for_delete(connection_struct *conn, const char *fname) { struct stream_struct *stream_info = NULL; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 1963fb3..a859cb6 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -647,8 +647,6 @@ void msg_file_was_renamed(struct messaging_context *msg, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); -NTSTATUS open_streams_for_delete(connection_struct *conn, - const char *fname); int find_share_mode_lease(struct share_mode_data *d, const struct GUID *client_guid, const struct smb2_lease_key *key); -- 2.5.0 >From 3455c964b821e24af7da9ce374262a90ded112ce Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Mar 2016 14:16:13 -0800 Subject: [PATCH 4/5] s3: smbd: Change open_streams_for_delete() to take a struct smb_filename *. Prepare for changing vfs_streaminfo to do the same. Signed-off-by: Jeremy Allison --- source3/smbd/open.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index d2e79ca..a80d2e6 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3850,7 +3850,7 @@ void msg_file_was_renamed(struct messaging_context *msg, */ static NTSTATUS open_streams_for_delete(connection_struct *conn, - const char *fname) + const struct smb_filename *smb_fname) { struct stream_struct *stream_info = NULL; files_struct **streams = NULL; @@ -3859,7 +3859,7 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn, TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; - status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), + status = vfs_streaminfo(conn, NULL, smb_fname->base_name, talloc_tos(), &num_streams, &stream_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) @@ -3891,30 +3891,32 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn, } for (i=0; ibase_name, + stream_info[i].name, + NULL); + if (smb_fname_cp == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; } - if (SMB_VFS_STAT(conn, smb_fname) == -1) { + if (SMB_VFS_STAT(conn, smb_fname_cp) == -1) { DEBUG(10, ("Unable to stat stream: %s\n", - smb_fname_str_dbg(smb_fname))); + smb_fname_str_dbg(smb_fname_cp))); } status = SMB_VFS_CREATE_FILE( conn, /* conn */ NULL, /* req */ 0, /* root_dir_fid */ - smb_fname, /* fname */ + smb_fname_cp, /* fname */ DELETE_ACCESS, /* access_mask */ (FILE_SHARE_READ | /* share_access */ FILE_SHARE_WRITE | FILE_SHARE_DELETE), @@ -3933,13 +3935,13 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn, if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("Could not open stream %s: %s\n", - smb_fname_str_dbg(smb_fname), + smb_fname_str_dbg(smb_fname_cp), nt_errstr(status))); - TALLOC_FREE(smb_fname); + TALLOC_FREE(smb_fname_cp); break; } - TALLOC_FREE(smb_fname); + TALLOC_FREE(smb_fname_cp); } /* @@ -4513,7 +4515,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, * We can't open a file with DELETE access if any of the * streams is open without FILE_SHARE_DELETE */ - status = open_streams_for_delete(conn, smb_fname->base_name); + status = open_streams_for_delete(conn, smb_fname); if (!NT_STATUS_IS_OK(status)) { goto fail; -- 2.5.0 >From 844fcda0271c7ed72b44b23f600d75bdd55c1be3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Mar 2016 14:19:18 -0800 Subject: [PATCH 5/5] VFS: Modify vfs_streaminfo to take a const struct smb_filename * instead of const char * Preparing to reduce use of lp_posix_pathnames(). Signed-off-by: Jeremy Allison --- examples/VFS/skel_opaque.c | 2 +- examples/VFS/skel_transparent.c | 9 ++++++--- source3/include/vfs.h | 6 ++++-- source3/include/vfs_macros.h | 8 ++++---- source3/modules/vfs_catia.c | 21 +++++++++++++++++---- source3/modules/vfs_default.c | 15 ++++++++------- source3/modules/vfs_fruit.c | 19 ++++--------------- source3/modules/vfs_full_audit.c | 6 +++--- source3/modules/vfs_media_harmony.c | 37 ++++++++++++++++++------------------- source3/modules/vfs_streams_depot.c | 16 ++++++++++++---- source3/modules/vfs_streams_xattr.c | 29 ++++++++++++++++++----------- source3/modules/vfs_time_audit.c | 4 ++-- source3/modules/vfs_unityed_media.c | 19 ++++++++++--------- source3/smbd/close.c | 2 +- source3/smbd/filename.c | 2 +- source3/smbd/nttrans.c | 4 ++-- source3/smbd/open.c | 2 +- source3/smbd/proto.h | 2 +- source3/smbd/trans2.c | 8 ++++++-- source3/smbd/vfs.c | 13 +++++++++---- 20 files changed, 128 insertions(+), 96 deletions(-) diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 457881d..67c387d 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -579,7 +579,7 @@ static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle, static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams) diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 55b1ed6..9fc9438 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -699,14 +699,17 @@ static NTSTATUS skel_set_compression(struct vfs_handle_struct *handle, static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams) { return SMB_VFS_NEXT_STREAMINFO(handle, - fsp, - fname, mem_ctx, num_streams, streams); + fsp, + smb_fname, + mem_ctx, + num_streams, + streams); } static int skel_get_real_filename(struct vfs_handle_struct *handle, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index e77d702..1c6bc2f 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -188,6 +188,8 @@ const struct smb_filename * */ /* Version 35 - Change lchown from const char *, to const struct smb_filename * */ +/* Version 35 - Change streaminfo from const char *, to + const struct smb_filename * */ #define SMB_VFS_INTERFACE_VERSION 35 @@ -721,7 +723,7 @@ struct vfs_fn_pointers { NTSTATUS (*streaminfo_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams); @@ -1153,7 +1155,7 @@ struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle, const SMB_STRUCT_STAT *sbuf); NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index ae2ba1b..6059c2a 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -346,10 +346,10 @@ #define SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf) \ smb_vfs_call_file_id_create((handle)->next, (sbuf)) -#define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) \ - smb_vfs_call_streaminfo((conn)->vfs_handles, (fsp), (fname), (mem_ctx), (num_streams), (streams)) -#define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, num_streams, streams) \ - smb_vfs_call_streaminfo((handle)->next, (fsp), (fname), (mem_ctx), (num_streams), (streams)) +#define SMB_VFS_STREAMINFO(conn, fsp, smb_fname, mem_ctx, num_streams, streams) \ + smb_vfs_call_streaminfo((conn)->vfs_handles, (fsp), (smb_fname), (mem_ctx), (num_streams), (streams)) +#define SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx, num_streams, streams) \ + smb_vfs_call_streaminfo((handle)->next, (fsp), (smb_fname), (mem_ctx), (num_streams), (streams)) #define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) \ smb_vfs_call_get_real_filename((conn)->vfs_handles, (path), (name), (mem_ctx), (found_name)) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 4a988b9..e2b4eb5 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -792,7 +792,7 @@ static int catia_chflags(struct vfs_handle_struct *handle, static NTSTATUS catia_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *path, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *_num_streams, struct stream_struct **_streams) @@ -800,22 +800,35 @@ catia_streaminfo(struct vfs_handle_struct *handle, char *mapped_name = NULL; NTSTATUS status; int i; + struct smb_filename *catia_smb_fname = NULL; unsigned int num_streams = 0; struct stream_struct *streams = NULL; *_num_streams = 0; *_streams = NULL; - status = catia_string_replace_allocate(handle->conn, path, - &mapped_name, vfs_translate_to_unix); + status = catia_string_replace_allocate(handle->conn, + smb_fname->base_name, + &mapped_name, + vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); return status; } - status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, mapped_name, + catia_smb_fname = synthetic_smb_fname(talloc_tos(), + mapped_name, + NULL, + NULL); + if (catia_smb_fname == NULL) { + TALLOC_FREE(mapped_name); + return NT_STATUS_NO_MEMORY; + } + + status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, catia_smb_fname, mem_ctx, &num_streams, &streams); TALLOC_FREE(mapped_name); + TALLOC_FREE(catia_smb_fname); if (!NT_STATUS_IS_OK(status)) { return status; } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 4de965e..ee9ddb2 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2186,7 +2186,7 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *pnum_streams, struct stream_struct **pstreams) @@ -2206,17 +2206,18 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, ret = SMB_VFS_FSTAT(fsp, &sbuf); } else { - struct smb_filename smb_fname; + struct smb_filename smb_fname_cp; - ZERO_STRUCT(smb_fname); - smb_fname.base_name = discard_const_p(char, fname); + ZERO_STRUCT(smb_fname_cp); + smb_fname_cp.base_name = discard_const_p(char, + smb_fname->base_name); if (lp_posix_pathnames()) { - ret = SMB_VFS_LSTAT(handle->conn, &smb_fname); + ret = SMB_VFS_LSTAT(handle->conn, &smb_fname_cp); } else { - ret = SMB_VFS_STAT(handle->conn, &smb_fname); + ret = SMB_VFS_STAT(handle->conn, &smb_fname_cp); } - sbuf = smb_fname.st; + sbuf = smb_fname_cp.st; } if (ret == -1) { diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index e0d1fae..0c74286 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -3168,24 +3168,18 @@ exit: static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *pnum_streams, struct stream_struct **pstreams) { struct fruit_config_data *config = NULL; - struct smb_filename *smb_fname = NULL; struct adouble *ad = NULL; NTSTATUS status; SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, return NT_STATUS_UNSUCCESSFUL); - DEBUG(10, ("fruit_streaminfo called for %s\n", fname)); - - smb_fname = synthetic_smb_fname(talloc_tos(), fname, NULL, NULL); - if (smb_fname == NULL) { - return NT_STATUS_NO_MEMORY; - } + DEBUG(10, ("fruit_streaminfo called for %s\n", smb_fname->base_name)); if (config->meta == FRUIT_META_NETATALK) { ad = ad_get(talloc_tos(), handle, @@ -3197,7 +3191,6 @@ static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle, smb_roundup(handle->conn, AFP_INFO_SIZE))) { TALLOC_FREE(ad); - TALLOC_FREE(smb_fname); return NT_STATUS_NO_MEMORY; } } @@ -3216,16 +3209,13 @@ static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle, ad_getentrylen( ad, ADEID_RFORK)))) { TALLOC_FREE(ad); - TALLOC_FREE(smb_fname); return NT_STATUS_NO_MEMORY; } } TALLOC_FREE(ad); } - TALLOC_FREE(smb_fname); - - status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, + status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx, pnum_streams, pstreams); if (!NT_STATUS_IS_OK(status)) { return status; @@ -3236,7 +3226,6 @@ static NTSTATUS fruit_streaminfo(vfs_handle_struct *handle, if (!del_fruit_stream(mem_ctx, pnum_streams, pstreams, ":" NETATALK_META_XATTR ":$DATA")) { TALLOC_FREE(ad); - TALLOC_FREE(smb_fname); return NT_STATUS_NO_MEMORY; } } @@ -3792,7 +3781,7 @@ static void fruit_copy_chunk_done(struct tevent_req *subreq) * because streams are few and small. */ status = vfs_streaminfo(state->handle->conn, state->src_fsp, - state->src_fsp->fsp_name->base_name, + state->src_fsp->fsp_name, req, &num_streams, &streams); if (tevent_req_nterror(req, status)) { return; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index d29064b..691b1e1 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -1674,18 +1674,18 @@ static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *ha static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *pnum_streams, struct stream_struct **pstreams) { NTSTATUS result; - result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, + result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx, pnum_streams, pstreams); do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle, - "%s", fname); + "%s", smb_fname->base_name); return result; } diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 67e2541..2ae6c4a 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -1962,43 +1962,42 @@ out: */ static NTSTATUS mh_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *ctx, unsigned int *num_streams, struct stream_struct **streams) { NTSTATUS status; - char *clientPath; - TALLOC_CTX *mem_ctx; + int ret; + struct smb_filename *clientFname = NULL; DEBUG(MH_INFO_DEBUG, ("Entering mh_streaminfo\n")); - if (!is_in_media_files(fname)) - { - status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, - ctx, num_streams, streams); + if (!is_in_media_files(smb_fname->base_name)) { + status = SMB_VFS_NEXT_STREAMINFO(handle, + fsp, + smb_fname, + ctx, + num_streams, + streams); goto out; } - clientPath = NULL; - mem_ctx = talloc_tos(); - - if (alloc_get_client_path(handle, mem_ctx, - fname, - &clientPath)) - { - status = map_nt_error_from_unix(errno); + ret = alloc_get_client_smb_fname(handle, + talloc_tos(), + smb_fname, + &clientFname); + if (ret != 0) { + status = NT_STATUS_NO_MEMORY; goto err; } /* This only works on files, so we don't have to worry about * our fake directory stat'ing here. */ - // But what does this function do, exactly? Does it need - // extra modifications for the Avid stuff? - status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, clientPath, + status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, clientFname, ctx, num_streams, streams); err: - TALLOC_FREE(clientPath); + TALLOC_FREE(clientFname); out: return status; } diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index d998dc5..ef5ef64 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -911,17 +911,20 @@ static bool collect_one_stream(const char *dirname, static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *pnum_streams, struct stream_struct **pstreams) { - struct smb_filename *smb_fname_base; + struct smb_filename *smb_fname_base = NULL; int ret; NTSTATUS status; struct streaminfo_state state; - smb_fname_base = synthetic_smb_fname(talloc_tos(), fname, NULL, NULL); + smb_fname_base = synthetic_smb_fname(talloc_tos(), + smb_fname->base_name, + NULL, + NULL); if (smb_fname_base == NULL) { return NT_STATUS_NO_MEMORY; } @@ -975,7 +978,12 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle, *pnum_streams = state.num_streams; *pstreams = state.streams; - status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams); + status = SMB_VFS_NEXT_STREAMINFO(handle, + fsp, + smb_fname_base, + mem_ctx, + pnum_streams, + pstreams); out: TALLOC_FREE(smb_fname_base); diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index b54809f..3887d9f 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -811,7 +811,7 @@ static bool collect_one_stream(struct ea_struct *ea, void *private_data) static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *pnum_streams, struct stream_struct **pstreams) @@ -825,19 +825,21 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, ret = SMB_VFS_FSTAT(fsp, &sbuf); } else { - struct smb_filename *smb_fname = NULL; - smb_fname = synthetic_smb_fname(talloc_tos(), fname, NULL, - NULL); - if (smb_fname == NULL) { + struct smb_filename *smb_fname_base = NULL; + smb_fname_base = synthetic_smb_fname(talloc_tos(), + smb_fname->base_name, + NULL, + NULL); + if (smb_fname_base == NULL) { return NT_STATUS_NO_MEMORY; } if (lp_posix_pathnames()) { - ret = SMB_VFS_LSTAT(handle->conn, smb_fname); + ret = SMB_VFS_LSTAT(handle->conn, smb_fname_base); } else { - ret = SMB_VFS_STAT(handle->conn, smb_fname); + ret = SMB_VFS_STAT(handle->conn, smb_fname_base); } - sbuf = smb_fname->st; - TALLOC_FREE(smb_fname); + sbuf = smb_fname_base->st; + TALLOC_FREE(smb_fname_base); } if (ret == -1) { @@ -860,7 +862,7 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, */ status = NT_STATUS_OK; } else { - status = walk_xattr_streams(handle, fsp, fname, + status = walk_xattr_streams(handle, fsp, smb_fname->base_name, collect_one_stream, &state); } @@ -877,7 +879,12 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, *pnum_streams = state.num_streams; *pstreams = state.streams; - return SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams); + return SMB_VFS_NEXT_STREAMINFO(handle, + fsp, + smb_fname, + mem_ctx, + pnum_streams, + pstreams); } static uint32_t streams_xattr_fs_capabilities(struct vfs_handle_struct *handle, diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 30dae98..3bdc98b 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -1533,7 +1533,7 @@ static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *ha static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *pnum_streams, struct stream_struct **pstreams) @@ -1543,7 +1543,7 @@ static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle, double timediff; clock_gettime_mono(&ts1); - result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, + result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx, pnum_streams, pstreams); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c index d46b376..7544b8f 100644 --- a/source3/modules/vfs_unityed_media.c +++ b/source3/modules/vfs_unityed_media.c @@ -1489,26 +1489,27 @@ err: static NTSTATUS um_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *ctx, unsigned int *num_streams, struct stream_struct **streams) { NTSTATUS status; - char *client_path = NULL; int ret; + struct smb_filename *client_fname = NULL; DEBUG(10, ("Entering um_streaminfo\n")); - if (!is_in_media_files(fname)) { - return SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, + if (!is_in_media_files(smb_fname->base_name)) { + return SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, ctx, num_streams, streams); } - ret = alloc_get_client_path(handle, talloc_tos(), - fname, &client_path); + ret = alloc_get_client_smb_fname(handle, + talloc_tos(), + smb_fname, + &client_fname); if (ret != 0) { - status = map_nt_error_from_unix(errno); goto err; } @@ -1518,10 +1519,10 @@ static NTSTATUS um_streaminfo(struct vfs_handle_struct *handle, * function do, exactly? Does it need extra modifications for * the Avid stuff? */ - status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, client_path, + status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, client_fname, ctx, num_streams, streams); err: - TALLOC_FREE(client_path); + TALLOC_FREE(client_fname); return status; } diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 144998f..3b887c8 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -170,7 +170,7 @@ NTSTATUS delete_all_streams(connection_struct *conn, TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; - status = vfs_streaminfo(conn, NULL, smb_fname->base_name, talloc_tos(), + status = vfs_streaminfo(conn, NULL, smb_fname, talloc_tos(), &num_streams, &stream_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 86f6686..14eb53f 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1315,7 +1315,7 @@ static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx, } /* Fall back to a case-insensitive scan of all streams on the file. */ - status = vfs_streaminfo(conn, NULL, smb_fname->base_name, mem_ctx, + status = vfs_streaminfo(conn, NULL, smb_fname, mem_ctx, &num_streams, &streams); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 75b283e..c6ad095 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -698,7 +698,7 @@ void reply_ntcreate_and_X(struct smb_request *req) if (NT_STATUS_IS_OK(status) && num_names) { file_status &= ~NO_EAS; } - status = vfs_streaminfo(conn, NULL, smb_fname->base_name, ctx, + status = vfs_streaminfo(conn, NULL, smb_fname, ctx, &num_streams, &streams); /* There is always one stream, ::$DATA. */ if (NT_STATUS_IS_OK(status) && num_streams > 1) { @@ -1337,7 +1337,7 @@ static void call_nt_transact_create(connection_struct *conn, if (NT_STATUS_IS_OK(status) && num_names) { file_status &= ~NO_EAS; } - status = vfs_streaminfo(conn, NULL, smb_fname->base_name, ctx, + status = vfs_streaminfo(conn, NULL, smb_fname, ctx, &num_streams, &streams); /* There is always one stream, ::$DATA. */ if (NT_STATUS_IS_OK(status) && num_streams > 1) { diff --git a/source3/smbd/open.c b/source3/smbd/open.c index a80d2e6..baebd7c 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3859,7 +3859,7 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn, TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; - status = vfs_streaminfo(conn, NULL, smb_fname->base_name, talloc_tos(), + status = vfs_streaminfo(conn, NULL, smb_fname, talloc_tos(), &num_streams, &stream_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index a859cb6..e1ec063 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1215,7 +1215,7 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp); NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid); NTSTATUS vfs_streaminfo(connection_struct *conn, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 8cd03c4..b1eb9a9 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5180,8 +5180,12 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, return NT_STATUS_INVALID_PARAMETER; } - status = vfs_streaminfo(conn, fsp, smb_fname->base_name, - talloc_tos(), &num_streams, &streams); + status = vfs_streaminfo(conn, + fsp, + smb_fname, + talloc_tos(), + &num_streams, + &streams); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("could not get stream info: %s\n", diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 19f75d1..a1154ae 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1365,14 +1365,19 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp) */ NTSTATUS vfs_streaminfo(connection_struct *conn, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams) { *num_streams = 0; *streams = NULL; - return SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams); + return SMB_VFS_STREAMINFO(conn, + fsp, + smb_fname, + mem_ctx, + num_streams, + streams); } /* @@ -2124,13 +2129,13 @@ struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle, NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle, struct files_struct *fsp, - const char *fname, + const struct smb_filename *smb_fname, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams) { VFS_FIND(streaminfo); - return handle->fns->streaminfo_fn(handle, fsp, fname, mem_ctx, + return handle->fns->streaminfo_fn(handle, fsp, smb_fname, mem_ctx, num_streams, streams); } -- 2.5.0