From 6ffdb8c48ac479a9f4090d73d289479fb96c6b1a Mon Sep 17 00:00:00 2001 From: huyx Date: Tue, 2 Jul 2024 20:50:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=84=E8=93=9D=E4=BB=A3=E7=A0=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- adapter/uhdf2/ipc/BUILD.gn | 4 ++++ adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp | 2 ++ adapter/uhdf2/test/unittest/manager/BUILD.gn | 3 +++ bundle.json | 2 +- .../manager/test/unittest/common/hdf_remote_adapter_test.cpp | 4 ++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/adapter/uhdf2/ipc/BUILD.gn b/adapter/uhdf2/ipc/BUILD.gn index f88c06bed..fdb4e4c76 100644 --- a/adapter/uhdf2/ipc/BUILD.gn +++ b/adapter/uhdf2/ipc/BUILD.gn @@ -63,6 +63,10 @@ if (defined(ohos_lite)) { ] } + if (build_selinux) { + cflags = [ "-DWITH_SELINUX" ] + } + innerapi_tags = [ "chipsetsdk", "platformsdk_indirect", diff --git a/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp b/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp index 984af37b2..1c9765383 100644 --- a/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp +++ b/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp @@ -318,9 +318,11 @@ int HdfRemoteAdapterAddSa(int32_t saId, struct HdfRemoteService *service) OHOS::HdfXCollie hdfXCollie("HdfRemoteAdapterAddSa_" + OHOS::ToString(saId) + "_add_sa", OHOS::HdfXCollie::DEFAULT_TIMEOUT_SECONDS, nullptr, nullptr, OHOS::HdfXCollie::HDF_XCOLLIE_FLAG_RECOVERY); struct HdfRemoteServiceHolder *holder = reinterpret_cast(service); +#ifdef WITH_SELINUX OHOS::sptr remote = holder->remote_; OHOS::IPCObjectStub *stub = reinterpret_cast(remote.GetRefPtr()); stub->SetRequestSidFlag(true); +#endif int ret = saManager->AddSystemAbility(saId, holder->remote_); (void)OHOS::IPCSkeleton::GetInstance().SetMaxWorkThreadNum(g_remoteThreadMax++); HDF_LOGI("add sa %{public}d, ret = %{public}s", saId, (ret == 0) ? "succ" : "fail"); diff --git a/adapter/uhdf2/test/unittest/manager/BUILD.gn b/adapter/uhdf2/test/unittest/manager/BUILD.gn index 9f1199328..1e5b77551 100644 --- a/adapter/uhdf2/test/unittest/manager/BUILD.gn +++ b/adapter/uhdf2/test/unittest/manager/BUILD.gn @@ -159,6 +159,9 @@ ohos_unittest("hdf_adapter_uhdf_test_remote_adapter") { } else { external_deps = [ "hilog:libhilog" ] } + if (build_selinux) { + cflags = [ "-DWITH_SELINUX" ] + } } module_output_path = "hdf_core/shared" ohos_unittest("hdf_adapter_uhdf_test_core_shared") { diff --git a/bundle.json b/bundle.json index 23e5c54e3..f8ef5f16e 100644 --- a/bundle.json +++ b/bundle.json @@ -58,7 +58,7 @@ "ipc/hdf_dump_reg.h", "ipc/hdf_remote_service.h", "ipc/hdf_sbuf_ipc.h", - "ipc/iproxy_broker.h", + "ipc/iproxy_broker.h", "core/hdf_object.h" ], "header_base": "//drivers/hdf_core/interfaces/inner_api" diff --git a/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp b/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp index 1521456b3..f744bdc60 100644 --- a/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp +++ b/framework/core/manager/test/unittest/common/hdf_remote_adapter_test.cpp @@ -104,6 +104,10 @@ HWTEST_F(HdfRemoteAdapterTest, HdfRemoteAdapterTest004, TestSize.Level1) ASSERT_TRUE(ret > 0); ret = HdfRemoteGetCallingUid(); ASSERT_TRUE(ret >= 0); +#ifdef WITH_SELINUX + char *callingSid = HdfRemoteGetCallingSid(); + ASSERT_TRUE(callingSid != nullptr); +#endif } /* -- Gitee