Projects
Eulaceura:Factory
hiviewdfx_hisysevent
_service:obs_scm:0002-remove-dependency-and-ada...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0002-remove-dependency-and-adapt-for-openeuler-dsoftbus.patch of Package hiviewdfx_hisysevent
From ad68a9dc1f289fb63cc4b10613f3bd46b546c225 Mon Sep 17 00:00:00 2001 From: heppen <hepeng68@huawei.com> Date: Tue, 20 Jun 2023 17:01:51 +0800 Subject: [PATCH] remove dependency and adapt for openeuler --- adapter/BUILD.gn | 2 +- .../common/bus_center/bus_center_adapter.gni | 4 +- .../common/dfx/softbus_adapter_hisysevent.cpp | 263 +++++++++--------- bundle.json | 4 +- .../bus_center/src/bus_center_adapter.c | 2 +- core/authentication/include/auth_hichain.h | 2 + core/authentication/src/auth_hichain.c | 8 +- core/authentication/src/auth_session_fsm.c | 8 + .../lane_manager/src/lnn_lane_link_proc.c | 2 +- .../lane_manager/src/lnn_select_rule.c | 2 +- .../standard/softbus_permission.cpp | 151 +++++----- .../common/src/softbus_thread_pool.c | 3 +- core/frame/BUILD.gn | 6 +- .../src/permission_status_change_cb.cpp | 18 +- .../src/softbus_client_info_manager.cpp | 9 +- .../standard/init/src/softbus_server_stub.cpp | 137 ++++----- 16 files changed, 325 insertions(+), 296 deletions(-) diff --git a/adapter/BUILD.gn b/adapter/BUILD.gn index 20f4e606d..2b7fa0fb8 100644 --- a/adapter/BUILD.gn +++ b/adapter/BUILD.gn @@ -206,7 +206,7 @@ if (defined(ohos_lite)) { public_configs = [ ":config_adapter_common" ] if (is_standard_system) { external_deps = [ - "hisysevent_native:libhisysevent", + # "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", ] } diff --git a/adapter/common/bus_center/bus_center_adapter.gni b/adapter/common/bus_center/bus_center_adapter.gni index ebd12a0f3..6c8887d8b 100644 --- a/adapter/common/bus_center/bus_center_adapter.gni +++ b/adapter/common/bus_center/bus_center_adapter.gni @@ -87,8 +87,8 @@ if (defined(ohos_lite)) { if (has_ces_part) { bus_center_adapter_src += [ "$adapter_bus_center_path/common_event/lnn_common_event_monitor.cpp" ] - bus_center_adapter_external_deps += - [ "common_event_service:cesfwk_innerkits" ] + # bus_center_adapter_external_deps += + # [ "common_event_service:cesfwk_innerkits" ] } else { bus_center_adapter_src += [ "$adapter_bus_center_path/common_event/lnn_common_event_monitor_virtual.cpp" ] } diff --git a/adapter/common/dfx/softbus_adapter_hisysevent.cpp b/adapter/common/dfx/softbus_adapter_hisysevent.cpp index 1c6d36352..d04490317 100644 --- a/adapter/common/dfx/softbus_adapter_hisysevent.cpp +++ b/adapter/common/dfx/softbus_adapter_hisysevent.cpp @@ -23,127 +23,127 @@ #include "softbus_adapter_mem.h" #include "softbus_adapter_thread.h" #include "message_handler.h" -#include "hisysevent_c.h" +// #include "hisysevent_c.h" -static const char *g_domain = "DSOFTBUS"; -static bool g_init_lock = false; -static SoftBusMutex g_dfx_lock; -static HiSysEventParam g_dstParam[SOFTBUS_EVT_PARAM_BUTT]; +// static const char *g_domain = "DSOFTBUS"; +// static bool g_init_lock = false; +// static SoftBusMutex g_dfx_lock; +// static HiSysEventParam g_dstParam[SOFTBUS_EVT_PARAM_BUTT]; -static int32_t ConvertEventParam(SoftBusEvtParam *srcParam, HiSysEventParam *dstParam) -{ - switch (srcParam->paramType) { - case SOFTBUS_EVT_PARAMTYPE_BOOL: - dstParam->t = HISYSEVENT_BOOL; - dstParam->v.b = srcParam->paramValue.b; - break; - case SOFTBUS_EVT_PARAMTYPE_UINT8: - dstParam->t = HISYSEVENT_UINT8; - dstParam->v.ui8 = srcParam->paramValue.u8v; - break; - case SOFTBUS_EVT_PARAMTYPE_UINT16: - dstParam->t = HISYSEVENT_UINT16; - dstParam->v.ui16 = srcParam->paramValue.u16v; - break; - case SOFTBUS_EVT_PARAMTYPE_INT32: - dstParam->t = HISYSEVENT_INT32; - dstParam->v.i32 = srcParam->paramValue.i32v; - break; - case SOFTBUS_EVT_PARAMTYPE_UINT32: - dstParam->t = HISYSEVENT_UINT32; - dstParam->v.ui32 = srcParam->paramValue.u32v; - break; - case SOFTBUS_EVT_PARAMTYPE_UINT64: - dstParam->t = HISYSEVENT_UINT64; - dstParam->v.ui64 = srcParam->paramValue.u64v; - break; - case SOFTBUS_EVT_PARAMTYPE_FLOAT: - dstParam->t = HISYSEVENT_FLOAT; - dstParam->v.f = srcParam->paramValue.f; - break; - case SOFTBUS_EVT_PARAMTYPE_DOUBLE: - dstParam->t = HISYSEVENT_DOUBLE; - dstParam->v.d = srcParam->paramValue.d; - break; - case SOFTBUS_EVT_PARAMTYPE_STRING: - dstParam->t = HISYSEVENT_STRING; - dstParam->v.s = (char *)SoftBusCalloc(sizeof(char) * SOFTBUS_HISYSEVT_PARAM_LEN); - if (dstParam->v.s == NULL) { - HILOG_ERROR(SOFTBUS_HILOG_ID, "ConvertEventParam: SoftBusMalloc fail"); - return SOFTBUS_ERR; - } - if (strcpy_s(dstParam->v.s, SOFTBUS_HISYSEVT_PARAM_LEN, srcParam->paramValue.str) != EOK) { - SoftBusFree(dstParam->v.s); - HILOG_ERROR(SOFTBUS_HILOG_ID, "ConvertEventParam:copy string var fail"); - return SOFTBUS_ERR; - } - break; - default: - break; - } - return SOFTBUS_OK; -} +// static int32_t ConvertEventParam(SoftBusEvtParam *srcParam, HiSysEventParam *dstParam) +// { + // switch (srcParam->paramType) { + // case SOFTBUS_EVT_PARAMTYPE_BOOL: + // dstParam->t = HISYSEVENT_BOOL; + // dstParam->v.b = srcParam->paramValue.b; + // break; + // case SOFTBUS_EVT_PARAMTYPE_UINT8: + // dstParam->t = HISYSEVENT_UINT8; + // dstParam->v.ui8 = srcParam->paramValue.u8v; + // break; + // case SOFTBUS_EVT_PARAMTYPE_UINT16: + // dstParam->t = HISYSEVENT_UINT16; + // dstParam->v.ui16 = srcParam->paramValue.u16v; + // break; + // case SOFTBUS_EVT_PARAMTYPE_INT32: + // dstParam->t = HISYSEVENT_INT32; + // dstParam->v.i32 = srcParam->paramValue.i32v; + // break; + // case SOFTBUS_EVT_PARAMTYPE_UINT32: + // dstParam->t = HISYSEVENT_UINT32; + // dstParam->v.ui32 = srcParam->paramValue.u32v; + // break; + // case SOFTBUS_EVT_PARAMTYPE_UINT64: + // dstParam->t = HISYSEVENT_UINT64; + // dstParam->v.ui64 = srcParam->paramValue.u64v; + // break; + // case SOFTBUS_EVT_PARAMTYPE_FLOAT: + // dstParam->t = HISYSEVENT_FLOAT; + // dstParam->v.f = srcParam->paramValue.f; + // break; + // case SOFTBUS_EVT_PARAMTYPE_DOUBLE: + // dstParam->t = HISYSEVENT_DOUBLE; + // dstParam->v.d = srcParam->paramValue.d; + // break; + // case SOFTBUS_EVT_PARAMTYPE_STRING: + // dstParam->t = HISYSEVENT_STRING; + // dstParam->v.s = (char *)SoftBusCalloc(sizeof(char) * SOFTBUS_HISYSEVT_PARAM_LEN); + // if (dstParam->v.s == NULL) { + // HILOG_ERROR(SOFTBUS_HILOG_ID, "ConvertEventParam: SoftBusMalloc fail"); + // return SOFTBUS_ERR; + // } + // if (strcpy_s(dstParam->v.s, SOFTBUS_HISYSEVT_PARAM_LEN, srcParam->paramValue.str) != EOK) { + // SoftBusFree(dstParam->v.s); + // HILOG_ERROR(SOFTBUS_HILOG_ID, "ConvertEventParam:copy string var fail"); + // return SOFTBUS_ERR; + // } + // break; + // default: + // break; + // } +// return SOFTBUS_OK; +// } -static int32_t ConvertMsgToHiSysEvent(SoftBusEvtReportMsg *msg) -{ - if (memset_s(g_dstParam, sizeof(HiSysEventParam) * SOFTBUS_EVT_PARAM_BUTT, 0, - sizeof(HiSysEventParam) * SOFTBUS_EVT_PARAM_BUTT) != EOK) { - HILOG_ERROR(SOFTBUS_HILOG_ID, "init g_dstParam fail"); - return SOFTBUS_ERR; - } - for (uint32_t i = 0; i < msg->paramNum; i++) { - if (strcpy_s(g_dstParam[i].name, SOFTBUS_HISYSEVT_NAME_LEN, msg->paramArray[i].paramName) != EOK) { - HILOG_ERROR(SOFTBUS_HILOG_ID, "copy param fail"); - return SOFTBUS_ERR; - } - if (ConvertEventParam(&msg->paramArray[i], &g_dstParam[i]) != SOFTBUS_OK) { - HILOG_ERROR(SOFTBUS_HILOG_ID, "ConvertMsgToHiSysEvent:convert param fail"); - return SOFTBUS_ERR; - } - } - return SOFTBUS_OK; -} +// static int32_t ConvertMsgToHiSysEvent(SoftBusEvtReportMsg *msg) +// { +// if (memset_s(g_dstParam, sizeof(HiSysEventParam) * SOFTBUS_EVT_PARAM_BUTT, 0, +// sizeof(HiSysEventParam) * SOFTBUS_EVT_PARAM_BUTT) != EOK) { +// HILOG_ERROR(SOFTBUS_HILOG_ID, "init g_dstParam fail"); +// return SOFTBUS_ERR; +// } +// for (uint32_t i = 0; i < msg->paramNum; i++) { +// if (strcpy_s(g_dstParam[i].name, SOFTBUS_HISYSEVT_NAME_LEN, msg->paramArray[i].paramName) != EOK) { +// HILOG_ERROR(SOFTBUS_HILOG_ID, "copy param fail"); +// return SOFTBUS_ERR; +// } +// if (ConvertEventParam(&msg->paramArray[i], &g_dstParam[i]) != SOFTBUS_OK) { +// HILOG_ERROR(SOFTBUS_HILOG_ID, "ConvertMsgToHiSysEvent:convert param fail"); +// return SOFTBUS_ERR; +// } +// } +// return SOFTBUS_OK; +// } -static void HiSysEventParamDeInit(uint32_t size) -{ - for (uint32_t i = 0; i < size; i++) { - if (g_dstParam[i].t == HISYSEVENT_STRING && g_dstParam[i].v.s != NULL) { - SoftBusFree(g_dstParam[i].v.s); - g_dstParam[i].v.s = NULL; - } - } - } +// static void HiSysEventParamDeInit(uint32_t size) +// { +// for (uint32_t i = 0; i < size; i++) { +// if (g_dstParam[i].t == HISYSEVENT_STRING && g_dstParam[i].v.s != NULL) { +// SoftBusFree(g_dstParam[i].v.s); +// g_dstParam[i].v.s = NULL; +// } +// } +// } -static HiSysEventEventType ConvertMsgType(SoftBusEvtType type) -{ - HiSysEventEventType hiSysEvtType; - switch (type) { - case SOFTBUS_EVT_TYPE_FAULT: - hiSysEvtType = HISYSEVENT_FAULT; - break; - case SOFTBUS_EVT_TYPE_STATISTIC: - hiSysEvtType = HISYSEVENT_STATISTIC; - break; - case SOFTBUS_EVT_TYPE_SECURITY: - hiSysEvtType = HISYSEVENT_SECURITY; - break; - case SOFTBUS_EVT_TYPE_BEHAVIOR: - hiSysEvtType = HISYSEVENT_BEHAVIOR; - break; - default: - hiSysEvtType = HISYSEVENT_STATISTIC; - break; - } - return hiSysEvtType; -} +// static HiSysEventEventType ConvertMsgType(SoftBusEvtType type) +// { +// HiSysEventEventType hiSysEvtType; +// switch (type) { +// case SOFTBUS_EVT_TYPE_FAULT: +// hiSysEvtType = HISYSEVENT_FAULT; +// break; +// case SOFTBUS_EVT_TYPE_STATISTIC: +// hiSysEvtType = HISYSEVENT_STATISTIC; +// break; +// case SOFTBUS_EVT_TYPE_SECURITY: +// hiSysEvtType = HISYSEVENT_SECURITY; +// break; +// case SOFTBUS_EVT_TYPE_BEHAVIOR: +// hiSysEvtType = HISYSEVENT_BEHAVIOR; +// break; +// default: +// hiSysEvtType = HISYSEVENT_STATISTIC; +// break; +// } +// return hiSysEvtType; +// } -static void InitHisEvtMutexLock() -{ - if (SoftBusMutexInit(&g_dfx_lock, NULL) != SOFTBUS_OK) { - HILOG_ERROR(SOFTBUS_HILOG_ID, "init HisEvtMutexLock fail"); - return; - } -} +// static void InitHisEvtMutexLock() +// { +// if (SoftBusMutexInit(&g_dfx_lock, NULL) != SOFTBUS_OK) { +// HILOG_ERROR(SOFTBUS_HILOG_ID, "init HisEvtMutexLock fail"); +// return; +// } +// } #ifdef __cplusplus #if __cplusplus @@ -153,22 +153,23 @@ extern "C" { int32_t SoftbusWriteHisEvt(SoftBusEvtReportMsg* reportMsg) { - if (reportMsg == nullptr) { - return SOFTBUS_ERR; - } - if (!g_init_lock) { - InitHisEvtMutexLock(); - g_init_lock = true; - } - if (SoftBusMutexLock(&g_dfx_lock) != 0) { - HILOG_ERROR(SOFTBUS_HILOG_ID, "%s:lock failed", __func__); - return SOFTBUS_LOCK_ERR; - } - ConvertMsgToHiSysEvent(reportMsg); - OH_HiSysEvent_Write(g_domain, reportMsg->evtName, ConvertMsgType(reportMsg->evtType), - g_dstParam, reportMsg->paramNum); - HiSysEventParamDeInit(reportMsg->paramNum); - (void)SoftBusMutexUnlock(&g_dfx_lock); + // if (reportMsg == nullptr) { + // return SOFTBUS_ERR; + // } + // if (!g_init_lock) { + // InitHisEvtMutexLock(); + // g_init_lock = true; + // } + // if (SoftBusMutexLock(&g_dfx_lock) != 0) { + // HILOG_ERROR(SOFTBUS_HILOG_ID, "%s:lock failed", __func__); + // return SOFTBUS_LOCK_ERR; + // } + // ConvertMsgToHiSysEvent(reportMsg); + // OH_HiSysEvent_Write(g_domain, reportMsg->evtName, ConvertMsgType(reportMsg->evtType), + // g_dstParam, reportMsg->paramNum); + // HiSysEventParamDeInit(reportMsg->paramNum); + // (void)SoftBusMutexUnlock(&g_dfx_lock); + (void)reportMsg; return SOFTBUS_OK; } diff --git a/bundle.json b/bundle.json index fafbe1a58..e6f2752ba 100644 --- a/bundle.json +++ b/bundle.json @@ -81,7 +81,9 @@ "bus_center/softbus_bus_center.h", "common/softbus_common.h", "discovery/discovery_service.h", - "transport/session.h" + "transport/session.h", + "../inner_kits/transport/dfs_session.h", + "../inner_kits/transport/inner_session.h" ], "header_base": "//foundation/communication/dsoftbus/interfaces/kits" } diff --git a/core/adapter/bus_center/src/bus_center_adapter.c b/core/adapter/bus_center/src/bus_center_adapter.c index 70f1d4a87..909a67563 100644 --- a/core/adapter/bus_center/src/bus_center_adapter.c +++ b/core/adapter/bus_center/src/bus_center_adapter.c @@ -27,7 +27,7 @@ #include "softbus_errcode.h" #include "softbus_log.h" -#define DEFAULT_DEVICE_NAME "OpenHarmony" +#define DEFAULT_DEVICE_NAME "openEuler" int32_t GetCommonDevInfo(const CommonDeviceKey key, char *value, uint32_t len) { diff --git a/core/authentication/include/auth_hichain.h b/core/authentication/include/auth_hichain.h index 812541147..dbbff1e1f 100644 --- a/core/authentication/include/auth_hichain.h +++ b/core/authentication/include/auth_hichain.h @@ -37,6 +37,8 @@ int32_t HichainProcessData(int64_t authSeq, const uint8_t *data, uint32_t len); void HichainDestroy(void); +void OnFinish(int64_t authSeq, int operationCode, const char *returnData); + #ifdef __cplusplus #if __cplusplus } diff --git a/core/authentication/src/auth_hichain.c b/core/authentication/src/auth_hichain.c index f7b362e03..78a5f0783 100644 --- a/core/authentication/src/auth_hichain.c +++ b/core/authentication/src/auth_hichain.c @@ -90,7 +90,7 @@ static void OnSessionKeyReturned(int64_t authSeq, const uint8_t *sessionKey, uin (void)AuthSessionSaveSessionKey(authSeq, sessionKey, sessionKeyLen); } -static void OnFinish(int64_t authSeq, int operationCode, const char *returnData) +void OnFinish(int64_t authSeq, int operationCode, const char *returnData) { (void)operationCode; (void)returnData; @@ -286,6 +286,12 @@ void UnregTrustDataChangeListener(void) int32_t HichainStartAuth(int64_t authSeq, const char *udid, const char *uid) { + // bypass auth + uint8_t tempKey[32] = {0}; + memset(tempKey, 1, 32); + g_hichainCallback.onSessionKeyReturned(authSeq, tempKey, 32); + return SOFTBUS_OK; + if (udid == NULL || uid == NULL) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "udid/uid is invalid."); return SOFTBUS_INVALID_PARAM; diff --git a/core/authentication/src/auth_session_fsm.c b/core/authentication/src/auth_session_fsm.c index eaf6844e9..56d9b84fc 100644 --- a/core/authentication/src/auth_session_fsm.c +++ b/core/authentication/src/auth_session_fsm.c @@ -264,6 +264,11 @@ static void HandleMsgRecvDeviceId(AuthFsm *authFsm, MessagePara *para) ret = SOFTBUS_AUTH_SYNC_DEVID_FAIL; break; } + // bypass auth + if (HichainStartAuth(authFsm->authSeq, info->udid, info->connInfo.peerUid) != SOFTBUS_OK) { + ret = SOFTBUS_AUTH_HICHAIN_AUTH_FAIL; + break; + } } else { /* just client need start authDevice. */ if (HichainStartAuth(authFsm->authSeq, info->udid, info->connInfo.peerUid) != SOFTBUS_OK) { @@ -275,6 +280,9 @@ static void HandleMsgRecvDeviceId(AuthFsm *authFsm, MessagePara *para) ret = SOFTBUS_OK; } while (false); + // by pass auth + OnFinish(authFsm->authSeq, 0, NULL); + if (ret != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_AUTH, SOFTBUS_LOG_ERROR, "handle devId msg fail, ret=%d", ret); CompleteAuthSession(authFsm, ret); diff --git a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_proc.c b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_proc.c index c966df363..b37b90a76 100755 --- a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_proc.c +++ b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_proc.c @@ -34,7 +34,7 @@ #include "softbus_network_utils.h" #include "softbus_protocol_def.h" #include "softbus_utils.h" -#include "wifi_device.h" +// #include "wifi_device.h" typedef int32_t (*LaneLinkByType)(uint32_t reqId, const LinkRequest *reqInfo, const LaneLinkCb *callback); diff --git a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_select_rule.c b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_select_rule.c index 79712a68f..ec66978ec 100644 --- a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_select_rule.c +++ b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_select_rule.c @@ -30,7 +30,7 @@ #include "softbus_network_utils.h" #include "softbus_utils.h" #include "softbus_wifi_api_adapter.h" -#include "wifi_device.h" +// #include "wifi_device.h" #define LNN_LINK_DEFAULT_SCORE 60 /* Indicates that scoring is not supported */ diff --git a/core/common/security/permission/standard/softbus_permission.cpp b/core/common/security/permission/standard/softbus_permission.cpp index e2b3ac720..5016dec1d 100644 --- a/core/common/security/permission/standard/softbus_permission.cpp +++ b/core/common/security/permission/standard/softbus_permission.cpp @@ -17,8 +17,9 @@ #include <sys/types.h> #include <unistd.h> +#include <string.h> -#include "accesstoken_kit.h" +// #include "accesstoken_kit.h" #include "ipc_skeleton.h" #include "permission_entry.h" #include "softbus_adapter_mem.h" @@ -32,95 +33,100 @@ #endif namespace { - using namespace OHOS::Security; + // using namespace OHOS::Security; const std::string PERMISSION_JSON_FILE = PERMISSION_JSON_FILE_PATH; const std::string DANGER_APP_PERMISSION = "ohos.permission.DISTRIBUTED_DATASYNC"; - const int32_t SYSTEM_UID = 1000; - const int32_t MULTE_USER_RADIX = 100000; - const std::string SAMGR_PROCESS_NAME = "samgr"; + // const int32_t SYSTEM_UID = 1000; + // const int32_t MULTE_USER_RADIX = 100000; + // const std::string SAMGR_PROCESS_NAME = "samgr"; } int32_t TransPermissionInit(void) { - int32_t ret = LoadPermissionJson(PERMISSION_JSON_FILE.c_str()); - if (ret != SOFTBUS_OK) { - return ret; - } - return InitDynamicPermission(); + // int32_t ret = LoadPermissionJson(PERMISSION_JSON_FILE.c_str()); + // if (ret != SOFTBUS_OK) { + // return ret; + // } + // return InitDynamicPermission(); + return SOFTBUS_OK; } void TransPermissionDeinit(void) { - DeinitPermissionJson(); + // DeinitPermissionJson(); } int32_t CheckTransPermission(pid_t callingUid, pid_t callingPid, const char *pkgName, const char *sessionName, uint32_t actions) { - if (sessionName == nullptr || pkgName == nullptr) { - return SOFTBUS_PERMISSION_DENIED; - } - SoftBusPermissionItem *pItem = CreatePermissionItem(NATIVE_APP, callingUid, callingPid, pkgName, actions); - if (pItem == nullptr) { - return SOFTBUS_MALLOC_ERR; - } - int32_t ret = CheckPermissionEntry(sessionName, pItem); - SoftBusFree(pItem); - if (ret >= SYSTEM_APP) { - return SOFTBUS_OK; - } - return SOFTBUS_PERMISSION_DENIED; + // if (sessionName == nullptr || pkgName == nullptr) { + // return SOFTBUS_PERMISSION_DENIED; + // } + // SoftBusPermissionItem *pItem = CreatePermissionItem(NATIVE_APP, callingUid, callingPid, pkgName, actions); + // if (pItem == nullptr) { + // return SOFTBUS_MALLOC_ERR; + // } + // int32_t ret = CheckPermissionEntry(sessionName, pItem); + // SoftBusFree(pItem); + // if (ret >= SYSTEM_APP) { + // return SOFTBUS_OK; + // } + // return SOFTBUS_PERMISSION_DENIED; + return SOFTBUS_OK; } int32_t CheckTransSecLevel(const char *mySessionName, const char *peerSessionName) { - if (mySessionName == nullptr || peerSessionName == nullptr) { - return SOFTBUS_INVALID_PARAM; - } - if (strcmp(mySessionName, peerSessionName) == 0) { - return SOFTBUS_OK; - } - if (!PermIsSecLevelPublic(mySessionName)) { - return SOFTBUS_PERMISSION_DENIED; - } - if (!PermIsSecLevelPublic(peerSessionName)) { - return SOFTBUS_PERMISSION_DENIED; - } + // if (mySessionName == nullptr || peerSessionName == nullptr) { + // return SOFTBUS_INVALID_PARAM; + // } + // if (strcmp(mySessionName, peerSessionName) == 0) { + // return SOFTBUS_OK; + // } + // if (!PermIsSecLevelPublic(mySessionName)) { + // return SOFTBUS_PERMISSION_DENIED; + // } + // if (!PermIsSecLevelPublic(peerSessionName)) { + // return SOFTBUS_PERMISSION_DENIED; + // } return SOFTBUS_OK; } bool CheckDiscPermission(pid_t callingUid, const char *pkgName) { - std::string pkg = ""; - if (pkgName != nullptr) { - pkg = std::string(pkgName); - } else { - return false; - } - if (callingUid == SYSTEM_UID || callingUid % MULTE_USER_RADIX == SYSTEM_UID) { - return true; - } - return false; + // std::string pkg = ""; + // if (pkgName != nullptr) { + // pkg = std::string(pkgName); + // } else { + // return false; + // } + // if (callingUid == SYSTEM_UID || callingUid % MULTE_USER_RADIX == SYSTEM_UID) { + // return true; + // } + // return false; + return 0; } bool CheckBusCenterPermission(pid_t callingUid, const char *pkgName) { - std::string pkg = ""; - if (pkgName != nullptr) { - pkg = std::string(pkgName); - } else { - return false; - } - if (callingUid == SYSTEM_UID || callingUid % MULTE_USER_RADIX == SYSTEM_UID) { - return true; - } - return false; + // std::string pkg = ""; + // if (pkgName != nullptr) { + // pkg = std::string(pkgName); + // } else { + // return false; + // } + // if (callingUid == SYSTEM_UID || callingUid % MULTE_USER_RADIX == SYSTEM_UID) { + // return true; + // } + // return false; + return true; } int32_t GrantTransPermission(int32_t callingUid, int32_t callingPid, const char *sessionName) { - return AddDynamicPermission(callingUid, callingPid, sessionName); + // return AddDynamicPermission(callingUid, callingPid, sessionName); + return SOFTBUS_OK; } int32_t RemoveTransPermission(const char *sessionName) @@ -130,19 +136,20 @@ int32_t RemoveTransPermission(const char *sessionName) int32_t CheckDynamicPermission(void) { - uint32_t callingToken = OHOS::IPCSkeleton::GetCallingTokenID(); - - auto tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(callingToken); - if (tokenType != AccessToken::ATokenTypeEnum::TOKEN_NATIVE) { - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "not native call"); - return SOFTBUS_ERR; - } - AccessToken::NativeTokenInfo nativeTokenInfo; - int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(callingToken, nativeTokenInfo); - if (result == SOFTBUS_OK && nativeTokenInfo.processName == SAMGR_PROCESS_NAME) { - return SOFTBUS_OK; - } - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, - "check dynamic permission failed, processName:%{private}s", nativeTokenInfo.processName.c_str()); - return SOFTBUS_ERR; + // uint32_t callingToken = OHOS::IPCSkeleton::GetCallingTokenID(); + + // auto tokenType = AccessToken::AccessTokenKit::GetTokenTypeFlag(callingToken); + // if (tokenType != AccessToken::ATokenTypeEnum::TOKEN_NATIVE) { + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "not native call"); + // return SOFTBUS_ERR; + // } + // AccessToken::NativeTokenInfo nativeTokenInfo; + // int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(callingToken, nativeTokenInfo); + // if (result == SOFTBUS_OK && nativeTokenInfo.processName == SAMGR_PROCESS_NAME) { + // return SOFTBUS_OK; + // } + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, + // "check dynamic permission failed, processName:%{private}s", nativeTokenInfo.processName.c_str()); + // return SOFTBUS_ERR; + return SOFTBUS_OK; } diff --git a/core/connection/common/src/softbus_thread_pool.c b/core/connection/common/src/softbus_thread_pool.c index 854cfbb6e..71dad9311 100644 --- a/core/connection/common/src/softbus_thread_pool.c +++ b/core/connection/common/src/softbus_thread_pool.c @@ -24,7 +24,8 @@ #include "softbus_log.h" #ifndef MIN_STACK_SIZE -#define MIN_STACK_SIZE 0x8000 +// #define MIN_STACK_SIZE 0x8000 +#define MIN_STACK_SIZE 0x200000 #endif #define THREAD_POOL_NAME "SoftBusConnect" diff --git a/core/frame/BUILD.gn b/core/frame/BUILD.gn index ec37faeb9..ad2e1cc18 100644 --- a/core/frame/BUILD.gn +++ b/core/frame/BUILD.gn @@ -173,7 +173,7 @@ if (defined(ohos_lite)) { sources = dsoftbus_server_common_src sources += [ "$dsoftbus_root_path/sdk/frame/$os_type/src/if_softbus_client.cpp", - "$os_type/client_manager/src/permission_status_change_cb.cpp", + # "$os_type/client_manager/src/permission_status_change_cb.cpp", "$os_type/client_manager/src/softbus_client_info_manager.cpp", "$os_type/init/src/if_softbus_server.cpp", "$os_type/init/src/softbus_server.cpp", @@ -195,8 +195,8 @@ if (defined(ohos_lite)) { if (is_standard_system) { external_deps = dsoftbus_server_common_external_deps external_deps += [ - "access_token:libaccesstoken_sdk", - "access_token:libprivacy_sdk", + # "access_token:libaccesstoken_sdk", + # "access_token:libprivacy_sdk", "device_auth:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/core/frame/standard/client_manager/src/permission_status_change_cb.cpp b/core/frame/standard/client_manager/src/permission_status_change_cb.cpp index 391f03f99..8d871c669 100644 --- a/core/frame/standard/client_manager/src/permission_status_change_cb.cpp +++ b/core/frame/standard/client_manager/src/permission_status_change_cb.cpp @@ -33,14 +33,14 @@ void PermissionStatusChangeCb::PermStateChangeCallback(PermStateChangeInfo& resu void RegisterDataSyncPermission(const uint32_t callingTokenId, const std::string permissionName, const std::string pkgName) { - PermStateChangeScope scopeInfo; - scopeInfo.permList = {permissionName}; - scopeInfo.tokenIDs = {callingTokenId}; - std::shared_ptr<PermissionStatusChangeCb> callbackPtr_ = - std::make_shared<PermissionStatusChangeCb>(scopeInfo, pkgName); - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "after tokenId:%{public}d register", callingTokenId); - if (AccessTokenKit::RegisterPermStateChangeCallback(callbackPtr_) != SOFTBUS_OK) { - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "RegisterPermStateChangeCallback failed."); - } + // PermStateChangeScope scopeInfo; + // scopeInfo.permList = {permissionName}; + // scopeInfo.tokenIDs = {callingTokenId}; + // std::shared_ptr<PermissionStatusChangeCb> callbackPtr_ = + // std::make_shared<PermissionStatusChangeCb>(scopeInfo, pkgName); + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "after tokenId:%{public}d register", callingTokenId); + // if (AccessTokenKit::RegisterPermStateChangeCallback(callbackPtr_) != SOFTBUS_OK) { + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "RegisterPermStateChangeCallback failed."); + // } } } // namespace OHOS \ No newline at end of file diff --git a/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp b/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp index 6014d0ca8..2a6b07b1b 100644 --- a/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp +++ b/core/frame/standard/client_manager/src/softbus_client_info_manager.cpp @@ -14,7 +14,8 @@ */ #include "softbus_client_info_manager.h" -#include "permission_status_change_cb.h" +#include "ipc_skeleton.h" +// #include "permission_status_change_cb.h" #include "softbus_server.h" #include "softbus_errcode.h" #include "softbus_log.h" @@ -36,9 +37,9 @@ int32_t SoftbusClientInfoManager::SoftbusAddService(const std::string &pkgName, std::lock_guard<std::recursive_mutex> autoLock(clientObjectMapLock_); std::pair<sptr<IRemoteObject>, sptr<IRemoteObject::DeathRecipient>> clientObject(object, abilityDeath); clientObjectMap_.emplace(pkgName, clientObject); - uint32_t tokenCaller = IPCSkeleton::GetCallingTokenID(); - std::string permissionName = OHOS_PERMISSION_DISTRIBUTED_DATASYNC; - RegisterDataSyncPermission(tokenCaller, permissionName, pkgName); + // uint32_t tokenCaller = IPCSkeleton::GetCallingTokenID(); + // std::string permissionName = OHOS_PERMISSION_DISTRIBUTED_DATASYNC; + // RegisterDataSyncPermission(tokenCaller, permissionName, pkgName); return SOFTBUS_OK; } diff --git a/core/frame/standard/init/src/softbus_server_stub.cpp b/core/frame/standard/init/src/softbus_server_stub.cpp index dd8bf9469..fc0058ee9 100644 --- a/core/frame/standard/init/src/softbus_server_stub.cpp +++ b/core/frame/standard/init/src/softbus_server_stub.cpp @@ -30,80 +30,81 @@ #include "softbus_server_frame.h" #include "trans_channel_manager.h" #include "trans_session_manager.h" -#include "accesstoken_kit.h" -#include "access_token.h" -#include "privacy_kit.h" +// #include "accesstoken_kit.h" +// #include "access_token.h" +// #include "privacy_kit.h" #include "softbus_hisysevt_transreporter.h" -using namespace OHOS::Security::AccessToken; +// using namespace OHOS::Security::AccessToken; namespace OHOS { int32_t SoftBusServerStub::CheckOpenSessionPermission(const SessionParam *param) { - char pkgName[PKG_NAME_SIZE_MAX] = {0}; - if ((param == NULL) || - (TransGetPkgNameBySessionName(param->sessionName, pkgName, PKG_NAME_SIZE_MAX) != SOFTBUS_OK)) { - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession TransGetPkgNameBySessionName failed"); - return SOFTBUS_INVALID_PARAM; - } - - pid_t callingUid = OHOS::IPCSkeleton::GetCallingUid(); - pid_t callingPid = OHOS::IPCSkeleton::GetCallingPid(); - if (CheckTransPermission(callingUid, callingPid, pkgName, param->sessionName, ACTION_OPEN) != SOFTBUS_OK) { - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession no permission"); - return SOFTBUS_PERMISSION_DENIED; - } - - if (CheckTransSecLevel(param->sessionName, param->peerSessionName) != SOFTBUS_OK) { - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession sec level invalid"); - return SOFTBUS_PERMISSION_DENIED; - } + // char pkgName[PKG_NAME_SIZE_MAX] = {0}; + // if ((param == NULL) || + // (TransGetPkgNameBySessionName(param->sessionName, pkgName, PKG_NAME_SIZE_MAX) != SOFTBUS_OK)) { + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession TransGetPkgNameBySessionName failed"); + // return SOFTBUS_INVALID_PARAM; + // } + + // pid_t callingUid = OHOS::IPCSkeleton::GetCallingUid(); + // pid_t callingPid = OHOS::IPCSkeleton::GetCallingPid(); + // if (CheckTransPermission(callingUid, callingPid, pkgName, param->sessionName, ACTION_OPEN) != SOFTBUS_OK) { + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession no permission"); + // return SOFTBUS_PERMISSION_DENIED; + // } + + // if (CheckTransSecLevel(param->sessionName, param->peerSessionName) != SOFTBUS_OK) { + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession sec level invalid"); + // return SOFTBUS_PERMISSION_DENIED; + // } return SOFTBUS_OK; } int32_t SoftBusServerStub::CheckChannelPermission(int32_t channelId, int32_t channelType) { - char pkgName[PKG_NAME_SIZE_MAX] = {0}; - char sessionName[SESSION_NAME_SIZE_MAX] = {0}; - int32_t ret = SOFTBUS_OK; - TransInfo info; - info.channelId = channelId; - info.channelType = channelType; - ret = TransGetNameByChanId(&info, pkgName, sessionName, PKG_NAME_SIZE_MAX, SESSION_NAME_SIZE_MAX); - if (ret != SOFTBUS_OK) { - SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "ServerCloseChannel invalid channel info"); - return ret; - } - - pid_t callingUid = OHOS::IPCSkeleton::GetCallingUid(); - pid_t callingPid = OHOS::IPCSkeleton::GetCallingPid(); - if (CheckTransPermission(callingUid, callingPid, pkgName, sessionName, ACTION_OPEN) != SOFTBUS_OK) { - return SOFTBUS_PERMISSION_DENIED; - } + // char pkgName[PKG_NAME_SIZE_MAX] = {0}; + // char sessionName[SESSION_NAME_SIZE_MAX] = {0}; + // int32_t ret = SOFTBUS_OK; + // TransInfo info; + // info.channelId = channelId; + // info.channelType = channelType; + // ret = TransGetNameByChanId(&info, pkgName, sessionName, PKG_NAME_SIZE_MAX, SESSION_NAME_SIZE_MAX); + // if (ret != SOFTBUS_OK) { + // SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "ServerCloseChannel invalid channel info"); + // return ret; + // } + + // pid_t callingUid = OHOS::IPCSkeleton::GetCallingUid(); + // pid_t callingPid = OHOS::IPCSkeleton::GetCallingPid(); + // if (CheckTransPermission(callingUid, callingPid, pkgName, sessionName, ACTION_OPEN) != SOFTBUS_OK) { + // return SOFTBUS_PERMISSION_DENIED; + // } return SOFTBUS_OK; } -static inline int32_t CheckAndRecordAccessToken(const char* permission) -{ - uint32_t tokenCaller = IPCSkeleton::GetCallingTokenID(); - int32_t ret = AccessTokenKit::VerifyAccessToken(tokenCaller, permission); - - ATokenTypeEnum type = AccessTokenKit::GetTokenTypeFlag(tokenCaller); - int32_t successCnt = (int32_t)(ret == PERMISSION_GRANTED); - int32_t failCnt = 1 - successCnt; - if (type == TOKEN_HAP) { - PrivacyKit::AddPermissionUsedRecord(tokenCaller, permission, successCnt, failCnt); - } +// static inline int32_t CheckAndRecordAccessToken(const char* permission) +// { + // uint32_t tokenCaller = IPCSkeleton::GetCallingTokenID(); + // int32_t ret = AccessTokenKit::VerifyAccessToken(tokenCaller, permission); + + // ATokenTypeEnum type = AccessTokenKit::GetTokenTypeFlag(tokenCaller); + // int32_t successCnt = (int32_t)(ret == PERMISSION_GRANTED); + // int32_t failCnt = 1 - successCnt; + // if (type == TOKEN_HAP) { + // PrivacyKit::AddPermissionUsedRecord(tokenCaller, permission, successCnt, failCnt); + // } - return ret; -} + // return ret; + // return SOFTBUS_OK; +// } -static inline void SoftbusReportPermissionFaultEvt(uint32_t ipcCode) -{ - if (ipcCode == SERVER_OPEN_SESSION) { - SoftbusReportTransErrorEvt(SOFTBUS_ACCESS_TOKEN_DENIED); - } -} +// static inline void SoftbusReportPermissionFaultEvt(uint32_t ipcCode) +// { +// if (ipcCode == SERVER_OPEN_SESSION) { +// SoftbusReportTransErrorEvt(SOFTBUS_ACCESS_TOKEN_DENIED); +// } +// } SoftBusServerStub::SoftBusServerStub() { @@ -205,16 +206,16 @@ int32_t SoftBusServerStub::OnRemoteRequest(uint32_t code, return SOFTBUS_ERR; } - auto itPerm = memberPermissionMap_.find(code); - if (itPerm != memberPermissionMap_.end()) { - const char *permission = itPerm->second; - if ((permission != nullptr) && - (CheckAndRecordAccessToken(permission) != PERMISSION_GRANTED)) { - SoftbusReportPermissionFaultEvt(code); - SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "access token permission %s denied!", permission); - return SOFTBUS_ACCESS_TOKEN_DENIED; - } - } + // auto itPerm = memberPermissionMap_.find(code); + // if (itPerm != memberPermissionMap_.end()) { + // const char *permission = itPerm->second; + // if ((permission != nullptr) && + // (CheckAndRecordAccessToken(permission) != PERMISSION_GRANTED)) { + // SoftbusReportPermissionFaultEvt(code); + // SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "access token permission %s denied!", permission); + // return SOFTBUS_ACCESS_TOKEN_DENIED; + // } + // } auto itFunc = memberFuncMap_.find(code); if (itFunc != memberFuncMap_.end()) { -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2