summaryrefslogtreecommitdiff
path: root/source3/torture/test_smb2.c
Commit message (Collapse)AuthorAgeFilesLines
* libsmb: Introduce type-safe struct cli_smb2_create_flagsVolker Lendecke2023-04-181-5/+5
| | | | | | | | | | | | | | | This makes it clearer what to pass into the create_flags argument to cli_smb2_create_fnum(). There was already confusion in source3/torture/test_smb2.c: It passed in SMB2_OPLOCK_LEVEL_NONE (which was okay because it #defines to 0), but it should have been a straight 0, for example SMB2_OPLOCK_LEVEL_EXCLUSIVE would have been wrong. This way adding other flags (.nofollow comes to mind) will be much easier to handle. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3: smbtorture: Add SMB2-DFS-FILENAME-LEADING-BACKSLASH test.Jeremy Allison2023-01-041-0/+190
| | | | | | | | | | | | | | | | Shows that we fail to cope with MacOSX clients that send a (or more than one) leading '\\' character for an SMB2 DFS pathname. I missed this in earlier tests as Windows, Linux, and libsmbclient clients do NOT send a leading backslash for SMB2 DFS paths. Only MacOSX (sigh:-). Passes against Windows. Adds a knownfail for smbd. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15277 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* libsmb: Return symlink error struct from smb2cli_create_recv()Volker Lendecke2022-11-221-346/+564
| | | | | | | | Looks larger than it is, this just adds a parameter and while there adapts long lines to README.Coding Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbtorture3: Add new SMB2-DFS-SHARE-NON-DFS-PATH test.Jeremy Allison2022-09-281-0/+207
| | | | | | | | | | | | | | Uses non-DFS names and DFS-names against a DFS share, shows that Windows looks correctly at the DFS flag when SMB2 requests are made on a DFS share. Passes against Windows 2022. Mark as knownfail for smbd. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed Sep 28 19:34:29 UTC 2022 on sn-devel-184
* s3: torture: Fix test SMB2-DFS-PATHS to pass against Windows server 2022.Jeremy Allison2022-09-281-7/+33
| | | | | | | | | | | There is only one difference between Windows 2022 and Windows 2008. Opening an empty ("") DFS path succeeds in opening the share root on Windows 2008 but fails with NT_STATUS_INVALID_PARAMETER on Windows 2022. Allow the test to cope with both. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* s3: torture: In run_smb2_basic(), replace ↵Jeremy Allison2022-09-151-5/+3
| | | | | | | cli_state_save_tcon()/cli_state_restore_tcon() with cli_state_save_tcon_share()/cli_state_restore_tcon_share(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* s3: smbtorture3: Add a new test SMB2-NON-DFS-SHARE.Jeremy Allison2022-09-141-0/+162
| | | | | | | | | | | | | | | | | This one is tricky. It sends SMB2 DFS pathnames to a non-DFS share, and sets the SMB2 flag FLAGS2_DFS_PATHNAMES in the SMB2 packet. Windows will have non of it and (correctly) treats the pathnames as local paths (they're going to a non-DFS share). Samba fails. This proves the server looks as the share DFS capability to override the flag in the SMB2 packet. Passes against Windows. Added knownfail for Samba. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* s3: torture: Add a comprehensive SMB2 DFS path torture tester.Jeremy Allison2022-08-301-0/+727
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passes fully against Windows. This shows that DFS paths on Windows on SMB2 must be of the form: SERVER\SHARE\PATH but the actual contents of the strings SERVER and SHARE don't need to match the given server or share. The algorithm the Windows server uses is the following: Look for a '\\' character, and assign anything before that to the SERVER component. The characters in this component are not checked for validity. Look for a second '\\' character and assign anything between the first and second '\\' characters to the SHARE component. The characters in the share component are checked for validity, but only ':' is flagged as an illegal sharename character despite what: [MS-FSCC] https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/dc9978d7-6299-4c5a-a22d-a039cdc716ea says. Anything after the second '\\' character is assigned to the PATH component and becomes the share-relative path. If there aren't two '\\' characters it removes everything and ends up with the empty string as the share relative path. To give some examples, the following pathnames all map to the directory at the root of the DFS share: SERVER\SHARE SERVER "" ANY\NAME ANY ::::\NAME the name: SERVER\: is illegal (sharename contains ':') and the name: ANY\NAME\file maps to a share-relative pathname of "file", despite "ANY" not being the server name, and "NAME" not being the DFS share name we are connected to. Adds a knownfail for smbd as our current code in parse_dfs_path() is completely incorrect here and tries to map "incorrect" DFS names into local paths. I will work on fixing this later, but we should be able to remove parse_dfs_path() entirely and move the DFS pathname logic before the call to filename_convert_dirfsp() in the same way Volker suggested and was able to achieve for extract_snapshot_token() and the @GMT pathname processing. Also proves the "target" paths for SMB2_SETINFO rename and hardlink must *not* be DFS-paths. Next I will work on a torture tester for SMB1 DFS paths. Signed-off-by: Jeremy Allison <jra@samba.org> Reivewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Aug 30 17:10:33 UTC 2022 on sn-devel-184
* s3: torture: Add 2 new tests SMB2-DEL-ON-CLOSE-NONWRITE-DELETE-NO, ↵Jeremy Allison2022-03-221-0/+244
| | | | | | | | | | | | | | | | | | | | | | SMB2-DEL-ON-CLOSE-NONWRITE-DELETE-YES. We currently allow setting the delete on close bit for a directory containing only explicitly hidden/vetoed files in the case where "delete veto files = yes" *and* "delete veto files = no". For the "delete veto files = no" case we should be denying setting the delete on close bit when the client tries to set it (that's the only time Windows looks at the bit and returns an error to the user). We already do the in the dangling symlink case, we just missed it in the !is_visible_fsp() case. Mark SMB2-DEL-ON-CLOSE-NONWRITE-DELETE-NO as knownfail for now. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15023 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* s3: smbtorture3: Add test for setting delete on close on a directory, then ↵Jeremy Allison2021-11-041-0/+136
| | | | | | | | | | | | | | creating a file within to see if delete succeeds. Exposes an existing problem where "ret" is overwritten in the directory scan. Add knownfail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14892 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: tests: Add "SMB2-LIST-DIR-ASYNC" test.Jeremy Allison2021-07-151-0/+84
| | | | | | | | | | | Add as knownfail. Shows our "smbd async dosmode" code wasn't working. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14758 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3:torture: replace PROTOCOL_SMB2_22 with PROTOCOL_SMB3_00Stefan Metzmacher2021-07-151-4/+4
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: torture: Add a test for setting and getting ACLs on stream handles ↵Jeremy Allison2021-03-301-0/+207
| | | | | | | | | | | | | | | | | | | | | | | | (SMB2-STREAM-ACL). It shows this isn't done correctly for streams_xattr. A common config is: vfs_objects = streams_xattr acl_xattr to store both streams and Windows ACLs in xattrs. Unfortunately getting and setting ACLs using handles opened on stream files isn't being done correctly in Samba. This test passes against Windows 10. This adds tests that prove this doesn't work. Next patch will add the fix and remove the knownfail. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbtorture3: Ensure we *always* replace the saved saved_tcon even in an ↵Jeremy Allison2021-02-021-1/+1
| | | | | | | | | error condition. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13992 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* torture3: cli_set_security_descriptor() does smb2 as wellVolker Lendecke2020-11-161-3/+3
| | | | | | | Remove a direct caller Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture3: cli_query_security_descriptor() does smb2 as wellVolker Lendecke2020-11-161-10/+4
| | | | | | | Remove a direct caller Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture3: Fix a cut&paste error in a printf messageVolker Lendecke2020-10-021-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture3: Fix a debug messageVolker Lendecke2020-06-041-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture3: Check error code for quotactl on a non-quota file handleVolker Lendecke2020-05-291-0/+67
| | | | | | | 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>
* s3: torture: Add a basic SMB2 SACL test.Jeremy Allison2020-04-211-0/+336
| | | | | | | | | | | | | | | | | | | | | | | | | | | Shows bits needed to set/get a SACL. We need a script within Samba to run this as it depends on a user with SeSecurityPrivilege to work. Test does the following: 1). Create a test file. 2). Open with SEC_FLAG_SYSTEM_SECURITY *only*. ACCESS_DENIED. NB. SMB2-only behavior. SMB1 allows this as tested in SMB1-SYSTEM-SECURITY. 3). Open with SEC_FLAG_SYSTEM_SECURITY|FILE_WRITE_ATTRIBUTES. 4). Write SACL. Should fail with ACCESS_DENIED (seems to need WRITE_DAC). 5). Close (3). 6). Open with SEC_FLAG_SYSTEM_SECURITY|SEC_STD_WRITE_DAC. 7). Write SACL. Success. 8). Close (4). 9). Open with SEC_FLAG_SYSTEM_SECURITY|READ_ATTRIBUTES. 10). Read SACL. Success. 11). Read DACL. Should fail with ACCESS_DENIED (no READ_CONTROL). 12). Close (9). 13 - and on error). Delete test file. Passes against Windows 10. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: torture: Add MS-FSA style terminating '/' and '\\' test - SMB2-PATH-SLASH.Jeremy Allison2019-10-021-0/+205
| | | | | | | | | | | [MS-FSA] 2.1.5.1 Server Requests an Open of a File. Checks how to behave on both files and directories. Tested against Windows 10 server - passes. Currently smbd fails this. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* libsmb: Rename InfoType from [MS-SMB2] according to the specVolker Lendecke2019-04-011-7/+7
| | | | | | | This makes it easier to find this via internet search Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbtorture: Add new SMB2-DIR-FSYNC test to show behavior of FSYNC on ↵Jeremy Allison2018-05-181-0/+270
| | | | | | | | | | | | | | | | | | | | | | directories. Tests against a directory handle on the root of a share, and a directory handle on a sub-directory in a share. Check SEC_DIR_ADD_FILE and SEC_DIR_ADD_SUBDIR separately, either allows flush to succeed. Passes against Windows. Regression test for: BUG: https://bugzilla.samba.org/show_bug.cgi?id=13428 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri May 18 02:38:50 CEST 2018 on sn-devel-144
* s3:torture: add SMB2-ANONYMOUS which asserts no GUEST bit for anonymousStefan Metzmacher2018-03-151-0/+42
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13328 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3:torture: make use of smb_protocol_types_string() in run_smb2_negprot()Stefan Metzmacher2017-06-221-31/+3
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbtorture: Show correct use of cli_state_save_tcon() / ↵Jeremy Allison2017-06-171-3/+5
| | | | | | | | | cli_state_restore_tcon(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12831 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
* s3: torture: Add test for cli_ftruncate calling cli_smb2_ftruncate.Jeremy Allison2017-01-041-0/+157
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12479 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
* s3:libsmb: don't pass 'passlen' to cli_tree_connect[_send]() and allow pass=NULLStefan Metzmacher2016-12-091-9/+9
| | | | | | | | | | There're no callers which try to pass a raw lm_response directly anymore. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Dec 9 13:09:37 CET 2016 on sn-devel-144
* s3:torture: make use of auth_generic_set_creds() in test_smb2.cStefan Metzmacher2016-11-151-65/+10
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:torture: make use of cli_session_setup_creds() in test_smb2.cStefan Metzmacher2016-11-151-15/+6
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:libsmb: let the callers only pass the password string to ↵Stefan Metzmacher2016-11-151-10/+5
| | | | | | | | | cli_session_setup[_send]() There're no callers which tried to pass raw {lm,nt}_response any more. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:torture: handle PROTOCOL_SMB3_11Stefan Metzmacher2015-05-081-0/+3
| | | | Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:torture: add PROTOCOL_SMB3_10 handlingStefan Metzmacher2014-10-071-0/+3
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:libsmb: remove unused smb2cli.hStefan Metzmacher2014-09-301-1/+0
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* libcli/smb: move smb2cli_tcon.c to the toplevelStefan Metzmacher2014-09-301-2/+8
| | | | | | | removing use of cli_state from the code. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:torture: use cli_state_client_guid in run_smb2_multi_channel()Stefan Metzmacher2014-09-191-0/+6
| | | | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Fri Sep 19 11:40:15 CEST 2014 on sn-devel-104
* libcli: Make smb2cli_create return blobsVolker Lendecke2014-06-301-16/+16
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* auth/gensec: remove tevent_context argument from gensec_update()Stefan Metzmacher2014-03-271-10/+20
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s3:torture: add PROTOCOL_SMB3_02 handlingStefan Metzmacher2013-09-171-0/+3
| | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libcli/smb: Change smb2cli_create() and smb2cli_create_recv() to return a ↵Jeremy Allison2013-08-151-16/+32
| | | | | | | | | parameter blob of the newly opened/created file. Will use in the smb2 client code. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* libcli/smb: Fix smb2cli_write_recv() and smb2cli_write() to return the bytes ↵Jeremy Allison2013-08-151-7/+7
| | | | | | | written. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:torture: make use of samba_tevent_context_init()Stefan Metzmacher2013-02-191-6/+6
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* libcli/smb: pass smbXcli_session to smb2cli_tcon_set_values()Stefan Metzmacher2012-07-251-0/+4
| | | | metze
* s3:libsmb: remove unused cli_state->smb2.pidStefan Metzmacher2012-07-251-9/+0
| | | | metze
* s3:libsmb: remove cli_state->smb2.tidStefan Metzmacher2012-07-251-27/+18
| | | | metze
* s3:torture/test_smb2: make a copy of smbXcli_tconStefan Metzmacher2012-07-251-0/+32
| | | | | | | metze Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Jul 25 00:10:47 CEST 2012 on sn-devel-104
* libcli/smb: pass smbXcli_tcon to smb2cli_query_directory*()Stefan Metzmacher2012-07-241-4/+4
| | | | metze
* libcli/smb: pass smbXcli_tcon to smb2cli_query_info*()Stefan Metzmacher2012-07-241-5/+5
| | | | metze
* libcli/smb: pass smbXcli_tcon to smb2cli_set_info*()Stefan Metzmacher2012-07-241-2/+2
| | | | metze
* libcli/smb: pass smbXcli_tcon to smb2cli_flush*()Stefan Metzmacher2012-07-241-18/+18
| | | | metze