1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

smbtorture: Directory Leases vs setting creation date

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Ralph Boehme 2024-10-18 12:56:31 +02:00
parent aa50c19e6b
commit 1150efd21c

View File

@ -5848,6 +5848,7 @@ struct torture_suite *torture_smb2_lease_init(TALLOC_CTX *ctx)
enum dirlease_test { enum dirlease_test {
DLT_SETEOF, DLT_SETEOF,
DLT_SETDOS, DLT_SETDOS,
DLT_BTIME,
}; };
static void prepare_setinfo(enum dirlease_test t, static void prepare_setinfo(enum dirlease_test t,
@ -5866,6 +5867,11 @@ static void prepare_setinfo(enum dirlease_test t,
s->basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL; s->basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL;
} }
break; break;
case DLT_BTIME:
s->basic_info.in.create_time++;
break;
default:
break;
} }
} }
@ -6146,6 +6152,58 @@ done:
return ret; return ret;
} }
/*
* TEST: Test setting creation date
*/
static bool test_dirlease_setbtime(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_setbtime_dir";
const char *dnamefname = "test_dirlease_setbtime_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.create_time, time(NULL) + 9*30*24*60*60);
ret = test_dirlease_setinfo(tctx, mem_ctx, DLT_BTIME, tree, tree2,
dname, dnamefname,
&dirh, &dirlease, &sfinfo);
torture_assert_goto(tctx, ret, ret, done, "setbtime 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 *torture_smb2_dirlease_init(TALLOC_CTX *ctx)
{ {
struct torture_suite *suite = struct torture_suite *suite =
@ -6158,5 +6216,6 @@ struct torture_suite *torture_smb2_dirlease_init(TALLOC_CTX *ctx)
torture_suite_add_1smb2_test(suite, "leases", test_dirlease_leases); torture_suite_add_1smb2_test(suite, "leases", test_dirlease_leases);
torture_suite_add_2smb2_test(suite, "seteof", test_dirlease_seteof); torture_suite_add_2smb2_test(suite, "seteof", test_dirlease_seteof);
torture_suite_add_2smb2_test(suite, "setdos", test_dirlease_setdos); torture_suite_add_2smb2_test(suite, "setdos", test_dirlease_setdos);
torture_suite_add_2smb2_test(suite, "setbtime", test_dirlease_setbtime);
return suite; return suite;
} }