1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

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>
(cherry picked from commit 8e55a8562951924e4b1aad5a6d67fc8b309590c1)
This commit is contained in:
Jeremy Allison 2019-10-17 12:41:08 -07:00 committed by Karolin Seeger
parent f48393e1bd
commit d92fa942a2

View File

@ -3390,6 +3390,7 @@ static bool run_trans2test(int dummy)
bool correct = True;
NTSTATUS status;
uint32_t fs_attr;
uint64_t ino;
printf("starting trans2 test\n");
@ -3397,6 +3398,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",
@ -3468,7 +3477,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;
@ -3478,6 +3487,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);
@ -9970,11 +9992,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);
@ -9985,13 +10016,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);