From 4fa34c0cd0171d5d326ea1b8de499a0edda6521f Mon Sep 17 00:00:00 2001 From: cuiruibin Date: Sun, 20 Apr 2025 14:56:58 +0800 Subject: [PATCH 1/2] test Signed-off-by: cuiruibin --- test/unittest/remote_file_share/remote_file_share_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unittest/remote_file_share/remote_file_share_test.cpp b/test/unittest/remote_file_share/remote_file_share_test.cpp index 5df49b322..14765126d 100644 --- a/test/unittest/remote_file_share/remote_file_share_test.cpp +++ b/test/unittest/remote_file_share/remote_file_share_test.cpp @@ -167,6 +167,7 @@ namespace { string errPthreadName = "../test"; ret = pthread_setname_np(pthread_self(), errPthreadName.c_str()); EXPECT_EQ(ret, E_OK); + ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); close(fd); EXPECT_NE(ret, E_OK); -- Gitee From 3a8f8cd80e1f341737e2d299d9d9ecc4f9aaf797 Mon Sep 17 00:00:00 2001 From: cuiruibin Date: Wed, 23 Apr 2025 11:55:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=85=A5=E5=8F=82=E6=A0=A1=E9=AA=8C=E5=8A=A0?= =?UTF-8?q?=E5=9B=BA=20Signed-off-by:=20cuiruibin=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/common/src/common_func.cpp | 16 ++++++++++++++++ interfaces/innerkits/native/BUILD.gn | 1 + interfaces/kits/js/BUILD.gn | 1 + .../remote_file_share/remote_file_share_test.cpp | 1 - 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/interfaces/common/src/common_func.cpp b/interfaces/common/src/common_func.cpp index 8850178f6..7e23139f1 100644 --- a/interfaces/common/src/common_func.cpp +++ b/interfaces/common/src/common_func.cpp @@ -19,6 +19,7 @@ #include #include +#include "accesstoken_kit.h" #include "bundle_mgr_client.h" #include "bundle_mgr_proxy.h" #include "ipc_skeleton.h" @@ -76,8 +77,23 @@ bool CommonFunc::GetDirByBundleNameAndAppIndex(const std::string &bundleName, in return true; } +static bool IsSAProcesses() +{ + uint32_t selfToken = IPCSkeleton::GetSelfTokenID(); + auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(selfToken); + if (tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE) { + LOGE("The Current Invoking Process Is An SA Process"); + return true; + } + return false; +} + string CommonFunc::GetSelfBundleName() { + if (IsSAProcesses()) { + LOGE("The Current Invoking Process Is An SA Process"); + return ""; + } sptr bundleMgrProxy = GetBundleMgrProxy(); if (!bundleMgrProxy) { LOGE("GetSelfBundleName: bundle mgr proxy is nullptr."); diff --git a/interfaces/innerkits/native/BUILD.gn b/interfaces/innerkits/native/BUILD.gn index 08a8d8cb3..68096b93f 100644 --- a/interfaces/innerkits/native/BUILD.gn +++ b/interfaces/innerkits/native/BUILD.gn @@ -103,6 +103,7 @@ ohos_shared_library("fileuri_native") { external_deps = [ "ability_base:zuri", + "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 3a96c145c..101464af5 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -107,6 +107,7 @@ ohos_shared_library("fileuri") { external_deps = [ "ability_base:zuri", "ability_runtime:abilitykit_native", + "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", diff --git a/test/unittest/remote_file_share/remote_file_share_test.cpp b/test/unittest/remote_file_share/remote_file_share_test.cpp index 14765126d..5df49b322 100644 --- a/test/unittest/remote_file_share/remote_file_share_test.cpp +++ b/test/unittest/remote_file_share/remote_file_share_test.cpp @@ -167,7 +167,6 @@ namespace { string errPthreadName = "../test"; ret = pthread_setname_np(pthread_self(), errPthreadName.c_str()); EXPECT_EQ(ret, E_OK); - ret = RemoteFileShare::CreateSharePath(fd, sharePath, userId, deviceId); close(fd); EXPECT_NE(ret, E_OK); -- Gitee