1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

smbtorture: Directory Leases vs setting inode change date

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Ralph Boehme 2024-09-09 10:37:19 +02:00
parent b277c32dc1
commit 28e8aae6ad

View File

@ -5850,6 +5850,7 @@ enum dirlease_test {
DLT_SETDOS,
DLT_BTIME,
DLT_MTIME,
DLT_CTIME,
};
static void prepare_setinfo(enum dirlease_test t,
@ -5874,6 +5875,9 @@ static void prepare_setinfo(enum dirlease_test t,
case DLT_MTIME:
s->basic_info.in.write_time++;
break;
case DLT_CTIME:
s->basic_info.in.change_time++;
break;
default:
break;
}
@ -6260,6 +6264,58 @@ done:
return ret;
}
/*
* TEST: Test setting inode change date
*/
static bool test_dirlease_setctime(struct torture_context *tctx,
struct smb2_tree *tree,
struct smb2_tree *tree2)
{
TALLOC_CTX *mem_ctx = talloc_new(tctx);
struct smb2_create c;
struct smb2_lease dirlease;
struct smb2_handle dirh = {};
const char *dname = "test_dirlease_setctime_dir";
const char *dnamefname = "test_dirlease_setctime_dir\\lease.dat";
union smb_setfileinfo sfinfo = {};
NTSTATUS status;
bool ret = true;
smb2_deltree(tree, dname);
tree->session->transport->lease.handler = torture_lease_handler;
tree->session->transport->lease.private_data = tree;
torture_reset_lease_break_info(tctx, &lease_break_info);
/* Get an RH directory lease on the test directory */
smb2_lease_v2_create_share(&c, &dirlease, true, dname,
smb2_util_share_access("RWD"),
LEASE1, NULL,
smb2_util_lease_state("RHW"), 0);
status = smb2_create(tree, mem_ctx, &c);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_create failed\n");
dirh = c.out.file.handle;
CHECK_LEASE_V2(&c, "RH", true, LEASE1, 0, 0, ++dirlease.lease_epoch);
sfinfo.generic.level = RAW_SFILEINFO_BASIC_INFORMATION;
unix_to_nt_time(&sfinfo.basic_info.in.change_time, time(NULL) + 9*30*24*60*60);
ret = test_dirlease_setinfo(tctx, mem_ctx, DLT_CTIME, tree, tree2,
dname, dnamefname,
&dirh, &dirlease, &sfinfo);
torture_assert_goto(tctx, ret, ret, done, "setctime test failed\n");
done:
if (!smb2_util_handle_empty(dirh)) {
smb2_util_close(tree, dirh);
}
smb2_deltree(tree, dname);
talloc_free(mem_ctx);
return ret;
}
struct torture_suite *torture_smb2_dirlease_init(TALLOC_CTX *ctx)
{
struct torture_suite *suite =
@ -6274,5 +6330,6 @@ struct torture_suite *torture_smb2_dirlease_init(TALLOC_CTX *ctx)
torture_suite_add_2smb2_test(suite, "setdos", test_dirlease_setdos);
torture_suite_add_2smb2_test(suite, "setbtime", test_dirlease_setbtime);
torture_suite_add_2smb2_test(suite, "setmtime", test_dirlease_setmtime);
torture_suite_add_2smb2_test(suite, "setctime", test_dirlease_setctime);
return suite;
}