diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 57a2b21e3e4..759f7a5823a 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -144,6 +144,7 @@ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn, TALLOC_CTX *mem_ctx, uint16_t info_level, files_struct *fsp, + struct share_mode_lock **lck, struct smb_filename *smb_fname, char *data, int total_data, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index bf1cb07cede..abbc47a83a3 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -922,6 +922,7 @@ ssize_t sendfile_short_send(struct smbXsrv_connection *xconn, size_t smb_maxcnt); NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, + struct share_mode_lock **lck, struct smb_filename *smb_fname_dst_in, const char *dst_original_lcomp, uint32_t attrs, diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index f4fa85c728d..155f7c62bb1 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -4598,6 +4598,7 @@ static void call_trans2setpathinfo( req, info_level, fsp, + NULL, smb_fname, *ppdata, total_data, @@ -4774,6 +4775,7 @@ static void call_trans2setfileinfo( req, info_level, fsp, + NULL, smb_fname, *ppdata, total_data, diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index 16c70eda337..91a38cd0905 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -1389,6 +1389,7 @@ static NTSTATUS parent_dirname_compatible_open(connection_struct *conn, NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, + struct share_mode_lock **_lck, struct smb_filename *smb_fname_dst_in, const char *dst_original_lcomp, uint32_t attrs, @@ -1737,7 +1738,11 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, */ parent_dir_fname_src_atname->st = fsp->fsp_name->st; - lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); + if (_lck != NULL) { + lck = talloc_move(talloc_tos(), _lck); + } else { + lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); + } /* * We have the file open ourselves, so not being able to get the @@ -1963,6 +1968,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, status = rename_internals_fsp(conn, fsp, + NULL, smb_fname_dst, dst_original_lcomp, attrs, diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index 4038d1dd8de..84c651b1794 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -429,6 +429,7 @@ static void smbd_smb2_setinfo_lease_break_check(struct tevent_req *req) state, state->file_info_level, state->fsp, + &state->lck, state->fsp->fsp_name, (char *)state->data.data, state->data.length, @@ -541,6 +542,7 @@ static void smbd_smb2_setinfo_lease_break_fsp_done(struct tevent_req *subreq) state, state->file_info_level, state->fsp, + &state->lck, state->fsp->fsp_name, (char *)state->data.data, state->data.length, diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 0a97493280b..f279753622a 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -4406,6 +4406,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn, const char *pdata, int total_data, files_struct *fsp, + struct share_mode_lock **lck, struct smb_filename *smb_fname_src) { bool overwrite; @@ -4437,6 +4438,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn, status = rename_internals_fsp(conn, fsp, + lck, smb_fname_dst, dst_original_lcomp, (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM), @@ -4810,6 +4812,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn, status = rename_internals_fsp(conn, fsp, + NULL, smb_fname_dst, dst_original_lcomp, 0, @@ -5087,11 +5090,20 @@ static NTSTATUS smb_set_file_end_of_file_info(connection_struct *conn, fail_after_createfile); } +/** + * Set an info_level + * + * Called from the SMB1 and SMB2 code. For the path-based SMB1 code, there may + * not be a full fsp from the FSA layer. + * + * lck may be NULL, currently only passed for SMB2 rename requests. + **/ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn, struct smb_request *req, TALLOC_CTX *mem_ctx, uint16_t info_level, files_struct *fsp, + struct share_mode_lock **lck, struct smb_filename *smb_fname, char *pdata, int total_data, @@ -5234,9 +5246,13 @@ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn, case SMB2_FILE_RENAME_INFORMATION_INTERNAL: { /* SMB2 rename information. */ - status = smb2_file_rename_information(conn, req, - pdata, total_data, - fsp, smb_fname); + status = smb2_file_rename_information(conn, + req, + pdata, + total_data, + fsp, + lck, + smb_fname); break; }