return ret;
}
+static bool torture_smb2_read_only_file(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ struct smb2_create c;
+ struct smb2_handle h = {{0}};
+ bool ret = true;
+ NTSTATUS status;
+
+ smb2_deltree(tree, MAXIMUM_ALLOWED_FILE);
+
+ c = (struct smb2_create) {
+ .in.desired_access = SEC_RIGHTS_FILE_ALL,
+ .in.file_attributes = FILE_ATTRIBUTE_READONLY,
+ .in.create_disposition = NTCREATEX_DISP_CREATE,
+ .in.fname = MAXIMUM_ALLOWED_FILE,
+ };
+
+ status = smb2_create(tree, tctx, &c);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+ h = c.out.file.handle;
+ smb2_util_close(tree, h);
+ ZERO_STRUCT(h);
+
+ c = (struct smb2_create) {
+ .in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED,
+ .in.file_attributes = FILE_ATTRIBUTE_READONLY,
+ .in.create_disposition = NTCREATEX_DISP_OPEN,
+ .in.fname = MAXIMUM_ALLOWED_FILE,
+ };
+
+ status = smb2_create(tree, tctx, &c);
+ torture_assert_ntstatus_ok_goto(
+ tctx, status, ret, done,
+ "Failed to open READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED\n");
+ h = c.out.file.handle;
+ smb2_util_close(tree, h);
+ ZERO_STRUCT(h);
+
+done:
+ if (!smb2_util_handle_empty(h)) {
+ smb2_util_close(tree, h);
+ }
+ smb2_deltree(tree, MAXIMUM_ALLOWED_FILE);
+ return ret;
+}
+
struct torture_suite *torture_smb2_max_allowed(TALLOC_CTX *ctx)
{
struct torture_suite *suite = torture_suite_create(ctx, "maximum_allowed");
torture_suite_add_1smb2_test(suite, "maximum_allowed", torture_smb2_maximum_allowed);
+ torture_suite_add_1smb2_test(suite, "read_only", torture_smb2_read_only_file);
return suite;
}