From 5355d87755d2d25c8ac957e20c7b1fe6951e83ad Mon Sep 17 00:00:00 2001 From: j30052480 Date: Mon, 17 Jun 2024 15:46:44 +0800 Subject: [PATCH] fix: revert devmgr adapting calling sid Signed-off-by: j30052480 --- adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp | 8 ----- .../uhdf2/manager/src/devsvc_manager_stub.c | 35 ++++--------------- interfaces/inner_api/ipc/hdf_remote_service.h | 7 ---- 3 files changed, 6 insertions(+), 44 deletions(-) diff --git a/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp b/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp index 5b47f5303..f4972e3ae 100644 --- a/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp +++ b/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp @@ -304,9 +304,6 @@ 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); - OHOS::sptr remote = holder->remote_; - OHOS::IPCObjectStub *stub = reinterpret_cast(remote.GetRefPtr()); - stub->SetRequestSidFlag(true); 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"); @@ -433,11 +430,6 @@ pid_t HdfRemoteGetCallingUid(void) return OHOS::IPCSkeleton::GetCallingUid(); } -char *HdfRemoteGetCallingSid(void) -{ - return strdup(OHOS::IPCSkeleton::GetCallingSid().c_str()); -} - int HdfRemoteAdapterDefaultDispatch(struct HdfRemoteService *service, int code, struct HdfSBuf *data, struct HdfSBuf *reply) { diff --git a/adapter/uhdf2/manager/src/devsvc_manager_stub.c b/adapter/uhdf2/manager/src/devsvc_manager_stub.c index 42c11b4fa..a85a3bbf1 100644 --- a/adapter/uhdf2/manager/src/devsvc_manager_stub.c +++ b/adapter/uhdf2/manager/src/devsvc_manager_stub.c @@ -36,18 +36,10 @@ static int32_t AddServicePermCheck(const char *servName) { #ifdef WITH_SELINUX pid_t callingPid = HdfRemoteGetCallingPid(); - char *callingSid = HdfRemoteGetCallingSid(); - if (callingSid == NULL) { - HDF_LOGE("%{public}s: sid of %{public}d is null", __func__, callingPid); + if (HdfAddServiceCheck(callingPid, servName) != 0) { + HDF_LOGE("[selinux] %{public}d haven't \"add service\" permission to %{public}s", callingPid, servName); return HDF_ERR_NOPERM; } - if (HdfAddServiceCheck(callingSid, servName) != 0) { - HDF_LOGE("[selinux] %{public}s %{public}d haven't \"add service\" permission to %{public}s", - callingSid, callingPid, servName); - free(callingSid); - return HDF_ERR_NOPERM; - } - free(callingSid); #endif return HDF_SUCCESS; } @@ -56,18 +48,10 @@ static int32_t GetServicePermCheck(const char *servName) { #ifdef WITH_SELINUX pid_t callingPid = HdfRemoteGetCallingPid(); - char *callingSid = HdfRemoteGetCallingSid(); - if (callingSid == NULL) { - HDF_LOGE("%{public}s: sid of %{public}d is null", __func__, callingPid); - return HDF_ERR_NOPERM; - } - if (HdfGetServiceCheck(callingSid, servName) != 0) { - HDF_LOGE("[selinux] %{public}s %{public}d haven't \"get service\" permission to %{public}s", - callingSid, callingPid, servName); - free(callingSid); + if (HdfGetServiceCheck(callingPid, servName) != 0) { + HDF_LOGE("[selinux] %{public}d haven't \"get service\" permission to %{public}s", callingPid, servName); return HDF_ERR_NOPERM; } - free(callingSid); #endif return HDF_SUCCESS; @@ -77,17 +61,10 @@ static int32_t ListServicePermCheck(void) { #ifdef WITH_SELINUX pid_t callingPid = HdfRemoteGetCallingPid(); - char *callingSid = HdfRemoteGetCallingSid(); - if (callingSid == NULL) { - HDF_LOGE("%{public}s: sid of %{public}d is null", __func__, callingPid); - return HDF_ERR_NOPERM; - } - if (HdfListServiceCheck(callingSid) != 0) { - HDF_LOGE("[selinux] %{public}s %{public}d haven't \"list service\" permission", callingSid, callingPid); - free(callingSid); + if (HdfListServiceCheck(callingPid) != 0) { + HDF_LOGE("[selinux] %{public}d haven't \"list service\" permission", callingPid); return HDF_ERR_NOPERM; } - free(callingSid); #endif return HDF_SUCCESS; diff --git a/interfaces/inner_api/ipc/hdf_remote_service.h b/interfaces/inner_api/ipc/hdf_remote_service.h index 85e3f26d5..9c57b30c7 100644 --- a/interfaces/inner_api/ipc/hdf_remote_service.h +++ b/interfaces/inner_api/ipc/hdf_remote_service.h @@ -169,13 +169,6 @@ pid_t HdfRemoteGetCallingPid(void); */ pid_t HdfRemoteGetCallingUid(void); -/** - * @brief Get the caller's SID. - * - * @return The caller's SID. - */ -char* HdfRemoteGetCallingSid(void); - /** * @brief Default command distribution for invoking ipc. * -- Gitee