From: Volker Lendecke Date: Thu, 19 May 2022 18:43:40 +0000 (+0200) Subject: smbd: Simplify copy_file() X-Git-Tag: talloc-2.3.4~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7a60eb7c93f18af0ce05e16511f3c7b17617273;p=thirdparty%2Fsamba.git smbd: Simplify copy_file() The only two callers did not use "count" and "target_is_directory". Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 183c4e02371..dba09cc462c 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -4781,8 +4781,7 @@ static void fruit_offload_write_done(struct tevent_req *subreq) state->handle->conn, src_fname_tmp, dst_fname_tmp, - OPENX_FILE_CREATE_IF_NOT_EXIST, - 0, false); + OPENX_FILE_CREATE_IF_NOT_EXIST); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("%s: copy %s to %s failed: %s\n", __func__, smb_fname_str_dbg(src_fname_tmp), diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 6961a4ddda9..85517406852 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1461,8 +1461,7 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx, status = copy_file(mem_ctx, conn, smb_fname_old, smb_fname_new, OPENX_FILE_EXISTS_TRUNCATE | - OPENX_FILE_CREATE_IF_NOT_EXIST, - 0, false); + OPENX_FILE_CREATE_IF_NOT_EXIST); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("move_driver_file_to_download_area: Unable " diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index f49191b721f..28591a17e38 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -988,9 +988,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, connection_struct *conn, struct smb_filename *smb_fname_src, struct smb_filename *smb_fname_dst, - int ofun, - int count, - bool target_is_directory); + int ofun); uint64_t get_lock_offset(const uint8_t *data, int data_offset, bool large_file_format); diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index 5f3c9be41eb..6c2876fa80f 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -1836,9 +1836,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, connection_struct *conn, struct smb_filename *smb_fname_src, struct smb_filename *smb_fname_dst, - int ofun, - int count, - bool target_is_directory) + int ofun) { struct smb_filename *smb_fname_dst_tmp = NULL; off_t ret=-1; @@ -1853,31 +1851,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, return NT_STATUS_NO_MEMORY; } - /* - * If the target is a directory, extract the last component from the - * src filename and append it to the dst filename - */ - if (target_is_directory) { - const char *p; - - /* dest/target can't be a stream if it's a directory. */ - SMB_ASSERT(smb_fname_dst->stream_name == NULL); - - p = strrchr_m(smb_fname_src->base_name,'/'); - if (p) { - p++; - } else { - p = smb_fname_src->base_name; - } - smb_fname_dst_tmp->base_name = - talloc_asprintf_append(smb_fname_dst_tmp->base_name, "/%s", - p); - if (!smb_fname_dst_tmp->base_name) { - status = NT_STATUS_NO_MEMORY; - goto out; - } - } - status = vfs_file_exist(conn, smb_fname_src); if (!NT_STATUS_IS_OK(status)) { goto out; @@ -1888,18 +1861,14 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, goto out; } - if (!target_is_directory && count) { - new_create_disposition = FILE_OPEN; - } else { - if (!map_open_params_to_ntcreate(smb_fname_dst_tmp->base_name, - 0, ofun, - NULL, NULL, - &new_create_disposition, - NULL, - NULL)) { - status = NT_STATUS_INVALID_PARAMETER; - goto out; - } + if (!map_open_params_to_ntcreate(smb_fname_dst_tmp->base_name, + 0, ofun, + NULL, NULL, + &new_create_disposition, + NULL, + NULL)) { + status = NT_STATUS_INVALID_PARAMETER; + goto out; } /* Open the src file for reading. */