]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove unused parameters from rename_internals()
authorVolker Lendecke <vl@samba.org>
Wed, 24 Sep 2025 13:12:17 +0000 (15:12 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/proto.h
source3/smbd/smb1_nttrans.c
source3/smbd/smb1_reply.c
source3/smbd/smb2_reply.c
source3/smbd/smb2_trans2.c

index 193981f97e1401fda0aec24ec2afeadec80283e2..ac7722350ca45c9c32348debf0fe584491eefa16 100644 (file)
@@ -953,8 +953,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                          struct files_struct *src_dirfsp,
                          struct smb_filename *smb_fname_src,
                          struct smb_filename *smb_fname_src_rel,
-                         struct smb_filename *smb_fname_dst,
-                         const char *dst_original_lcomp,
                          uint32_t attrs,
                          const char *newname,
                          bool replace_if_exists,
index 67ee61c7d73a4b8a4b1c161bd66a5ee1aa4eccfc..e0722d00450dadf2d9ef4a8d0c9a60046434de31 100644 (file)
@@ -1564,34 +1564,16 @@ void reply_ntrename(struct smb_request *req)
 
        switch(rename_type) {
        case RENAME_FLAG_RENAME: {
-               /*
-                * Get the last component of the destination for
-                * rename_internals().
-                */
-
-               char *dst_original_lcomp = get_original_lcomp(ctx,
-                                                             conn,
-                                                             newname,
-                                                             ucf_flags_dst);
-               if (dst_original_lcomp == NULL) {
-                       reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       goto out;
-               }
-
                status = rename_internals(ctx,
                                          conn,
                                          req,
                                          src_dirfsp,
                                          smb_fname_old,
                                          smb_fname_old_rel,
-                                         smb_fname_new,
-                                         dst_original_lcomp,
                                          attrs,
                                          newname,
                                          false,
                                          DELETE_ACCESS);
-
-               TALLOC_FREE(dst_original_lcomp);
                break;
        }
        case RENAME_FLAG_HARD_LINK:
index 890bc1899cb7545d828f191c4c87b1aad763eff7..f7b2fb65720c1cebd1789ad64d1b4a6a39035db3 100644 (file)
@@ -6343,14 +6343,10 @@ void reply_mv(struct smb_request *req)
        struct files_struct *src_dirfsp = NULL;
        struct smb_filename *smb_fname_src = NULL;
        struct smb_filename *smb_fname_src_rel = NULL;
-       struct files_struct *dst_dirfsp = NULL;
-       struct smb_filename *smb_fname_dst = NULL;
-       const char *dst_original_lcomp = NULL;
        uint32_t src_ucf_flags = ucf_flags_from_smb_request(req);
        NTTIME src_twrp = 0;
        uint32_t dst_ucf_flags = ucf_flags_from_smb_request(req);
        NTTIME dst_twrp = 0;
-       bool stream_rename = false;
 
        START_PROFILE(SMBmv);
 
@@ -6384,7 +6380,6 @@ void reply_mv(struct smb_request *req)
                                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                                goto out;
                        }
-                       stream_rename = true;
                }
         }
 
@@ -6424,49 +6419,8 @@ void reply_mv(struct smb_request *req)
                reply_nterror(req, status);
                goto out;
        }
-       status = filename_convert_dirfsp(ctx,
-                                        conn,
-                                        newname,
-                                        dst_ucf_flags,
-                                        dst_twrp,
-                                        &dst_dirfsp,
-                                        &smb_fname_dst);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
-                       reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,
-                                       ERRSRV, ERRbadpath);
-                       goto out;
-               }
-               reply_nterror(req, status);
-               goto out;
-       }
-
-       /* Get the last component of the destination for rename_internals(). */
-       dst_original_lcomp = get_original_lcomp(ctx,
-                                       conn,
-                                       newname,
-                                       dst_ucf_flags);
-       if (dst_original_lcomp == NULL) {
-               reply_nterror(req, NT_STATUS_NO_MEMORY);
-               goto out;
-       }
-
-       if (stream_rename) {
-               /* smb_fname_dst->base_name must be the same as
-                  smb_fname_src->base_name. */
-               TALLOC_FREE(smb_fname_dst->base_name);
-               smb_fname_dst->base_name = talloc_strdup(smb_fname_dst,
-                                               smb_fname_src->base_name);
-               if (!smb_fname_dst->base_name) {
-                       reply_nterror(req, NT_STATUS_NO_MEMORY);
-                       goto out;
-               }
-       }
 
-       DBG_NOTICE("%s -> %s\n",
-                  smb_fname_str_dbg(smb_fname_src),
-                  smb_fname_str_dbg(smb_fname_dst));
+       DBG_NOTICE("%s -> %s\n", smb_fname_str_dbg(smb_fname_src), newname);
 
        status = rename_internals(ctx,
                                  conn,
@@ -6474,8 +6428,6 @@ void reply_mv(struct smb_request *req)
                                  src_dirfsp, /* src_dirfsp */
                                  smb_fname_src,
                                  smb_fname_src_rel,
-                                 smb_fname_dst,
-                                 dst_original_lcomp,
                                  attrs,
                                  newname,
                                  false,
@@ -6497,9 +6449,8 @@ void reply_mv(struct smb_request *req)
 
        reply_smb1_outbuf(req, 0, 0);
  out:
-       TALLOC_FREE(smb_fname_src);
-       TALLOC_FREE(smb_fname_dst);
-       END_PROFILE(SMBmv);
+        TALLOC_FREE(smb_fname_src);
+        END_PROFILE(SMBmv);
 }
 
 /****************************************************************************
index a8bc19f0d39d07a5cd7141be013325ef26421e48..48aa5c86038d1916447e2f93e4009ed02b0ad0bb 100644 (file)
@@ -1675,8 +1675,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                          struct files_struct *src_dirfsp,
                          struct smb_filename *smb_fname_src,
                          struct smb_filename *smb_fname_src_rel,
-                         struct smb_filename *smb_fname_dst,
-                         const char *dst_original_lcomp,
                          uint32_t attrs,
                          const char *newname,
                          bool replace_if_exists,
@@ -1701,14 +1699,13 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
        }
 
        DBG_NOTICE("case_sensitive = %d, "
-                 "case_preserve = %d, short case preserve = %d, "
-                 "directory = %s, newname = %s, "
-                 "last_component_dest = %s\n",
-                 case_sensitive, case_preserve,
-                 short_case_preserve,
-                 smb_fname_str_dbg(smb_fname_src),
-                 smb_fname_str_dbg(smb_fname_dst),
-                 dst_original_lcomp);
+                  "case_preserve = %d, short case preserve = %d, "
+                  "directory = %s, newname = %s\n",
+                  case_sensitive,
+                  case_preserve,
+                  short_case_preserve,
+                  smb_fname_str_dbg(smb_fname_src),
+                  newname);
 
        ZERO_STRUCT(smb_fname_src->st);
 
@@ -1783,8 +1780,9 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
        close_file_free(req, &fsp, NORMAL_CLOSE);
 
        DBG_NOTICE("Error %s rename %s -> %s\n",
-                 nt_errstr(status), smb_fname_str_dbg(smb_fname_src),
-                 smb_fname_str_dbg(smb_fname_dst));
+                  nt_errstr(status),
+                  smb_fname_str_dbg(smb_fname_src),
+                  newname);
 
  out:
        TALLOC_FREE(posx);
index 8a8831d6186e600fd9a428e3a9336f595829215f..983ae2e7606aed6feec1e6197e482933e052eb53 100644 (file)
@@ -4570,11 +4570,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
        char *newname = NULL;
        struct smb_filename *smb_fname_src_parent = NULL;
        struct smb_filename *smb_fname_src_rel = NULL;
-       struct files_struct *dst_dirfsp = NULL;
-       struct smb_filename *smb_fname_dst = NULL;
-       const char *dst_original_lcomp = NULL;
        NTSTATUS status = NT_STATUS_OK;
-       char *p;
        TALLOC_CTX *ctx = talloc_tos();
 
        if (total_data < 13) {
@@ -4619,105 +4615,6 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                return NT_STATUS_NOT_SUPPORTED;
        }
 
-       if (fsp_is_alternate_stream(fsp)) {
-               /* newname must be a stream name. */
-               if (newname[0] != ':') {
-                       return NT_STATUS_NOT_SUPPORTED;
-               }
-
-               /* Create an smb_fname to call rename_internals_fsp() with. */
-               smb_fname_dst = synthetic_smb_fname(talloc_tos(),
-                                       fsp->base_fsp->fsp_name->base_name,
-                                       newname,
-                                       NULL,
-                                       fsp->base_fsp->fsp_name->twrp,
-                                       fsp->base_fsp->fsp_name->flags);
-               if (smb_fname_dst == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-
-               /*
-                * Get the original last component, since
-                * rename_internals_fsp() requires it.
-                */
-               dst_original_lcomp = get_original_lcomp(smb_fname_dst,
-                                       conn,
-                                       newname,
-                                       0);
-               if (dst_original_lcomp == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-
-       } else {
-               /*
-                * Build up an smb_fname_dst based on the filename passed in.
-                * We basically just strip off the last component, and put on
-                * the newname instead.
-                */
-               char *base_name = NULL;
-               uint32_t ucf_flags = ucf_flags_from_smb_request(req);
-               NTTIME dst_twrp = 0;
-
-               /* newname must *not* be a stream name. */
-               if (newname[0] == ':') {
-                       return NT_STATUS_NOT_SUPPORTED;
-               }
-
-               /*
-                * Strip off the last component (filename) of the path passed
-                * in.
-                */
-               base_name = talloc_strdup(ctx, smb_fname_src->base_name);
-               if (!base_name) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-               p = strrchr_m(base_name, '/');
-               if (p) {
-                       p[1] = '\0';
-               } else {
-                       base_name = talloc_strdup(ctx, "");
-                       if (!base_name) {
-                               return NT_STATUS_NO_MEMORY;
-                       }
-               }
-               /* Append the new name. */
-               base_name = talloc_asprintf_append(base_name,
-                               "%s",
-                               newname);
-               if (!base_name) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-
-               if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(base_name, &dst_twrp);
-               }
-
-               /* The newname is *not* a DFS path. */
-               ucf_flags &= ~UCF_DFS_PATHNAME;
-
-               status = filename_convert_dirfsp(ctx,
-                                        conn,
-                                        base_name,
-                                        ucf_flags,
-                                        dst_twrp,
-                                        &dst_dirfsp,
-                                        &smb_fname_dst);
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       goto out;
-               }
-               dst_original_lcomp = get_original_lcomp(smb_fname_dst,
-                                       conn,
-                                       newname,
-                                       ucf_flags);
-               if (dst_original_lcomp == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-       }
-
        status = parent_pathref(ctx,
                                conn->cwd_fsp,
                                fsp->fsp_name,
@@ -4744,7 +4641,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                DBG_DEBUG("SMB_FILE_RENAME_INFORMATION (%s) %s -> %s\n",
                          fsp_fnum_dbg(fsp),
                          fsp_str_dbg(fsp),
-                         smb_fname_str_dbg(smb_fname_dst));
+                         newname);
 
                /*
                 * If no pathnames are open below this directory,
@@ -4766,22 +4663,20 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
        } else {
                DBG_DEBUG("SMB_FILE_RENAME_INFORMATION %s -> %s\n",
                          smb_fname_str_dbg(smb_fname_src),
-                         smb_fname_str_dbg(smb_fname_dst));
+                         newname);
                status = rename_internals(ctx,
+
                                          conn,
                                          req,
                                          smb_fname_src_parent->fsp,
                                          smb_fname_src,
                                          smb_fname_src_rel,
-                                         smb_fname_dst,
-                                         dst_original_lcomp,
                                          0,
                                          newname,
                                          overwrite,
                                          FILE_WRITE_ATTRIBUTES);
        }
- out:
-       TALLOC_FREE(smb_fname_dst);
+out:
        return status;
 }