smbd: Return "blocker_pid" from do_lock()
authorVolker Lendecke <vl@samba.org>
Thu, 20 Jun 2019 10:20:39 +0000 (12:20 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 20 Jun 2019 17:18:18 +0000 (17:18 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/locking.c
source3/locking/proto.h
source3/modules/vfs_fruit.c
source3/smbd/blocking.c
source3/smbd/reply.c
source3/smbd/smb2_lock.c
source3/smbd/trans2.c

index 969be7061471c7fff35efc3e1581927385a50bf0..17ecfd08fff7d121a701c7db87dfb441d6edac4d 100644 (file)
@@ -243,6 +243,7 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
                        enum brl_flavour lock_flav,
                        bool blocking_lock,
                        NTSTATUS *perr,
+                       struct server_id *pblocker_pid,
                        uint64_t *psmblctx)
 {
        struct byte_range_lock *br_lck = NULL;
@@ -294,6 +295,9 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
        if (psmblctx != NULL) {
                *psmblctx = blocker_smblctx;
        }
+       if (pblocker_pid != NULL) {
+               *pblocker_pid = blocker_pid;
+       }
 
        DEBUG(10, ("do_lock: returning status=%s\n", nt_errstr(*perr)));
 
index 13883875521548080b0caed065cf1046e3485fdc..273d3666d370a1d68f73642d7dd6f5723a3582e1 100644 (file)
@@ -123,6 +123,7 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
                        enum brl_flavour lock_flav,
                        bool blocking_lock,
                        NTSTATUS *perr,
+                       struct server_id *pblocker_pid,
                        uint64_t *psmblctx);
 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
                        files_struct *fsp,
index f2964769a74d6dc04c1bbf3dd7921dbd4f9683b4..d8e0dbe63e6ea79bb574554aa963d253a5d44f51 100644 (file)
@@ -2746,10 +2746,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
 
                off = access_to_netatalk_brl(fork_type, FILE_READ_DATA);
                br_lck = do_lock(
-                       handle->conn->sconn->msg_ctx, fsp,
-                       fsp->op->global->open_persistent_id, 1, off,
-                       READ_LOCK, POSIX_LOCK, false,
-                       &status, NULL);
+                       handle->conn->sconn->msg_ctx,
+                       fsp,
+                       fsp->op->global->open_persistent_id,
+                       1,
+                       off,
+                       READ_LOCK,
+                       POSIX_LOCK,
+                       false,  /* blocking_lock */
+                       &status,
+                       NULL,
+                       NULL);
 
                TALLOC_FREE(br_lck);
 
@@ -2763,10 +2770,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
 
                off = denymode_to_netatalk_brl(fork_type, DENY_READ);
                br_lck = do_lock(
-                       handle->conn->sconn->msg_ctx, fsp,
-                       fsp->op->global->open_persistent_id, 1, off,
-                       READ_LOCK, POSIX_LOCK, false,
-                       &status, NULL);
+                       handle->conn->sconn->msg_ctx,
+                       fsp,
+                       fsp->op->global->open_persistent_id,
+                       1,
+                       off,
+                       READ_LOCK,
+                       POSIX_LOCK,
+                       false,  /* blocking_lock */
+                       &status,
+                       NULL,
+                       NULL);
 
                TALLOC_FREE(br_lck);
 
@@ -2780,10 +2794,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
 
                off = access_to_netatalk_brl(fork_type, FILE_WRITE_DATA);
                br_lck = do_lock(
-                       handle->conn->sconn->msg_ctx, fsp,
-                       fsp->op->global->open_persistent_id, 1, off,
-                       READ_LOCK, POSIX_LOCK, false,
-                       &status, NULL);
+                       handle->conn->sconn->msg_ctx,
+                       fsp,
+                       fsp->op->global->open_persistent_id,
+                       1,
+                       off,
+                       READ_LOCK,
+                       POSIX_LOCK,
+                       false,
+                       &status,
+                       NULL,
+                       NULL);
 
                TALLOC_FREE(br_lck);
 
@@ -2797,10 +2818,17 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
 
                off = denymode_to_netatalk_brl(fork_type, DENY_WRITE);
                br_lck = do_lock(
-                       handle->conn->sconn->msg_ctx, fsp,
-                       fsp->op->global->open_persistent_id, 1, off,
-                       READ_LOCK, POSIX_LOCK, false,
-                       &status, NULL);
+                       handle->conn->sconn->msg_ctx,
+                       fsp,
+                       fsp->op->global->open_persistent_id,
+                       1,
+                       off,
+                       READ_LOCK,
+                       POSIX_LOCK,
+                       false,
+                       &status,
+                       NULL,
+                       NULL);
 
                TALLOC_FREE(br_lck);
 
index 590e3e45cd97ad7be87bd180da8048e457b79dbb..61a02c70969befab206a26ee6663c038c38648ec 100644 (file)
@@ -496,6 +496,7 @@ static bool process_lockingX(struct blocking_lock_record *blr)
                                WINDOWS_LOCK,
                                True,
                                &status,
+                               NULL,
                                &blr->blocking_smblctx);
 
                if (ERROR_WAS_LOCK_DENIED(status) && !lock_timeout) {
@@ -598,6 +599,7 @@ static bool process_trans2(struct blocking_lock_record *blr)
                                                blr->lock_flav,
                                                True,
                                                &status,
+                                               NULL,
                                                &blr->blocking_smblctx);
        if (ERROR_WAS_LOCK_DENIED(status) && !lock_timeout) {
                struct server_id blocker_pid;
index 9da7a651cef61876c46321c835a7e6c850a2a251..d02f14ead13f959ab0438f9de0e68a656d275422 100644 (file)
@@ -3795,6 +3795,7 @@ void reply_lockread(struct smb_request *req)
                        WINDOWS_LOCK,
                        False, /* Non-blocking lock. */
                        &status,
+                       NULL,
                        NULL);
        TALLOC_FREE(br_lck);
 
@@ -5663,6 +5664,7 @@ void reply_lock(struct smb_request *req)
                        WINDOWS_LOCK,
                        False, /* Non-blocking lock. */
                        &status,
+                       NULL,
                        NULL);
 
        TALLOC_FREE(br_lck);
@@ -8112,6 +8114,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                        bool blocking_lock = (timeout != 0);
                        bool defer_lock = false;
                        struct byte_range_lock *br_lck;
+                       struct server_id blocker_pid;
                        uint64_t block_smblctx;
 
                        br_lck = do_lock(req->sconn->msg_ctx,
@@ -8123,6 +8126,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                        WINDOWS_LOCK,
                                        blocking_lock,
                                        &status,
+                                       &blocker_pid,
                                        &block_smblctx);
 
                        if (br_lck && blocking_lock && ERROR_WAS_LOCK_DENIED(status)) {
index 1372661d0c7b6a029b97ff18b89a520cb97e47a5..e1df44bb3738d2ccd55b0e3d96ad06e72d5a3dd8 100644 (file)
@@ -743,6 +743,7 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
                        WINDOWS_LOCK,
                        true,
                        &status,
+                       NULL,
                        &blr->blocking_smblctx);
 
        TALLOC_FREE(br_lck);
index 27eb6270f60beef8484d45a43d5d19a02f635b02..724009841604dc8e2c71ff68030456eb2c04ec5d 100644 (file)
@@ -7357,6 +7357,7 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn,
                         POSIX_LOCK,
                         blocking_lock,
                         &status,
+                        NULL,
                         &block_smblctx);
 
        if (br_lck && blocking_lock && ERROR_WAS_LOCK_DENIED(status)) {