The branch, master has been updated
       via  8e5adf7 Fixed regression test case for Bug 8412 - Microsoft Office 
2007 (Microsoft Word) fails to save as on a Samba share with SMB2
       via  dec3b21 Fix bug 8412 - Microsoft Office 2007 (Microsoft Word) fails 
to save as on a Samba share with SMB2.
       via  218cccf Fix bug Bug 8422 - Infinite loop in ACL module code.
      from  f7f6992 s4: Mark the winsreplication test as knownfail

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


- Log -----------------------------------------------------------------
commit 8e5adf72ebe3e7193c9e9197f5f21a075b0df78c
Author: Jeremy Allison <[email protected]>
Date:   Mon Aug 29 16:49:29 2011 -0700

    Fixed regression test case for Bug 8412 - Microsoft Office 2007 (Microsoft 
Word) fails to save as on a Samba share with SMB2
    
    Autobuild-User: Jeremy Allison <[email protected]>
    Autobuild-Date: Tue Aug 30 03:26:49 CEST 2011 on sn-devel-104

commit dec3b21cd1737b317749e7ebced5aa1c2115ebdf
Author: Jeremy Allison <[email protected]>
Date:   Mon Aug 29 16:47:16 2011 -0700

    Fix bug 8412 - Microsoft Office 2007 (Microsoft Word) fails to save as on a 
Samba share with SMB2.

commit 218cccfdf1820a9840a5cbc7df3915b6b58a762d
Author: Jeremy Allison <[email protected]>
Date:   Mon Aug 29 16:46:15 2011 -0700

    Fix bug Bug 8422 - Infinite loop in ACL module code.
    
    Missing assignment means this loop will never terminate. Need to be applied
    to 3.5.x and 3.6.1.

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

Summary of changes:
 source3/modules/vfs_acl_common.c |    2 +-
 source3/smbd/reply.c             |   46 ++++++++++++++++++++++++++++++++++++++
 source3/smbd/smb2_setinfo.c      |    6 -----
 source4/torture/smb2/oplock.c    |   42 +++++++++++++++++++++++++++++++++-
 4 files changed, 87 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index a4d712f..f2f55ec 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -869,7 +869,7 @@ static int acl_common_remove_object(vfs_handle_struct 
*handle,
        /* Ensure we have this file open with DELETE access. */
        id = vfs_file_id_from_sbuf(conn, &local_fname.st);
        for (fsp = file_find_di_first(conn->sconn, id); fsp;
-            file_find_di_next(fsp)) {
+                    fsp = file_find_di_next(fsp)) {
                if (fsp->access_mask & DELETE_ACCESS &&
                                fsp->delete_on_close) {
                        /* We did open this for delete,
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 124c610..6f2f281 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5960,6 +5960,47 @@ static void notify_rename(connection_struct *conn, bool 
is_dir,
 }
 
 /****************************************************************************
+ Returns an error if the parent directory for a filename is open in an
+ incompatible way.
+****************************************************************************/
+
+static NTSTATUS parent_dirname_compatible_open(connection_struct *conn,
+                                       const struct smb_filename 
*smb_fname_dst_in)
+{
+       char *parent_dir = NULL;
+       struct smb_filename smb_fname_parent;
+       struct file_id id;
+       files_struct *fsp = NULL;
+       int ret;
+
+       if (!parent_dirname(talloc_tos(), smb_fname_dst_in->base_name,
+                       &parent_dir, NULL)) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       ZERO_STRUCT(smb_fname_parent);
+       smb_fname_parent.base_name = parent_dir;
+
+       ret = SMB_VFS_LSTAT(conn, &smb_fname_parent);
+       if (ret == -1) {
+               return map_nt_error_from_unix(errno);
+       }
+
+       /*
+        * We're only checking on this smbd here, mostly good
+        * enough.. and will pass tests.
+        */
+
+       id = vfs_file_id_from_sbuf(conn, &smb_fname_parent.st);
+       for (fsp = file_find_di_first(conn->sconn, id); fsp;
+                       fsp = file_find_di_next(fsp)) {
+               if (fsp->access_mask & DELETE_ACCESS) {
+                       return NT_STATUS_SHARING_VIOLATION;
+                }
+        }
+       return NT_STATUS_OK;
+}
+
+/****************************************************************************
  Rename an open file - given an fsp.
 ****************************************************************************/
 
@@ -5980,6 +6021,11 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                return status;
        }
 
+       status = parent_dirname_compatible_open(conn, smb_fname_dst_in);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
        /* Make a copy of the dst smb_fname structs */
 
        status = copy_smb_filename(ctx, smb_fname_dst_in, &smb_fname_dst);
diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c
index e114940..96b44aa 100644
--- a/source3/smbd/smb2_setinfo.c
+++ b/source3/smbd/smb2_setinfo.c
@@ -219,12 +219,6 @@ static struct tevent_req 
*smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx,
                if (file_info_level == SMB_FILE_RENAME_INFORMATION) {
                        /* SMB2_FILE_RENAME_INFORMATION_INTERNAL == 0xFF00 + 
in_file_info_class */
                        file_info_level = SMB2_FILE_RENAME_INFORMATION_INTERNAL;
-                       if (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK &&
-                           fsp->oplock_type != NO_OPLOCK) {
-                               /* No break, but error. */
-                               tevent_req_nterror(req, 
NT_STATUS_SHARING_VIOLATION);
-                               return tevent_req_post(req, ev);
-                       }
                }
 
                if (fsp->fh->fd == -1) {
diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c
index 2d74c5d..e5c3571 100644
--- a/source4/torture/smb2/oplock.c
+++ b/source4/torture/smb2/oplock.c
@@ -734,6 +734,7 @@ static bool test_smb2_oplock_exclusive6(struct 
torture_context *tctx,
        bool ret = true;
        union smb_open io;
        union smb_setfileinfo sinfo;
+       struct smb2_close closeio;
        struct smb2_handle h, h1;
 
        status = torture_smb2_testdir(tree1, BASEDIR, &h);
@@ -772,7 +773,8 @@ static bool test_smb2_oplock_exclusive6(struct 
torture_context *tctx,
        h1 = io.smb2.out.file.handle;
        CHECK_VAL(io.smb2.out.oplock_level, SMB2_OPLOCK_LEVEL_EXCLUSIVE);
 
-       torture_comment(tctx, "rename should not generate a break but get "
+       torture_comment(tctx, "rename with the parent directory handle open "
+                       "for DELETE should not generate a break but get "
                        "a sharing violation\n");
        ZERO_STRUCT(sinfo);
        sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION;
@@ -781,13 +783,49 @@ static bool test_smb2_oplock_exclusive6(struct 
torture_context *tctx,
        sinfo.rename_information.in.new_name = fname2;
        status = smb2_setinfo_file(tree1, &sinfo);
 
-       torture_comment(tctx, "trying rename while first file open\n");
+       torture_comment(tctx, "trying rename while parent handle open for 
delete.\n");
        torture_assert_ntstatus_equal(tctx, status, NT_STATUS_SHARING_VIOLATION,
                                      "Incorrect status");
        torture_wait_for_oplock_break(tctx);
        CHECK_VAL(break_info.count, 0);
        CHECK_VAL(break_info.failures, 0);
 
+       /* Close the parent directry handle. */
+       ZERO_STRUCT(closeio);
+       closeio.in.file.handle = h;
+       status = smb2_close(tree1, &closeio);
+       torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OK,
+                                     "Incorrect status");
+
+       /* Re-open without DELETE access. */
+       ZERO_STRUCT(io);
+       io.smb2.in.oplock_level = 0;
+       io.smb2.in.desired_access = SEC_RIGHTS_FILE_ALL & (~SEC_STD_DELETE);
+       io.smb2.in.file_attributes   = FILE_ATTRIBUTE_DIRECTORY;
+       io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
+       io.smb2.in.share_access = 
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE;
+       io.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+       io.smb2.in.fname = BASEDIR;
+
+       status = smb2_create(tree1, tctx, &(io.smb2));
+       torture_assert_ntstatus_ok(tctx, status, "Error opening the base 
directory");
+
+       torture_comment(tctx, "rename with the parent directory handle open "
+                       "without DELETE should succeed without a break\n");
+       ZERO_STRUCT(sinfo);
+       sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION;
+       sinfo.rename_information.in.file.handle = h1;
+       sinfo.rename_information.in.overwrite = true;
+       sinfo.rename_information.in.new_name = fname2;
+       status = smb2_setinfo_file(tree1, &sinfo);
+
+       torture_comment(tctx, "trying rename while parent handle open without 
delete\n");
+       torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OK,
+                                     "Incorrect status");
+       torture_wait_for_oplock_break(tctx);
+       CHECK_VAL(break_info.count, 0);
+       CHECK_VAL(break_info.failures, 0);
+
        smb2_util_close(tree1, h1);
        smb2_util_close(tree1, h);
 


-- 
Samba Shared Repository

Reply via email to