[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-1251-g59a28a2

Jeremy Allison jra at samba.org
Wed Feb 25 22:57:53 GMT 2009


The branch, master has been updated
       via  59a28a22ab26bb7f2c12f9bccda9c7f585d992a7 (commit)
      from  a6d0a93fc27729b63ae3fd4994059f3854a63845 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 59a28a22ab26bb7f2c12f9bccda9c7f585d992a7
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Feb 25 14:57:16 2009 -0800

    Fix more POSIX path lstat calls. Fix bug where close can return
    failure if we have a pending modtime and the containing directory
    of the file has been renamed (there is no POSIX "update time by
    fd" call). This can't happen on Windows as the rename will fail
    if there are open files beneath it. Will add a torture test
    for this.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/close.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 78b8123..d23b509 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -471,6 +471,7 @@ static NTSTATUS update_write_time_on_close(struct files_struct *fsp)
 	SMB_STRUCT_STAT sbuf;
 	struct smb_file_time ft;
 	NTSTATUS status;
+	int ret = -1;
 
 	ZERO_STRUCT(sbuf);
 	ZERO_STRUCT(ft);
@@ -485,15 +486,19 @@ static NTSTATUS update_write_time_on_close(struct files_struct *fsp)
 
 	/* Ensure we have a valid stat struct for the source. */
 	if (fsp->fh->fd != -1) {
-		if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
-			return map_nt_error_from_unix(errno);
-		}
+		ret = SMB_VFS_FSTAT(fsp, &sbuf);
 	} else {
-		if (SMB_VFS_STAT(fsp->conn,fsp->fsp_name,&sbuf) == -1) {
-			return map_nt_error_from_unix(errno);
+		if (fsp->posix_open) {
+			ret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name,&sbuf);
+		} else {
+			ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name,&sbuf);
 		}
 	}
 
+	if (ret == -1) {
+		return map_nt_error_from_unix(errno);
+	}
+
 	if (!VALID_STAT(sbuf)) {
 		/* if it doesn't seem to be a real file */
 		return NT_STATUS_OK;
@@ -581,6 +586,13 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp,
 	 */
 
 	saved_status4 = update_write_time_on_close(fsp);
+	if (NT_STATUS_EQUAL(saved_status4, 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. */
+
+		saved_status4 = NT_STATUS_OK;
+	}
 
 	if (NT_STATUS_IS_OK(status)) {
 		if (!NT_STATUS_IS_OK(saved_status1)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list