]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify copy_file()
authorVolker Lendecke <vl@samba.org>
Thu, 19 May 2022 18:43:40 +0000 (20:43 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 20 May 2022 19:02:37 +0000 (19:02 +0000)
The only two callers did not use "count" and "target_is_directory".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c
source3/printing/nt_printing.c
source3/smbd/proto.h
source3/smbd/smb2_reply.c

index 183c4e02371c1e52a6cc253aefcfc917def7926a..dba09cc462c697f87852fe413101927cfea5aec0 100644 (file)
@@ -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),
index 6961a4ddda970a849dbccfb09f20547e84d82b99..85517406852ee55c4602160636600cad52075bdf 100644 (file)
@@ -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 "
index f49191b721fbd763218ca52b102b4019d13ff3c9..28591a17e389dc8230e0b7bb9bd2d59a64ea6c31 100644 (file)
@@ -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);
 
index 5f3c9be41eb8aad120992b5dc765d3e324acadd6..6c2876fa80f879ed2e0685aa88770c27b39e26f8 100644 (file)
@@ -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. */