From: Volker Lendecke Date: Wed, 24 Sep 2025 13:12:17 +0000 (+0200) Subject: smbd: Remove unused parameters from rename_internals() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cd3aa5f1516fe1615306c3f634d58a150e403c3;p=thirdparty%2Fsamba.git smbd: Remove unused parameters from rename_internals() Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 193981f97e1..ac7722350ca 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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, diff --git a/source3/smbd/smb1_nttrans.c b/source3/smbd/smb1_nttrans.c index 67ee61c7d73..e0722d00450 100644 --- a/source3/smbd/smb1_nttrans.c +++ b/source3/smbd/smb1_nttrans.c @@ -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: diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index 890bc1899cb..f7b2fb65720 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -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); } /**************************************************************************** diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index a8bc19f0d39..48aa5c86038 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -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); diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 8a8831d6186..983ae2e7606 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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; }