]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when removing files
authorRalph Boehme <slow@samba.org>
Sat, 7 Sep 2024 14:21:41 +0000 (16:21 +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/close.c

index 1563dbf40f11eb8ad37055241102a011b89b1ca7..8f90b7f9da05bb5ebe1284b44ebbc11d8fa23e4d 100644 (file)
@@ -651,12 +651,28 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
                smb_panic("share_mode_entry_prepare_unlock() failed!");
        }
 
-       if (lck_state.delete_object) {
+       if (lck_state.delete_object && NT_STATUS_IS_OK(status)) {
+               const struct smb2_lease *lease = fsp_get_smb2_lease(fsp);
+
+               if (lease != NULL) {
+                       /*
+                        * If parent lease key of handle on which delete
+                        * disposition was set does not match the parent key of
+                        * last closed handle, break all leases on the parent
+                        * directory.
+                        */
+                       if (!smb2_lease_key_equal(&lease->parent_lease_key,
+                                                 &lck_state.parent_lease_key))
+                       {
+                               lease = NULL;
+                       }
+               }
                notify_fname(conn,
-                            NOTIFY_ACTION_REMOVED,
+                            NOTIFY_ACTION_REMOVED |
+                            NOTIFY_ACTION_DIRLEASE_BREAK,
                             FILE_NOTIFY_CHANGE_FILE_NAME,
                             fsp->fsp_name,
-                            NULL);
+                            lease);
        }
 
        return status;