The branch, master has been updated
       via  1884b928723e362250272f6986fb08fcee57ebc1 (commit)
       via  4e1a4cbe1f939f771554fa313eaf905fd72c2ff9 (commit)
       via  307f4a66acfe3836550d57caf9aba347b24ba61e (commit)
      from  dc9387ec42b40ace38ba398148f5c20ae13e4a2c (commit)

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


- Log -----------------------------------------------------------------
commit 1884b928723e362250272f6986fb08fcee57ebc1
Author: todd stecher <[email protected]>
Date:   Wed Feb 11 09:52:02 2009 -0800

    s3 OneFS: Expand the usage of the ignore sacl parameter

commit 4e1a4cbe1f939f771554fa313eaf905fd72c2ff9
Author: Zack Kirsch <[email protected]>
Date:   Mon Feb 9 21:58:50 2009 -0800

    s4 torture: Smbtorture additions for Windows BRL
    
    - Adds a few new BRL tests to RAW-LOCK
    - Adds a "win7" target to allow torture to handle protocol changes in
      windows 7

commit 307f4a66acfe3836550d57caf9aba347b24ba61e
Author: Zack Kirsch <[email protected]>
Date:   Mon Feb 9 21:59:40 2009 -0800

    s4 torture: Two minor fixes to smbtorture BRL tests.

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

Summary of changes:
 libcli/util/ntstatus.h          |    3 +
 source3/modules/onefs_acl.c     |    6 +
 source3/modules/onefs_open.c    |    5 +
 source4/torture/basic/locking.c |    2 +-
 source4/torture/raw/lock.c      |  573 ++++++++++++++++++++++++++++++++++++++-
 source4/torture/smbtorture.c    |    2 +
 6 files changed, 583 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h
index 139562d..1608e28 100644
--- a/libcli/util/ntstatus.h
+++ b/libcli/util/ntstatus.h
@@ -60,6 +60,9 @@ typedef uint32_t NTSTATUS;
 #define ERROR_INSUFFICIENT_BUFFER        NT_STATUS(0x007a)
 #define ERROR_INVALID_DATATYPE           NT_STATUS(0x070c)
 
+/* XXX Win7 Status code: Name unknown. */
+#define NT_STATUS_WIN7_INVALID_RANGE NT_STATUS(0xC0000000 | 0x01a1)
+
 /* Win32 Error codes extracted using a loop in smbclient then printing a
    netmon sniff to a file. */
 
diff --git a/source3/modules/onefs_acl.c b/source3/modules/onefs_acl.c
index 0ef7e0b..0239479 100644
--- a/source3/modules/onefs_acl.c
+++ b/source3/modules/onefs_acl.c
@@ -619,6 +619,12 @@ onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct 
*fsp,
        DEBUG(5, ("Getting sd for file %s. security_info=%u\n",
            fsp->fsp_name, security_info));
 
+       if (lp_parm_bool(SNUM(fsp->conn), PARM_ONEFS_TYPE,
+               PARM_IGNORE_SACL, PARM_IGNORE_SACL_DEFAULT)) {
+               DEBUG(5, ("Ignoring SACL on %s.\n", fsp->fsp_name));
+               security_info &= ~SACL_SECURITY_INFORMATION;
+       }
+
        if (fsp->fh->fd == -1) {
                if ((fsp->fh->fd = onefs_sys_create_file(handle->conn,
                                                         -1,
diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c
index b2b11eb..e335dc7 100644
--- a/source3/modules/onefs_open.c
+++ b/source3/modules/onefs_open.c
@@ -744,6 +744,11 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
                open_access_mask |= FILE_WRITE_DATA;
        }
 
+       if (lp_parm_bool(SNUM(fsp->conn), PARM_ONEFS_TYPE,
+               PARM_IGNORE_SACL, PARM_IGNORE_SACL_DEFAULT)) {
+               access_mask &= ~SYSTEM_SECURITY_ACCESS;
+       }
+
        DEBUG(10, ("onefs_open_file_ntcreate: fname=%s, after mapping "
                   "open_access_mask=%#x, access_mask=0x%x\n",
                   fname, open_access_mask, access_mask));
diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c
index fcac52c..06a960b 100644
--- a/source4/torture/basic/locking.c
+++ b/source4/torture/basic/locking.c
@@ -610,7 +610,7 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 
4)) &&
                  NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4));
 
        EXPECTED(ret, true);
-       torture_comment(tctx, "the same process %s unlock the stack of 4 
locks\n", ret?"can":"cannot"); 
+       torture_comment(tctx, "the same process %s unlock the stack of 3 
locks\n", ret?"can":"cannot");
 
        /* Ensure the next unlock fails. */
        ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4));
diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c
index 2d1eae3..72a03e1 100644
--- a/source4/torture/raw/lock.c
+++ b/source4/torture/raw/lock.c
@@ -38,8 +38,34 @@
                goto done; \
        }} while (0)
 
+#define CHECK_STATUS_CONT(status, correct) do { \
+       if (!NT_STATUS_EQUAL(status, correct)) { \
+               printf("(%s) Incorrect status %s - should be %s\n", \
+                      __location__, nt_errstr(status), nt_errstr(correct)); \
+               ret = false; \
+       }} while (0)
+
+#define CHECK_STATUS_OR(status, correct1, correct2) do { \
+       if ((!NT_STATUS_EQUAL(status, correct1)) && \
+           (!NT_STATUS_EQUAL(status, correct2))) { \
+               printf("(%s) Incorrect status %s - should be %s or %s\n", \
+                      __location__, nt_errstr(status), nt_errstr(correct1), \
+                      nt_errstr(correct2)); \
+               ret = false; \
+               goto done; \
+       }} while (0)
+
+#define CHECK_STATUS_OR_CONT(status, correct1, correct2) do { \
+       if ((!NT_STATUS_EQUAL(status, correct1)) && \
+           (!NT_STATUS_EQUAL(status, correct2))) { \
+               printf("(%s) Incorrect status %s - should be %s or %s\n", \
+                      __location__, nt_errstr(status), nt_errstr(correct1), \
+                      nt_errstr(correct2)); \
+               ret = false; \
+       }} while (0)
 #define BASEDIR "\\testlock"
 
+#define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false))
 
 /*
   test SMBlock and SMBunlock ops
@@ -337,15 +363,25 @@ static bool test_lockx(struct torture_context *tctx, 
struct smbcli_state *cli)
        lock[0].pid++;
        lock[0].count = 2;
        status = smb_raw_lock(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       if (TARGET_IS_WIN7(tctx))
+               CHECK_STATUS(status, NT_STATUS_WIN7_INVALID_RANGE);
+       else
+               CHECK_STATUS(status, NT_STATUS_OK);
        lock[0].pid--;
        io.lockx.in.ulock_cnt = 1;
        io.lockx.in.lock_cnt = 0;
        lock[0].count = 1;
        status = smb_raw_lock(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       status = smb_raw_lock(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+       /* XXX This is very strange - Win7 gives us an invalid range when we
+        * unlock the range even though the range is locked! Win7 bug? */
+       if (TARGET_IS_WIN7(tctx))
+               CHECK_STATUS(status, NT_STATUS_WIN7_INVALID_RANGE);
+       else {
+               CHECK_STATUS(status, NT_STATUS_OK);
+               status = smb_raw_lock(cli->tree, &io);
+               CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+       }
 
 done:
        smbcli_close(cli->tree, fnum);
@@ -354,7 +390,6 @@ done:
        return ret;
 }
 
-
 /*
   test high pid
 */
@@ -410,8 +445,6 @@ static bool test_pidhigh(struct torture_context *tctx,
                goto done;
        }
 
-       cli->session->pid |= 0x10000;
-
        cli->session->pid = 2;
 
        if (smbcli_read(cli->tree, fnum, &c, 0, 1) == 1) {
@@ -1321,6 +1354,525 @@ done:
        return ret;
 }
 
+struct double_lock_test {
+       struct smb_lock_entry lock1;
+       struct smb_lock_entry lock2;
+       NTSTATUS exp_status;
+};
+
+/**
+ * Tests zero byte locks.
+ */
+struct double_lock_test zero_byte_tests[] = {
+       /* {pid, offset, count}, {pid, offset, count}, status */
+
+       /** First, takes a zero byte lock at offset 10. Then:
+       *   - Taking 0 byte lock at 10 should succeed.
+       *   - Taking 1 byte locks at 9,10,11 should succeed.
+       *   - Taking 2 byte lock at 9 should fail.
+       *   - Taking 2 byte lock at 10 should succeed.
+       *   - Taking 3 byte lock at 9 should fail.
+       */
+       {{1000, 10, 0}, {1001, 10, 0}, NT_STATUS_OK},
+       {{1000, 10, 0}, {1001, 9, 1},  NT_STATUS_OK},
+       {{1000, 10, 0}, {1001, 10, 1}, NT_STATUS_OK},
+       {{1000, 10, 0}, {1001, 11, 1}, NT_STATUS_OK},
+       {{1000, 10, 0}, {1001, 9, 2},  NT_STATUS_LOCK_NOT_GRANTED},
+       {{1000, 10, 0}, {1001, 10, 2}, NT_STATUS_OK},
+       {{1000, 10, 0}, {1001, 9, 3},  NT_STATUS_LOCK_NOT_GRANTED},
+
+       /** Same, but opposite order. */
+       {{1001, 10, 0}, {1000, 10, 0}, NT_STATUS_OK},
+       {{1001, 9, 1},  {1000, 10, 0}, NT_STATUS_OK},
+       {{1001, 10, 1}, {1000, 10, 0}, NT_STATUS_OK},
+       {{1001, 11, 1}, {1000, 10, 0}, NT_STATUS_OK},
+       {{1001, 9, 2},  {1000, 10, 0}, NT_STATUS_LOCK_NOT_GRANTED},
+       {{1001, 10, 2}, {1000, 10, 0}, NT_STATUS_OK},
+       {{1001, 9, 3},  {1000, 10, 0}, NT_STATUS_LOCK_NOT_GRANTED},
+
+       /** Zero zero case. */
+       {{1000, 0, 0},  {1001, 0, 0},  NT_STATUS_OK},
+};
+
+static bool test_zerobytelocks(struct torture_context *tctx, struct 
smbcli_state *cli)
+{
+       union smb_lock io;
+       struct smb_lock_entry zerozero;
+       NTSTATUS status;
+       bool ret = true;
+       int fnum, i;
+       const char *fname = BASEDIR "\\zero.txt";
+
+       printf("Testing zero length byte range locks:\n");
+
+       if (!torture_setup_dir(cli, BASEDIR)) {
+               return false;
+       }
+
+       io.generic.level = RAW_LOCK_LOCKX;
+
+       fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+       if (fnum == -1) {
+               printf("Failed to create %s - %s\n", fname, 
smbcli_errstr(cli->tree));
+               ret = false;
+               goto done;
+       }
+
+       /* Setup initial parameters */
+       io.lockx.level = RAW_LOCK_LOCKX;
+       io.lockx.in.file.fnum = fnum;
+       io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; /* Exclusive */
+       io.lockx.in.timeout = 0;
+
+       /* Try every combination of locks in zero_byte_tests. The first lock is
+        * assumed to succeed. The second lock may contend, depending on the
+        * expected status. */
+       for (i = 0;
+            i < sizeof(zero_byte_tests) / sizeof(struct double_lock_test);
+            i++) {
+               printf("  ... {%d, %llu, %llu} + {%d, %llu, %llu} = %s\n",
+                   zero_byte_tests[i].lock1.pid,
+                   zero_byte_tests[i].lock1.offset,
+                   zero_byte_tests[i].lock1.count,
+                   zero_byte_tests[i].lock2.pid,
+                   zero_byte_tests[i].lock2.offset,
+                   zero_byte_tests[i].lock2.count,
+                   nt_errstr(zero_byte_tests[i].exp_status));
+
+               /* Lock both locks. */
+               io.lockx.in.ulock_cnt = 0;
+               io.lockx.in.lock_cnt = 1;
+
+               io.lockx.in.locks = &zero_byte_tests[i].lock1;
+               status = smb_raw_lock(cli->tree, &io);
+               CHECK_STATUS(status, NT_STATUS_OK);
+
+               io.lockx.in.locks = &zero_byte_tests[i].lock2;
+               status = smb_raw_lock(cli->tree, &io);
+
+               if (NT_STATUS_EQUAL(zero_byte_tests[i].exp_status,
+                       NT_STATUS_LOCK_NOT_GRANTED)) {
+                       /* Allow either of the failure messages and keep going
+                        * if we see the wrong status. */
+                       CHECK_STATUS_OR_CONT(status,
+                           NT_STATUS_LOCK_NOT_GRANTED,
+                           NT_STATUS_FILE_LOCK_CONFLICT);
+
+               } else {
+                       CHECK_STATUS_CONT(status,
+                           zero_byte_tests[i].exp_status);
+               }
+
+               /* Unlock both locks. */
+               io.lockx.in.ulock_cnt = 1;
+               io.lockx.in.lock_cnt = 0;
+
+               if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+                       status = smb_raw_lock(cli->tree, &io);
+                       CHECK_STATUS(status, NT_STATUS_OK);
+               }
+
+               io.lockx.in.locks = &zero_byte_tests[i].lock1;
+               status = smb_raw_lock(cli->tree, &io);
+               CHECK_STATUS(status, NT_STATUS_OK);
+       }
+
+done:
+       smbcli_close(cli->tree, fnum);
+       smb_raw_exit(cli->session);
+       smbcli_deltree(cli->tree, BASEDIR);
+       return ret;
+}
+
+static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
+{
+       union smb_lock io;
+       NTSTATUS status;
+       bool ret = true;
+       int fnum1, fnum2;
+       const char *fname = BASEDIR "\\unlock.txt";
+       struct smb_lock_entry lock1;
+       struct smb_lock_entry lock2;
+
+       printf("Testing LOCKX unlock:\n");
+
+       if (!torture_setup_dir(cli, BASEDIR)) {
+               return false;
+       }
+
+       fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+       if (fnum1 == -1) {
+               printf("Failed to create %s - %s\n", fname, 
smbcli_errstr(cli->tree));
+               ret = false;
+               goto done;
+       }
+       fnum2 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+       if (fnum2 == -1) {
+               printf("Failed to create %s - %s\n", fname, 
smbcli_errstr(cli->tree));
+               ret = false;
+               goto done;
+       }
+
+       /* Setup initial parameters */
+       io.lockx.level = RAW_LOCK_LOCKX;
+       io.lockx.in.timeout = 0;
+
+       lock1.pid = cli->session->pid;
+       lock1.offset = 0;
+       lock1.count = 10;
+       lock2.pid = cli->session->pid - 1;
+       lock2.offset = 0;
+       lock2.count = 10;
+
+       /**
+        * Take exclusive lock, then unlock it with a shared-unlock call.
+        */
+       printf("  taking exclusive lock.\n");
+       io.lockx.in.ulock_cnt = 0;
+       io.lockx.in.lock_cnt = 1;
+       io.lockx.in.mode = 0;
+       io.lockx.in.file.fnum = fnum1;
+       io.lockx.in.locks = &lock1;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       printf("  unlock the exclusive with a shared unlock call.\n");
+       io.lockx.in.ulock_cnt = 1;
+       io.lockx.in.lock_cnt = 0;
+       io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
+       io.lockx.in.file.fnum = fnum1;
+       io.lockx.in.locks = &lock1;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       printf("  try shared lock on pid2/fnum2, testing the unlock.\n");
+       io.lockx.in.ulock_cnt = 0;
+       io.lockx.in.lock_cnt = 1;
+       io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
+       io.lockx.in.file.fnum = fnum2;
+       io.lockx.in.locks = &lock2;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       /**
+        * Unlock a shared lock with an exclusive-unlock call.
+        */
+       printf("  unlock new shared lock with exclusive unlock call.\n");
+       io.lockx.in.ulock_cnt = 1;
+       io.lockx.in.lock_cnt = 0;
+       io.lockx.in.mode = 0;
+       io.lockx.in.file.fnum = fnum2;
+       io.lockx.in.locks = &lock2;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       printf("  try exclusive lock on pid1, testing the unlock.\n");
+       io.lockx.in.ulock_cnt = 0;
+       io.lockx.in.lock_cnt = 1;
+       io.lockx.in.mode = 0;
+       io.lockx.in.file.fnum = fnum1;
+       io.lockx.in.locks = &lock1;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       /* cleanup */
+       io.lockx.in.ulock_cnt = 1;
+       io.lockx.in.lock_cnt = 0;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       /**
+        * Test unlocking of 0-byte locks.
+        */
+
+       printf("  lock shared and exclusive 0-byte locks, testing that Windows "
+           "always unlocks the exclusive first.\n");
+       lock1.pid = cli->session->pid;
+       lock1.offset = 10;
+       lock1.count = 0;
+       lock2.pid = cli->session->pid;
+       lock2.offset = 5;
+       lock2.count = 10;
+       io.lockx.in.ulock_cnt = 0;
+       io.lockx.in.lock_cnt = 1;
+       io.lockx.in.file.fnum = fnum1;
+       io.lockx.in.locks = &lock1;
+
+       /* lock 0-byte shared
+        * Note: Order of the shared/exclusive locks doesn't matter. */
+       io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       /* lock 0-byte exclusive */
+       io.lockx.in.mode = 0;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       /* test contention */
+       io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
+       io.lockx.in.locks = &lock2;
+       io.lockx.in.file.fnum = fnum2;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS_OR(status, NT_STATUS_LOCK_NOT_GRANTED,
+           NT_STATUS_FILE_LOCK_CONFLICT);
+
+       /* unlock */
+       io.lockx.in.ulock_cnt = 1;
+       io.lockx.in.lock_cnt = 0;
+       io.lockx.in.file.fnum = fnum1;
+       io.lockx.in.locks = &lock1;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       /* test - can we take a shared lock? */
+       io.lockx.in.ulock_cnt = 0;
+       io.lockx.in.lock_cnt = 1;
+       io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
+       io.lockx.in.file.fnum = fnum2;
+       io.lockx.in.locks = &lock2;
+       status = smb_raw_lock(cli->tree, &io);
+
+       /* XXX Samba will fail this test. This is temporary(because this isn't
+        * new to Win7, it succeeds in WinXP too), until I can come to a
+        * resolution as to whether Samba should support this or not. There is
+        * code to preference unlocking exclusive locks before shared locks,
+        * but its wrapped with "#ifdef ZERO_ZERO". -zkirsch */
+       if (TARGET_IS_WIN7(tctx))
+               CHECK_STATUS(status, NT_STATUS_OK);
+       else {
+               CHECK_STATUS_OR(status, NT_STATUS_LOCK_NOT_GRANTED,
+                   NT_STATUS_FILE_LOCK_CONFLICT);
+       }
+
+       /* cleanup */
+       io.lockx.in.ulock_cnt = 1;
+       io.lockx.in.lock_cnt = 0;
+       status = smb_raw_lock(cli->tree, &io);
+
+        /* XXX Same as above. */
+        if (TARGET_IS_WIN7(tctx))
+                CHECK_STATUS(status, NT_STATUS_OK);
+        else
+                CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+
+       io.lockx.in.file.fnum = fnum1;
+       io.lockx.in.locks = &lock1;
+       status = smb_raw_lock(cli->tree, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+done:
+       smbcli_close(cli->tree, fnum1);
+       smbcli_close(cli->tree, fnum2);
+       smb_raw_exit(cli->session);
+       smbcli_deltree(cli->tree, BASEDIR);
+       return ret;
+}
+
+static bool test_multiple_unlock(struct torture_context *tctx, struct 
smbcli_state *cli)
+{
+       union smb_lock io;
+       NTSTATUS status;
+       bool ret = true;
+       int fnum1;
+       const char *fname = BASEDIR "\\unlock_multiple.txt";
+       struct smb_lock_entry lock1;
+       struct smb_lock_entry lock2;
+       struct smb_lock_entry locks[2];
+
+       printf("Testing LOCKX multiple unlock:\n");
+
+       if (!torture_setup_dir(cli, BASEDIR)) {
+               return false;
+       }
+
+       fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+       if (fnum1 == -1) {
+               printf("Failed to create %s - %s\n", fname, 
smbcli_errstr(cli->tree));
+               ret = false;
+               goto done;
+       }
+
+       /* Setup initial parameters */
+       io.lockx.level = RAW_LOCK_LOCKX;
+       io.lockx.in.timeout = 0;
+
+       lock1.pid = cli->session->pid;
+       lock1.offset = 0;
+       lock1.count = 10;
+       lock2.pid = cli->session->pid;
+       lock2.offset = 10;
+       lock2.count = 10;
+


-- 
Samba Shared Repository

Reply via email to