From 44732734cca2328a8aceb2db9b577c923920f644 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Jan 2011 14:23:19 -0800 Subject: Fix bug #7863 - Unlink may unlink wrong file when hardlinks are involved. Do this by keeping a linked list of delete on close tokens, one for each filename that identifies a path to the dev/inode. Use the jenkins hash of the pathname to identify the correct token. --- source3/smbd/open.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/smbd/open.c') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 722e461068..0de70451da 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -810,6 +810,7 @@ bool is_stat_open(uint32 access_mask) static NTSTATUS open_mode_check(connection_struct *conn, struct share_mode_lock *lck, + uint32_t name_hash, uint32 access_mask, uint32 share_access, uint32 create_options, @@ -825,7 +826,7 @@ static NTSTATUS open_mode_check(connection_struct *conn, /* A delete on close prohibits everything */ - if (lck->delete_on_close) { + if (is_delete_on_close_set(lck, name_hash)) { return NT_STATUS_DELETE_PENDING; } @@ -1823,7 +1824,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* Use the client requested access mask here, not the one we * open with. */ - status = open_mode_check(conn, lck, access_mask, share_access, + status = open_mode_check(conn, lck, fsp->name_hash, + access_mask, share_access, create_options, &file_existed); if (NT_STATUS_IS_OK(status)) { @@ -2045,7 +2047,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, return NT_STATUS_SHARING_VIOLATION; } - status = open_mode_check(conn, lck, access_mask, share_access, + status = open_mode_check(conn, lck, fsp->name_hash, + access_mask, share_access, create_options, &file_existed); if (NT_STATUS_IS_OK(status)) { @@ -2625,7 +2628,8 @@ static NTSTATUS open_directory(connection_struct *conn, return NT_STATUS_SHARING_VIOLATION; } - status = open_mode_check(conn, lck, access_mask, share_access, + status = open_mode_check(conn, lck, fsp->name_hash, + access_mask, share_access, create_options, &dir_existed); if (!NT_STATUS_IS_OK(status)) { -- cgit