From: Volker Lendecke Date: Fri, 22 May 2020 13:24:06 +0000 (+0200) Subject: torture3: Check error code for quotactl on a non-quota file handle X-Git-Tag: ldb-2.2.0~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f16ecc5ce3fd9a6fd084096d150a7b48fabb985;p=thirdparty%2Fsamba.git torture3: Check error code for quotactl on a non-quota file handle Bug: https://bugzilla.samba.org/show_bug.cgi?id=14367 Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- diff --git a/selftest/knownfail.d/quota1 b/selftest/knownfail.d/quota1 new file mode 100644 index 00000000000..4872f78746d --- /dev/null +++ b/selftest/knownfail.d/quota1 @@ -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\) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 6d8a730bb07..fb07610c3f0 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -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", diff --git a/source3/torture/proto.h b/source3/torture/proto.h index f9c79fd7906..18e686089ed 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -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); diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c index 52f1c397623..0fb40a61dd0 100644 --- a/source3/torture/test_smb2.c +++ b/source3/torture/test_smb2.c @@ -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; +} diff --git a/source3/torture/torture.c b/source3/torture/torture.c index e183ea2c5ca..997e074c481 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -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,