|
|
1bb595 |
From a7c755672cd277497da3df4714f6d9457b6ac5ae Mon Sep 17 00:00:00 2001
|
|
|
1bb595 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
1bb595 |
Date: Thu, 28 May 2020 15:02:43 +0200
|
|
|
1bb595 |
Subject: [PATCH] ad_gpo_ndr.c: more ndr updates
|
|
|
1bb595 |
MIME-Version: 1.0
|
|
|
1bb595 |
Content-Type: text/plain; charset=UTF-8
|
|
|
1bb595 |
Content-Transfer-Encoding: 8bit
|
|
|
1bb595 |
|
|
|
1bb595 |
This patch add another update to the ndr code which was previously
|
|
|
1bb595 |
updated by commit c031adde4f532f39845a0efd78693600f1f8b2f4 and
|
|
|
1bb595 |
1fdd8fa2fded1985fbfc6aa67394eebcdbb6a2fc.
|
|
|
1bb595 |
|
|
|
1bb595 |
As missing update in ndr_pull_security_ace() cased
|
|
|
1bb595 |
a failure in ad_gpo_parse_sd(). A unit-test for ad_gpo_parse_sd() was
|
|
|
1bb595 |
added to prevent similar issues in future.
|
|
|
1bb595 |
|
|
|
1bb595 |
Resolves: https://github.com/SSSD/sssd/issues/5183
|
|
|
1bb595 |
|
|
|
1bb595 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
1bb595 |
---
|
|
|
1bb595 |
src/providers/ad/ad_gpo_ndr.c | 1 +
|
|
|
1bb595 |
src/tests/cmocka/test_ad_gpo.c | 57 ++++++++++++++++++++++++++++++++++
|
|
|
1bb595 |
2 files changed, 58 insertions(+)
|
|
|
1bb595 |
|
|
|
1bb595 |
diff --git a/src/providers/ad/ad_gpo_ndr.c b/src/providers/ad/ad_gpo_ndr.c
|
|
|
1bb595 |
index acd7b77c8..71d6d40f2 100644
|
|
|
1bb595 |
--- a/src/providers/ad/ad_gpo_ndr.c
|
|
|
1bb595 |
+++ b/src/providers/ad/ad_gpo_ndr.c
|
|
|
1bb595 |
@@ -317,6 +317,7 @@ ndr_pull_security_ace(struct ndr_pull *ndr,
|
|
|
1bb595 |
ndr->offset += pad;
|
|
|
1bb595 |
}
|
|
|
1bb595 |
if (ndr_flags & NDR_BUFFERS) {
|
|
|
1bb595 |
+ NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->object, r->type));
|
|
|
1bb595 |
NDR_CHECK(ndr_pull_security_ace_object_ctr
|
|
|
1bb595 |
(ndr, NDR_BUFFERS, &r->object));
|
|
|
1bb595 |
}
|
|
|
1bb595 |
diff --git a/src/tests/cmocka/test_ad_gpo.c b/src/tests/cmocka/test_ad_gpo.c
|
|
|
1bb595 |
index 97f70408a..d1f7a6915 100644
|
|
|
1bb595 |
--- a/src/tests/cmocka/test_ad_gpo.c
|
|
|
1bb595 |
+++ b/src/tests/cmocka/test_ad_gpo.c
|
|
|
1bb595 |
@@ -347,6 +347,60 @@ void test_ad_gpo_ace_includes_host_sid_true(void **state)
|
|
|
1bb595 |
group_size, ace_dom_sid, true);
|
|
|
1bb595 |
}
|
|
|
1bb595 |
|
|
|
1bb595 |
+uint8_t test_sid_data[] = {
|
|
|
1bb595 |
+0x01, 0x00, 0x04, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
1bb595 |
+0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x34, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00,
|
|
|
1bb595 |
+0xbd, 0x00, 0x0e, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00,
|
|
|
1bb595 |
+0xda, 0x0e, 0xba, 0x60, 0x0f, 0xa2, 0xf4, 0x55, 0xb5, 0x57, 0x47, 0xf8, 0x00, 0x02, 0x00, 0x00,
|
|
|
1bb595 |
+0x00, 0x0a, 0x24, 0x00, 0xff, 0x00, 0x0f, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
|
|
|
1bb595 |
+0x15, 0x00, 0x00, 0x00, 0xda, 0x0e, 0xba, 0x60, 0x0f, 0xa2, 0xf4, 0x55, 0xb5, 0x57, 0x47, 0xf8,
|
|
|
1bb595 |
+0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0xbd, 0x00, 0x0e, 0x00, 0x01, 0x05, 0x00, 0x00,
|
|
|
1bb595 |
+0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0xda, 0x0e, 0xba, 0x60, 0x0f, 0xa2, 0xf4, 0x55,
|
|
|
1bb595 |
+0xb5, 0x57, 0x47, 0xf8, 0x07, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x24, 0x00, 0xff, 0x00, 0x0f, 0x00,
|
|
|
1bb595 |
+0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0xda, 0x0e, 0xba, 0x60,
|
|
|
1bb595 |
+0x0f, 0xa2, 0xf4, 0x55, 0xb5, 0x57, 0x47, 0xf8, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00,
|
|
|
1bb595 |
+0xbd, 0x00, 0x0e, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00,
|
|
|
1bb595 |
+0xda, 0x0e, 0xba, 0x60, 0x0f, 0xa2, 0xf4, 0x55, 0xb5, 0x57, 0x47, 0xf8, 0x00, 0x02, 0x00, 0x00,
|
|
|
1bb595 |
+0x00, 0x0a, 0x14, 0x00, 0xff, 0x00, 0x0f, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
|
|
|
1bb595 |
+0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x00, 0xff, 0x00, 0x0f, 0x00, 0x01, 0x01, 0x00, 0x00,
|
|
|
1bb595 |
+0x00, 0x00, 0x00, 0x05, 0x12, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x00, 0x94, 0x00, 0x02, 0x00,
|
|
|
1bb595 |
+0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x02, 0x28, 0x00,
|
|
|
1bb595 |
+0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x8f, 0xfd, 0xac, 0xed, 0xb3, 0xff, 0xd1, 0x11,
|
|
|
1bb595 |
+0xb4, 0x1d, 0x00, 0xa0, 0xc9, 0x68, 0xf9, 0x39, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
|
|
|
1bb595 |
+0x0b, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x00, 0x94, 0x00, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00,
|
|
|
1bb595 |
+0x00, 0x00, 0x00, 0x05, 0x09, 0x00, 0x00, 0x00
|
|
|
1bb595 |
+};
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+void test_ad_gpo_parse_sd(void **state)
|
|
|
1bb595 |
+{
|
|
|
1bb595 |
+ int ret;
|
|
|
1bb595 |
+ struct security_descriptor *sd = NULL;
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ ret = ad_gpo_parse_sd(test_ctx, NULL, 0, &sd);
|
|
|
1bb595 |
+ assert_int_equal(ret, EINVAL);
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ ret = ad_gpo_parse_sd(test_ctx, test_sid_data, sizeof(test_sid_data), &sd);
|
|
|
1bb595 |
+ assert_int_equal(ret, EOK);
|
|
|
1bb595 |
+ assert_non_null(sd);
|
|
|
1bb595 |
+ assert_int_equal(sd->revision, 1);
|
|
|
1bb595 |
+ assert_int_equal(sd->type, 39940);
|
|
|
1bb595 |
+ assert_null(sd->owner_sid);
|
|
|
1bb595 |
+ assert_null(sd->group_sid);
|
|
|
1bb595 |
+ assert_null(sd->sacl);
|
|
|
1bb595 |
+ assert_non_null(sd->dacl);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->revision, 4);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->size, 308);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->num_aces, 10);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->aces[0].type, 0);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->aces[0].flags, 0);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->aces[0].size, 36);
|
|
|
1bb595 |
+ assert_int_equal(sd->dacl->aces[0].access_mask, 917693);
|
|
|
1bb595 |
+ /* There are more components and ACEs in the security_descriptor struct
|
|
|
1bb595 |
+ * which are not checked here. */
|
|
|
1bb595 |
+
|
|
|
1bb595 |
+ talloc_free(sd);
|
|
|
1bb595 |
+}
|
|
|
1bb595 |
+
|
|
|
1bb595 |
int main(int argc, const char *argv[])
|
|
|
1bb595 |
{
|
|
|
1bb595 |
poptContext pc;
|
|
|
1bb595 |
@@ -385,6 +439,9 @@ int main(int argc, const char *argv[])
|
|
|
1bb595 |
cmocka_unit_test_setup_teardown(test_ad_gpo_ace_includes_host_sid_true,
|
|
|
1bb595 |
ad_gpo_test_setup,
|
|
|
1bb595 |
ad_gpo_test_teardown),
|
|
|
1bb595 |
+ cmocka_unit_test_setup_teardown(test_ad_gpo_parse_sd,
|
|
|
1bb595 |
+ ad_gpo_test_setup,
|
|
|
1bb595 |
+ ad_gpo_test_teardown),
|
|
|
1bb595 |
};
|
|
|
1bb595 |
|
|
|
1bb595 |
/* Set debug level to invalid value so we can decide if -d 0 was used. */
|
|
|
1bb595 |
--
|
|
|
1bb595 |
2.21.1
|
|
|
1bb595 |
|