1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

s4:torture: add a Maximum Access check with an Owner Rights ACE

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13812

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
This commit is contained in:
Ralph Boehme 2019-02-28 14:48:02 +01:00 committed by David Disseldorp
parent 9f4ee05295
commit 3ca38d2cd1
2 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,2 @@
^samba3.smb2.acls.OWNER-RIGHTS\(ad_dc\)
^samba3.smb2.acls.OWNER-RIGHTS\(nt4_dc\)

View File

@ -2363,6 +2363,130 @@ done:
return ret;
}
/*
* test Owner Rights, S-1-3-4
*/
static bool test_owner_rights(struct torture_context *tctx,
struct smb2_tree *tree)
{
const char *fname = BASEDIR "\\owner_right.txt";
struct smb2_create cr;
struct smb2_handle handle = {{0}};
union smb_fileinfo gi;
union smb_setfileinfo si;
struct security_descriptor *sd_orig = NULL;
struct security_descriptor *sd = NULL;
const char *owner_sid = NULL;
NTSTATUS mxac_status;
NTSTATUS status;
bool ret = true;
smb2_deltree(tree, BASEDIR);
ret = smb2_util_setup_dir(tctx, tree, BASEDIR);
torture_assert_goto(tctx, ret, ret, done,
"smb2_util_setup_dir failed\n");
torture_comment(tctx, "TESTING OWNER RIGHTS\n");
cr = (struct smb2_create) {
.in.desired_access = SEC_STD_READ_CONTROL |
SEC_STD_WRITE_DAC |SEC_STD_WRITE_OWNER,
.in.file_attributes = FILE_ATTRIBUTE_NORMAL,
.in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
.in.create_disposition = NTCREATEX_DISP_OPEN_IF,
.in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS,
.in.fname = fname,
};
status = smb2_create(tree, tctx, &cr);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_create failed\n");
handle = cr.out.file.handle;
torture_comment(tctx, "get the original sd\n");
gi = (union smb_fileinfo) {
.query_secdesc.level = RAW_FILEINFO_SEC_DESC,
.query_secdesc.in.file.handle = handle,
.query_secdesc.in.secinfo_flags = SECINFO_DACL|SECINFO_OWNER,
};
status = smb2_getinfo_file(tree, tctx, &gi);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_getinfo_file failed\n");
sd_orig = gi.query_secdesc.out.sd;
owner_sid = dom_sid_string(tctx, sd_orig->owner_sid);
sd = security_descriptor_dacl_create(tctx, 0, NULL, NULL,
owner_sid,
SEC_ACE_TYPE_ACCESS_ALLOWED,
SEC_RIGHTS_FILE_READ,
0,
SID_OWNER_RIGHTS,
SEC_ACE_TYPE_ACCESS_ALLOWED,
SEC_RIGHTS_FILE_READ,
0,
NULL);
torture_assert_not_null_goto(tctx, sd, ret, done,
"SD create failed\n");
si = (union smb_setfileinfo) {
.set_secdesc.level = RAW_SFILEINFO_SEC_DESC,
.set_secdesc.in.file.handle = handle,
.set_secdesc.in.secinfo_flags = SECINFO_DACL,
.set_secdesc.in.sd = sd,
};
status = smb2_setinfo_file(tree, &si);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_setinfo_file failed\n");
status = smb2_util_close(tree, handle);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_util_close failed\n");
ZERO_STRUCT(handle);
cr = (struct smb2_create) {
.in.desired_access = SEC_STD_READ_CONTROL,
.in.file_attributes = FILE_ATTRIBUTE_NORMAL,
.in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
.in.create_disposition = NTCREATEX_DISP_OPEN_IF,
.in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS,
.in.query_maximal_access = true,
.in.fname = fname,
};
status = smb2_create(tree, tctx, &cr);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_setinfo_file failed\n");
handle = cr.out.file.handle;
mxac_status = NT_STATUS(cr.out.maximal_access_status);
torture_assert_ntstatus_ok_goto(tctx, mxac_status, ret, done,
"smb2_setinfo_file failed\n");
/* SEC_STD_DELETE comes from the parent directory */
torture_assert_int_equal_goto(tctx,
cr.out.maximal_access,
SEC_RIGHTS_FILE_READ|SEC_STD_DELETE,
ret, done,
"Wrong maximum access\n");
status = smb2_util_close(tree, handle);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_util_close failed\n");
ZERO_STRUCT(handle);
done:
if (!smb2_util_handle_empty(handle)) {
smb2_util_close(tree, handle);
}
smb2_deltree(tree, BASEDIR);
return ret;
}
/*
basic testing of SMB2 ACLs
*/
@ -2382,6 +2506,7 @@ struct torture_suite *torture_smb2_acls_init(TALLOC_CTX *ctx)
torture_suite_add_1smb2_test(suite, "GETSET", test_sd_get_set);
#endif
torture_suite_add_1smb2_test(suite, "ACCESSBASED", test_access_based);
torture_suite_add_1smb2_test(suite, "OWNER-RIGHTS", test_owner_rights);
suite->description = talloc_strdup(suite, "SMB2-ACLS tests");