vfs: kernel_flock and named streams
authorRalph Boehme <slow@samba.org>
Wed, 29 Apr 2015 14:53:04 +0000 (16:53 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 6 May 2015 18:25:15 +0000 (20:25 +0200)
Streams implementing VFS modules may implement streams in a way that the
fsp will have the basefile open in the fsp fd, so lacking a distinct fd
for the stream, kernel_flock will apply on the basefile which is
wrong. The actual check is deffered to the VFS module implementing the
kernel_flock call.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit d748652e5b1c1c0238a2b86cdf14d7f6de7ce9b2)

source3/modules/vfs_gpfs.c
source3/smbd/open.c

index f9eb7e86b123827c7ff6f0c1d40909bc5005ffd3..2efac192c177dfe0bdcf01b7aac89199a1694a51 100644 (file)
@@ -66,6 +66,16 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
                return 0;
        }
 
+       /*
+        * A named stream fsp will have the basefile open in the fsp
+        * fd, so lacking a distinct fd for the stream we have to skip
+        * kernel_flock and set_gpfs_sharemode for stream.
+        */
+       if (!is_ntfs_default_stream_smb_fname(fsp->fsp_name)) {
+               DEBUG(2,("%s: kernel_flock on stream\n", fsp_str_dbg(fsp)));
+               return 0;
+       }
+
        START_PROFILE(syscall_kernel_flock);
 
        kernel_flock(fsp->fh->fd, share_mode, access_mask);
index 4fcdff8c5b0e53f9fa07e86f8f1b8642c2fe1a28..f50db2fe798e944997e44c695a1acddb5409b569 100644 (file)
@@ -2737,6 +2737,15 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
        if (fsp->fh->fd != -1 && lp_kernel_share_modes(SNUM(conn))) {
                int ret_flock;
+               /*
+                * Beware: streams implementing VFS modules may
+                * implement streams in a way that fsp will have the
+                * basefile open in the fsp fd, so lacking a distinct
+                * fd for the stream kernel_flock will apply on the
+                * basefile which is wrong. The actual check is
+                * deffered to the VFS module implementing the
+                * kernel_flock call.
+                */
                ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, share_access, access_mask);
                if(ret_flock == -1 ){