[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Wed Jul 3 04:23:05 MDT 2013


The branch, v4-0-test has been updated
       via  0b80e93 vfs_streams_xattr: Do not attempt to write empty attribute twice
       via  f695430 Initialize the file descriptor in the files_struct before trying to close it. Otherwise, if one of the SETXATTR calls had failed, the close() call will return EBADF.
      from  9f7cbc7 s3:smbd:smb2: fix setting of scavenge timeout when reconnecting durable handles

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 0b80e9376daf07089dac6221a51dff1ffee6cbac
Author: Christof Schmitt <christof.schmitt at us.ibm.com>
Date:   Wed Jun 12 14:55:15 2013 -0700

    vfs_streams_xattr: Do not attempt to write empty attribute twice
    
    The create disposition FILE_OVERWRITE_IF is mapped to the flags
    O_CREAT|O_TRUNC. In vfs_streams_xattr, this triggers two calls to
    SMB_VFS_SETXATTR. The second can fail if O_EXCL is also set, resulting
    in an unnecessary error.
    
    Merge the identical code to handle O_CREAT and O_TRUNC to avoid setting
    an empty attribute twice. Also add the flags parameter to the debug
    message.
    
    Signed-off-by: Christof Schmitt <christof.schmitt at us.ibm.com>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 4cd7e1d283f060e794023d5b0a48a7ec97d33820)
    
    The last two patches address bug #9970 - Backport vfs_streams_xattr fixes to 4.0
    and 4.1.
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Wed Jul  3 12:22:43 CEST 2013 on sn-devel-104

commit f695430ffb7bb036ffbfdbc5baafb8e8698670e8
Author: Christof Schmitt <christof.schmitt at us.ibm.com>
Date:   Wed Jun 12 14:49:53 2013 -0700

    Initialize the file descriptor in the files_struct before trying to close it. Otherwise, if one of the SETXATTR calls had failed, the close() call will return EBADF.
    
    Signed-off-by: Christof Schmitt <christof.schmitt at us.ibm.com>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Richard Sharpe <rsharpe at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Jun 13 01:43:18 CEST 2013 on sn-devel-104
    (cherry picked from commit 5c488cfb79873287e769622fd5da43b7a735e29c)

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

Summary of changes:
 source3/modules/vfs_streams_xattr.c |   43 +++++++++-------------------------
 1 files changed, 12 insertions(+), 31 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index dd1135d..6650021 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -367,8 +367,8 @@ static int streams_xattr_open(vfs_handle_struct *handle,
 	int baseflags;
 	int hostfd = -1;
 
-	DEBUG(10, ("streams_xattr_open called for %s\n",
-		   smb_fname_str_dbg(smb_fname)));
+	DEBUG(10, ("streams_xattr_open called for %s with flags 0x%x\n",
+		   smb_fname_str_dbg(smb_fname), flags));
 
 	if (!is_ntfs_stream_smb_fname(smb_fname)) {
 		return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
@@ -452,40 +452,20 @@ static int streams_xattr_open(vfs_handle_struct *handle,
 		goto fail;
 	}
 
-	if (!NT_STATUS_IS_OK(status)) {
+	if ((!NT_STATUS_IS_OK(status) && (flags & O_CREAT)) ||
+	    (flags & O_TRUNC)) {
 		/*
-		 * The attribute does not exist
+		 * The attribute does not exist or needs to be truncated
 		 */
 
-                if (flags & O_CREAT) {
-			/*
-			 * Darn, xattrs need at least 1 byte
-			 */
-                        char null = '\0';
+		/*
+		 * Darn, xattrs need at least 1 byte
+		 */
+		char null = '\0';
 
-			DEBUG(10, ("creating attribute %s on file %s\n",
-				   xattr_name, smb_fname->base_name));
+		DEBUG(10, ("creating or truncating attribute %s on file %s\n",
+			   xattr_name, smb_fname->base_name));
 
-			if (fsp->base_fsp->fh->fd != -1) {
-                        	if (SMB_VFS_FSETXATTR(
-					fsp->base_fsp, xattr_name,
-					&null, sizeof(null),
-					flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
-					goto fail;
-				}
-			} else {
-	                        if (SMB_VFS_SETXATTR(
-					handle->conn, smb_fname->base_name,
-					xattr_name, &null, sizeof(null),
-					flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
-					goto fail;
-				}
-			}
-		}
-	}
-
-	if (flags & O_TRUNC) {
-		char null = '\0';
 		if (fsp->base_fsp->fh->fd != -1) {
 			if (SMB_VFS_FSETXATTR(
 					fsp->base_fsp, xattr_name,
@@ -532,6 +512,7 @@ static int streams_xattr_open(vfs_handle_struct *handle,
 		 * BUGBUGBUG -- we would need to call fd_close_posix here, but
 		 * we don't have a full fsp yet
 		 */
+		fsp->fh->fd = hostfd;
 		SMB_VFS_CLOSE(fsp);
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list