diff options
author | Jeremy Allison <jra@samba.org> | 2019-10-17 12:41:08 -0700 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-10-18 16:07:35 +0000 |
commit | 8e55a8562951924e4b1aad5a6d67fc8b309590c1 (patch) | |
tree | 3b10cdf50f0571368e44ef41cd0d4573b1fcbb84 /source3/torture | |
parent | d495074ee27a5f528d5156a69800ee58d799b1eb (diff) | |
download | samba-8e55a8562951924e4b1aad5a6d67fc8b309590c1.tar.gz |
s3: torture: Ensure SMB1 cli_qpathinfo2() doesn't return an inode number.
Piggyback on existing tests, ensure we don't regress on:
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14161
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/torture')
-rw-r--r-- | source3/torture/torture.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 052ff15a2e0..e498c162f11 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -4212,6 +4212,7 @@ static bool run_trans2test(int dummy) bool correct = True; NTSTATUS status; uint32_t fs_attr; + uint64_t ino; printf("starting trans2 test\n"); @@ -4219,6 +4220,14 @@ static bool run_trans2test(int dummy) return False; } + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + /* Ensure ino is zero, SMB2 gets a real one. */ + ino = 0; + } else { + /* Ensure ino is -1, SMB1 never gets a real one. */ + ino = (uint64_t)-1; + } + status = cli_get_fs_attr_info(cli, &fs_attr); if (!NT_STATUS_IS_OK(status)) { printf("ERROR: cli_get_fs_attr_info returned %s\n", @@ -4290,7 +4299,7 @@ static bool run_trans2test(int dummy) O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); cli_close(cli, fnum); status = cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts, - &m_time_ts, &size, NULL, NULL); + &m_time_ts, &size, NULL, &ino); if (!NT_STATUS_IS_OK(status)) { printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status)); correct = False; @@ -4300,6 +4309,19 @@ static bool run_trans2test(int dummy) printf("This system appears to set a initial 0 write time\n"); correct = False; } + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + /* SMB2 should always return an inode. */ + if (ino == 0) { + printf("SMB2 bad inode (0)\n"); + correct = false; + } + } else { + /* SMB1 must always return zero here. */ + if (ino != 0) { + printf("SMB1 bad inode (!0)\n"); + correct = false; + } + } } cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); @@ -12096,11 +12118,20 @@ static bool run_dir_createtime(int dummy) struct timespec create_time1; uint16_t fnum; bool ret = false; + uint64_t ino; if (!torture_open_connection(&cli, 0)) { return false; } + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + /* Ensure ino is zero, SMB2 gets a real one. */ + ino = 0; + } else { + /* Ensure ino is -1, SMB1 never gets a real one. */ + ino = (uint64_t)-1; + } + cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); cli_rmdir(cli, dname); @@ -12111,13 +12142,27 @@ static bool run_dir_createtime(int dummy) } status = cli_qpathinfo2(cli, dname, &create_time, NULL, NULL, NULL, - NULL, NULL, NULL); + NULL, NULL, &ino); if (!NT_STATUS_IS_OK(status)) { printf("cli_qpathinfo2 returned %s\n", nt_errstr(status)); goto out; } + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + /* SMB2 should always return an inode. */ + if (ino == 0) { + printf("SMB2 bad inode (0)\n"); + goto out; + } + } else { + /* SMB1 must always return zero here. */ + if (ino != 0) { + printf("SMB1 bad inode (!0)\n"); + goto out; + } + } + /* Sleep 3 seconds, then create a file. */ sleep(3); |