From bccbc5bb1ec897a77f1a782bc8db8c4a47a7cf8e Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Thu, 15 Apr 2021 11:53:13 +0200 Subject: [PATCH] s3: smbd: Update file times right before closing the underlying fd Next commits will update file_ntimes() to use handle-based SMB_VFS_FNTIMES(). Move the update_write_time_on_close() call immediately before closing the fd. Signed-off-by: Samuel Cabrero Reviewed-by: Ralph Boehme --- source3/smbd/close.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index d4f236e3de9..4e062f470ec 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -807,30 +807,29 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp, locking_close_file(fsp, close_type); - tmp = fd_close(fsp); - status = ntstatus_keeperror(status, tmp); - - /* check for magic scripts */ - if (close_type == NORMAL_CLOSE) { - tmp = check_magic(fsp); - status = ntstatus_keeperror(status, tmp); - } - /* - * Ensure pending modtime is set after close. + * Ensure pending modtime is set before closing underlying fd. */ tmp = update_write_time_on_close(fsp); if (NT_STATUS_EQUAL(tmp, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - /* Someone renamed the file or a parent directory containing - * this file. We can't do anything about this, we don't have - * an "update timestamp by fd" call in POSIX. Eat the error. */ - + /* + * Someone renamed the file or a parent directory containing + * this file. We can't do anything about this, eat the error. + */ tmp = NT_STATUS_OK; } + status = ntstatus_keeperror(status, tmp); + tmp = fd_close(fsp); status = ntstatus_keeperror(status, tmp); + /* check for magic scripts */ + if (close_type == NORMAL_CLOSE) { + tmp = check_magic(fsp); + status = ntstatus_keeperror(status, tmp); + } + DEBUG(2,("%s closed file %s (numopen=%d) %s\n", conn->session_info->unix_info->unix_name, fsp_str_dbg(fsp), conn->num_files_open - 1, -- 2.47.3