提交 2ce994fa 编写于 作者: L lutao

fix dump interface

Signed-off-by: Nlutao <lutao31@huawei.com>
上级 080da5d4
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
namespace OHOS { namespace OHOS {
#ifdef CONFIG_IPC_SINGLE #ifdef CONFIG_IPC_SINGLE
using namespace IPC_SINGLE; using namespace IPC_SINGLE;
static constexpr int HIDUMPER_SERVICE_UID = 1212;
#endif #endif
using namespace OHOS::HiviewDFX; using namespace OHOS::HiviewDFX;
...@@ -57,11 +58,11 @@ static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCObjectStub" }; ...@@ -57,11 +58,11 @@ static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCObjectStub" };
using namespace OHOS::Security; using namespace OHOS::Security;
// Authentication information can be added only for processes with system permission. // Authentication information can be added only for processes with system permission.
static constexpr pid_t ALLOWED_UID = 10000; static constexpr pid_t ALLOWED_UID = 10000;
static constexpr pid_t SHELL_UID = 2000;
static constexpr int APL_BASIC = 2; static constexpr int APL_BASIC = 2;
// Only the samgr can obtain the UID and PID. // Only the samgr can obtain the UID and PID.
static const std::string SAMGR_PROCESS_NAME = "samgr"; static const std::string SAMGR_PROCESS_NAME = "samgr";
#endif #endif
static constexpr int SHELL_UID = 2000;
IPCObjectStub::IPCObjectStub(std::u16string descriptor) : IRemoteObject(descriptor) IPCObjectStub::IPCObjectStub(std::u16string descriptor) : IRemoteObject(descriptor)
{ {
...@@ -165,20 +166,22 @@ int IPCObjectStub::SendRequest(uint32_t code, MessageParcel &data, MessageParcel ...@@ -165,20 +166,22 @@ int IPCObjectStub::SendRequest(uint32_t code, MessageParcel &data, MessageParcel
reply.WriteInt32(refCount); reply.WriteInt32(refCount);
break; break;
} }
#ifndef CONFIG_IPC_SINGLE
case DUMP_TRANSACTION: { case DUMP_TRANSACTION: {
pid_t uid = IPCSkeleton::GetCallingUid(); pid_t uid = IPCSkeleton::GetCallingUid();
#ifndef CONFIG_IPC_SINGLE
uint32_t calllingTokenID = IPCSkeleton::GetFirstTokenID(); uint32_t calllingTokenID = IPCSkeleton::GetFirstTokenID();
calllingTokenID = calllingTokenID == 0 ? IPCSkeleton::GetCallingTokenID() : calllingTokenID; calllingTokenID = calllingTokenID == 0 ? IPCSkeleton::GetCallingTokenID() : calllingTokenID;
if (!IPCSkeleton::IsLocalCalling() || if (!IPCSkeleton::IsLocalCalling() ||
(uid != 0 && uid != SHELL_UID && !HasDumpPermission(calllingTokenID))) { (uid != 0 && uid != SHELL_UID && !HasDumpPermission(calllingTokenID))) {
#else
if (!IPCSkeleton::IsLocalCalling() || (uid != 0 && uid != SHELL_UID && uid != HIDUMPER_SERVICE_UID)) {
#endif
ZLOGE(LABEL, "do not allow dump"); ZLOGE(LABEL, "do not allow dump");
break; break;
} }
result = OnRemoteDump(code, data, reply, option); result = OnRemoteDump(code, data, reply, option);
break; break;
} }
#endif
case GET_PROTO_INFO: { case GET_PROTO_INFO: {
result = ProcessProto(code, data, reply, option); result = ProcessProto(code, data, reply, option);
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册