torture3: Test LOCKINGX_CANCEL without locks
authorVolker Lendecke <vl@samba.org>
Mon, 3 Jun 2019 09:00:25 +0000 (11:00 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 20 Jun 2019 17:18:18 +0000 (17:18 +0000)
Tested against W2012R2

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail
source3/selftest/tests.py
source3/torture/torture.c

index 81fe4e6df8e67636b5e1a4060337567bb9b531b8..3f62bb5047a13e781fe0adc4455cad057c45514b 100644 (file)
@@ -9,6 +9,7 @@
  ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption
 ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test
 ^samba3.smbtorture_s3.plain.*SMB2-DIR-FSYNC.*\(ad_dc_ntvfs\)
+^samba3.smbtorture_s3.plain.LOCK11.*\(ad_dc_ntvfs\)
 ^samba3.smb2.session enc.reconnect # expected to give CONNECTION_DISCONNECTED, we need to fix the test
 ^samba3.raw.session enc # expected to give ACCESS_DENIED as SMB1 encryption isn't used
 ^samba3.smbtorture_s3.crypt_server # expected to give ACCESS_DENIED as SMB1 encryption isn't used
index 9bc5bdd0e5f73e23d397baf7fb79954000e17091..9dec692cb5a358a7d92190db3c16d1e826d1fbfe 100755 (executable)
@@ -80,6 +80,7 @@ plantestsuite("samba3.blackbox.registry.upgrade", "nt4_dc:local", [os.path.join(
 
 tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7", "LOCK9",
          "LOCK10",
+         "LOCK11",
          "UNLINK", "BROWSE", "ATTR", "TRANS2", "TORTURE",
          "OPLOCK1", "OPLOCK2", "OPLOCK4", "STREAMERROR",
          "DIR", "DIR1", "DIR-CREATETIME", "TCON", "TCONDEV", "RW1", "RW2", "RW3", "LARGE_READX", "RW-SIGNING",
index fee101791d42c4acee8e3443669d1c8212ef164f..a74598f68c22ca7fcd65dc33b19f7e74bc6adeae 100644 (file)
@@ -2894,6 +2894,58 @@ static void locktest10_read_andx_done(struct tevent_req *subreq)
        TALLOC_FREE(subreq);
 }
 
+static bool run_locktest11(int dummy)
+{
+       struct cli_state *cli1;
+       const char *fname = "\\lockt11.lck";
+       NTSTATUS status;
+       uint16_t fnum;
+       bool ret = false;
+
+       if (!torture_open_connection(&cli1, 0)) {
+               return false;
+       }
+
+       smbXcli_conn_set_sockopt(cli1->conn, sockops);
+
+       cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+
+       status = cli_openx(cli1, fname, O_CREAT|O_RDWR, DENY_NONE, &fnum);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_fprintf(stderr,
+                         "cli_openx returned %s\n",
+                         nt_errstr(status));
+               return false;
+       }
+
+       /*
+        * Test that LOCKING_ANDX_CANCEL_LOCK without any locks
+        * returns NT_STATUS_OK
+        */
+
+       status = cli_lockingx(
+               cli1,                           /* cli */
+               fnum,                           /* fnum */
+               LOCKING_ANDX_CANCEL_LOCK,       /* typeoflock */
+               0,                              /* newoplocklevel */
+               0,                              /* timeout */
+               0,                              /* num_unlocks */
+               NULL,                           /* unlocks */
+               0,                              /* num_locks */
+               NULL);                          /* locks */
+
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("cli_lockingX returned %s\n", nt_errstr(status));
+               goto fail;
+       }
+
+       ret = true;
+fail:
+       cli_close(cli1, fnum);
+       cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+
+       return ret;
+}
 /*
 test whether fnums and tids open on one VC are available on another (a major
 security hole)
@@ -12217,6 +12269,10 @@ static struct {
                .name = "LOCK10",
                .fn   =  run_locktest10,
        },
+       {
+               .name = "LOCK11",
+               .fn   =  run_locktest11,
+       },
        {
                .name = "UNLINK",
                .fn   = run_unlinktest,