]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: pass lck down to rename_internals_fsp()
authorRalph Boehme <slow@samba.org>
Mon, 30 Sep 2024 18:03:43 +0000 (20:03 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:30 +0000 (14:39 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/globals.h
source3/smbd/proto.h
source3/smbd/smb1_trans2.c
source3/smbd/smb2_reply.c
source3/smbd/smb2_setinfo.c
source3/smbd/smb2_trans2.c

index 57a2b21e3e4ee9c6f14dc3480f099b76b97403d8..759f7a5823a903982212c36e18435b384f48d737 100644 (file)
@@ -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,
index bf1cb07cede28fc77e035309480966b138b71e30..abbc47a83a3d72cc1698717e2ef592a3b3962647 100644 (file)
@@ -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,
index f4fa85c728dc163552d924e467fcf80db5bada25..155f7c62bb17ad2c43de79d4a92f8c0e3e14e793 100644 (file)
@@ -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,
index 16c70eda3373303d42547538c69b1e4a9582738f..91a38cd090543e0c246f0352125ef689a8e9e84e 100644 (file)
@@ -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,
index 4038d1dd8de20a6fc546e7405a85610a1324c097..84c651b1794a449ed6cc29ed859e8fc1e0ea1311 100644 (file)
@@ -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,
index 0a97493280ba0e5841a912616e7b285b6b835323..f279753622a9c220e21097d80fae52273e4e402b 100644 (file)
@@ -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;
                }