torture3: Check error code for quotactl on a non-quota file handle
authorVolker Lendecke <vl@samba.org>
Fri, 22 May 2020 13:24:06 +0000 (15:24 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 29 May 2020 08:34:31 +0000 (08:34 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14367

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/quota1 [new file with mode: 0644]
source3/selftest/tests.py
source3/torture/proto.h
source3/torture/test_smb2.c
source3/torture/torture.c

diff --git a/selftest/knownfail.d/quota1 b/selftest/knownfail.d/quota1
new file mode 100644 (file)
index 0000000..4872f78
--- /dev/null
@@ -0,0 +1,4 @@
+^samba3.smbtorture_s3.crypt_client.SMB2-QUOTA1.smbtorture\(nt4_dc_smb1\)
+^samba3.smbtorture_s3.plain.SMB2-QUOTA1.smbtorture\(fileserver\)
+# ntvfs returns NT_STATUS_NOT_SUPPORTED
+^samba3.smbtorture_s3.plain.SMB2-QUOTA1.smbtorture\(ad_dc_ntvfs\)
index 6d8a730bb07b729e3a469c7f774d558f8a593b06..fb07610c3f0e5225dfa206d966367525309532af 100755 (executable)
@@ -96,6 +96,7 @@ fileserver_tests = [
          "SMB2-SESSION-REAUTH", "SMB2-SESSION-RECONNECT", "SMB2-FTRUNCATE",
          "SMB2-ANONYMOUS", "SMB2-DIR-FSYNC",
         "SMB2-PATH-SLASH",
+        "SMB2-QUOTA1",
          "CLEANUP1",
          "CLEANUP2",
          "CLEANUP4",
index f9c79fd790685b7ef31b833df74f5d2387c6b4ab..18e686089ed2f147b92b255c8aa5dbe846daa24d 100644 (file)
@@ -104,6 +104,7 @@ bool run_smb2_ftruncate(int dummy);
 bool run_smb2_dir_fsync(int dummy);
 bool run_smb2_path_slash(int dummy);
 bool run_smb2_sacl(int dummy);
+bool run_smb2_quota1(int dummy);
 bool run_chain3(int dummy);
 bool run_local_conv_auth_info(int dummy);
 bool run_local_sprintf_append(int dummy);
index 52f1c3976238bab7d7dd74d872d6cd81dc6bcefd..0fb40a61dd0cc8addca1fd059f945331d470dc69 100644 (file)
@@ -2876,3 +2876,70 @@ bool run_smb2_sacl(int dummy)
        (void)cli_unlink(cli, fname, 0);
        return false;
 }
+
+bool run_smb2_quota1(int dummy)
+{
+       struct cli_state *cli = NULL;
+       NTSTATUS status;
+       uint16_t fnum = (uint16_t)-1;
+       SMB_NTQUOTA_STRUCT qt = {0};
+
+       printf("Starting SMB2-SACL\n");
+
+       if (!torture_init_connection(&cli)) {
+               return false;
+       }
+
+       status = smbXcli_negprot(cli->conn,
+                               cli->timeout,
+                               PROTOCOL_SMB2_02,
+                               PROTOCOL_SMB3_11);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smbXcli_negprot returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_session_setup_creds(cli, torture_creds);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_session_setup returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_tree_connect(cli, share, "?????", NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_tree_connect returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_smb2_create_fnum(
+               cli,
+               "\\",
+               SMB2_OPLOCK_LEVEL_NONE,
+               SMB2_IMPERSONATION_IMPERSONATION,
+               SEC_GENERIC_READ, /* desired access */
+               0, /* file_attributes, */
+               FILE_SHARE_READ|
+               FILE_SHARE_WRITE|
+               FILE_SHARE_DELETE, /* share_access, */
+               FILE_OPEN, /* create_disposition, */
+               FILE_DIRECTORY_FILE, /* create_options, */
+               NULL, /* in_cblobs. */
+               &fnum, /* fnum */
+               NULL, /* smb_create_returns  */
+               NULL, /* mem_ctx */
+               NULL); /* out_cblobs */
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_smb2_create_fnum failed: %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_smb2_get_user_quota(cli, fnum, &qt);
+       if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
+               printf("cli_smb2_get_user_quota returned %s, expected "
+                      "NT_STATUS_INVALID_HANDLE\n",
+                      nt_errstr(status));
+               return false;
+       }
+
+       return true;
+}
index e183ea2c5ca1356550cfbfff1c3f4a3bc5b6c1e2..997e074c481e2644267651b9a9034674d8a8a9c5 100644 (file)
@@ -14720,6 +14720,10 @@ static struct {
                .name  = "SMB2-SACL",
                .fn    = run_smb2_sacl,
        },
+       {
+               .name  = "SMB2-QUOTA1",
+               .fn    = run_smb2_quota1,
+       },
        {
                .name  = "CLEANUP1",
                .fn    = run_cleanup1,