The branch, v3-6-test has been updated
       via  498bb38 Add POSIX O_RDONLY test of a directory for bug #8112 - 
POSIX extension opens of a directory are denied with EISDIR.
       via  1c64ff3 Fix bug #8112 - POSIX extension opens of a directory are 
denied with EISDIR.
      from  d2c3354 s4:libcli/util/nterr: NO_S4U_PROT_SUPPORT and 
CROSSREALM_DELEGATION_FAILURE

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


- Log -----------------------------------------------------------------
commit 498bb38093e91b7d8c555e6ce900bd1af0789e2f
Author: Jeremy Allison <[email protected]>
Date:   Fri Apr 29 16:18:14 2011 -0700

    Add POSIX O_RDONLY test of a directory for bug #8112 - POSIX extension 
opens of a directory are denied with EISDIR.
    
    Don't strip access bits from wire flags when opening a directory.
    
    Autobuild-User: Jeremy Allison <[email protected]>
    Autobuild-Date: Sat Apr 30 02:21:24 CEST 2011 on sn-devel-104
    (cherry picked from commit de87f549b75d05a1198c490f6aa5c7e62c3fd4a5)

commit 1c64ff3b0d5b0379c1b5e6637ccdc67f3caec33f
Author: Jeremy Allison <[email protected]>
Date:   Fri Apr 29 16:15:55 2011 -0700

    Fix bug #8112 - POSIX extension opens of a directory are denied with EISDIR.
    
    Ensure create_options are passed down to SMB_VFS_CREATE_FILE().
    Correctly set create_options is SMB_O_DIRECTORY is set or pathname
    is known to be a directory.
    
    Jeremy.
    (cherry picked from commit 2cb53f066e0e42d923be89dd3a7e18ea7a1b7340)

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

Summary of changes:
 source3/libsmb/clifile.c  |    2 --
 source3/smbd/trans2.c     |   12 ++++++++++--
 source3/torture/torture.c |   12 ++++++++++--
 3 files changed, 20 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 7b39f50..bc56d40 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -4397,7 +4397,6 @@ static uint32_t open_flags_to_wire(int flags)
 #endif
 #if defined(O_DIRECTORY)
        if (flags & O_DIRECTORY) {
-               ret &= ~(SMB_O_RDONLY|SMB_O_RDWR|SMB_O_WRONLY);
                ret |= SMB_O_DIRECTORY;
        }
 #endif
@@ -4472,7 +4471,6 @@ static struct tevent_req 
*cli_posix_open_internal_send(TALLOC_CTX *mem_ctx,
 
        /* Setup data words. */
        if (is_dir) {
-               wire_flags &= ~(SMB_O_RDONLY|SMB_O_RDWR|SMB_O_WRONLY);
                wire_flags |= SMB_O_DIRECTORY;
        }
 
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 028d318..46f2aa0 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -7240,7 +7240,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
        uint32 mod_unixmode = 0;
        uint32 create_disp = 0;
        uint32 access_mask = 0;
-       uint32 create_options = 0;
+       uint32 create_options = FILE_NON_DIRECTORY_FILE;
        NTSTATUS status = NT_STATUS_OK;
        mode_t unixmode = (mode_t)0;
        files_struct *fsp = NULL;
@@ -7354,6 +7354,14 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
        if (wire_open_mode & SMB_O_SYNC) {
                create_options |= FILE_WRITE_THROUGH;
        }
+       if ((wire_open_mode & SMB_O_DIRECTORY) ||
+                       VALID_STAT_OF_DIR(smb_fname->st)) {
+               if (access_mask != FILE_READ_DATA) {
+                       return NT_STATUS_FILE_IS_A_DIRECTORY;
+               }
+               create_options &= ~FILE_NON_DIRECTORY_FILE;
+               create_options |= FILE_DIRECTORY_FILE;
+       }
        if (wire_open_mode & SMB_O_APPEND) {
                access_mask |= FILE_APPEND_DATA;
        }
@@ -7375,7 +7383,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
                    FILE_SHARE_DELETE),
                create_disp,                            /* create_disposition*/
-               FILE_NON_DIRECTORY_FILE,                /* create_options */
+               create_options,                         /* create_options */
                mod_unixmode,                           /* file_attributes */
                oplock_request,                         /* oplock_request */
                0,                                      /* allocation_size */
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 8f53192..4d0a839 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5073,8 +5073,16 @@ static bool run_simple_posix_open_test(int dummy)
                goto out;
        }
 
-       /* What happens when we try and POSIX open a directory ? */
-       if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) {
+       if (!NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) 
{
+               printf("POSIX open directory O_RDONLY of %s failed (%s)\n",
+                       dname, cli_errstr(cli1));
+               goto out;
+       }
+
+       cli_close(cli1, fnum1);
+
+       /* What happens when we try and POSIX open a directory for write ? */
+       if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDWR, 0, &fnum1))) {
                printf("POSIX open of directory %s succeeded, should have 
failed.\n", fname);
                goto out;
        } else {


-- 
Samba Shared Repository

Reply via email to