vfs_streams_xattr: use SMB_VFS_NEXT_OPEN and CLOSE
authorRalph Boehme <slow@samba.org>
Wed, 8 Feb 2017 18:16:21 +0000 (19:16 +0100)
committerUri Simchoni <uri@samba.org>
Wed, 1 Mar 2017 23:32:20 +0000 (00:32 +0100)
Using the SMB_VFS_OPEN leads to a recursion in the VFS that is hard to
follow and debug. It's called twice for the same fsp with two different
smb_fname's which makes it at least hard to debug, it may even be an
invalid usage.

Changing this here to use the NEXT function instead should have no
change in behaviour otherwise.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12565

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/modules/vfs_streams_xattr.c

index e193d3572c5460f6e2b7b548eaafe67a150815a5..66926367823ebbe6e7102fd7975d4f4a91d0ae4d 100644 (file)
@@ -449,8 +449,8 @@ static int streams_xattr_open(vfs_handle_struct *handle,
         baseflags &= ~O_EXCL;
         baseflags &= ~O_CREAT;
 
-        hostfd = SMB_VFS_OPEN(handle->conn, smb_fname_base, fsp,
-                             baseflags, mode);
+        hostfd = SMB_VFS_NEXT_OPEN(handle, smb_fname_base, fsp,
+                                  baseflags, mode);
 
         /* It is legit to open a stream on a directory, but the base
          * fd has to be read-only.
@@ -458,8 +458,8 @@ static int streams_xattr_open(vfs_handle_struct *handle,
         if ((hostfd == -1) && (errno == EISDIR)) {
                 baseflags &= ~O_ACCMODE;
                 baseflags |= O_RDONLY;
-                hostfd = SMB_VFS_OPEN(handle->conn, smb_fname_base, fsp, baseflags,
-                                     mode);
+                hostfd = SMB_VFS_NEXT_OPEN(handle, smb_fname_base, fsp, baseflags,
+                                          mode);
         }
 
        TALLOC_FREE(smb_fname_base);
@@ -547,7 +547,7 @@ static int streams_xattr_open(vfs_handle_struct *handle,
                 * we don't have a full fsp yet
                 */
                fsp->fh->fd = hostfd;
-               SMB_VFS_CLOSE(fsp);
+               SMB_VFS_NEXT_CLOSE(handle, fsp);
        }
 
        return -1;