diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index f0ee25b174dba27fb4bd937fddb92423952d891c..633389bbd02ecad12ade55a829e330a7afe6638e 100644 --- a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp +++ b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp @@ -30,17 +30,9 @@ namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompEnhanceAdapter"}; -#if defined(__LP64__) -static const std::string LIB_PATH = "/system/lib64/"; -#else -static const std::string LIB_PATH = "/system/lib/"; -#endif -static const std::string INNER_PATH = "platformsdk/"; -static const std::string ENHANCE_INPUT_INTERFACE_LIB = - LIB_PATH + INNER_PATH + "libsecurity_component_client_enhance.z.so"; -static const std::string ENHANCE_SRV_INTERFACE_LIB = LIB_PATH + "libsecurity_component_service_enhance.z.so"; -static const std::string ENHANCE_CLIENT_INTERFACE_LIB = - LIB_PATH + INNER_PATH + "libsecurity_component_client_enhance.z.so"; +static const std::string ENHANCE_INPUT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so"; +static const std::string ENHANCE_SRV_INTERFACE_LIB = "libsecurity_component_service_enhance.z.so"; +static const std::string ENHANCE_CLIENT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so"; } SecCompInputEnhanceInterface* SecCompEnhanceAdapter::inputHandler = nullptr; diff --git a/interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp b/interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp index b2987cebc63a2349cc7eb43c8ed416eae847e8a2..b0d70fc6c00f00082e1ffc79367f19c3a689b188 100644 --- a/interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp +++ b/interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ #include "sec_comp_enhance_test.h" +#include #include #include "sec_comp_err.h" #include "sec_comp_log.h" @@ -27,27 +28,24 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { static bool g_inputEnhanceExist = false; static bool g_srvEnhanceExist = false; static constexpr uint32_t SEC_COMP_ENHANCE_CFG_SIZE = 76; -#if defined(__LP64__) -static const std::string LIB_PATH = "/system/lib64/"; -#else -static const std::string LIB_PATH = "/system/lib/"; -#endif -static const std::string INNER_PATH = "platformsdk/"; -static const std::string ENHANCE_INPUT_INTERFACE_LIB = - LIB_PATH + INNER_PATH + "libsecurity_component_client_enhance.z.so"; -static const std::string ENHANCE_SRV_INTERFACE_LIB = LIB_PATH + "libsecurity_component_service_enhance.z.so"; +static const std::string ENHANCE_INPUT_INTERFACE_LIB = "libsecurity_component_client_enhance.z.so"; +static const std::string ENHANCE_SRV_INTERFACE_LIB = "libsecurity_component_service_enhance.z.so"; static constexpr uint32_t MAX_HMAC_SIZE = 64; } // namespace void SecCompEnhanceTest::SetUpTestCase() { - if (access(ENHANCE_INPUT_INTERFACE_LIB.c_str(), F_OK) == 0) { + void *handle = dlopen(ENHANCE_INPUT_INTERFACE_LIB.c_str(), RTLD_LAZY); + if (handle != nullptr) { g_inputEnhanceExist = true; } + dlclose(handle); - if (access(ENHANCE_SRV_INTERFACE_LIB.c_str(), F_OK) == 0) { + handle = dlopen(ENHANCE_SRV_INTERFACE_LIB.c_str(), RTLD_LAZY); + if (handle != nullptr) { g_srvEnhanceExist = true; } + dlclose(handle); system("kill -9 `pidof security_component_service`"); SC_LOG_INFO(LABEL, "SetUpTestCase."); }