!1539 【IPC/RPC】删除GetPIdUid接口

Merge pull request !1539 from chenchong_666/master
This commit is contained in:
openharmony_ci 2024-11-19 12:25:13 +00:00 committed by Gitee
commit 4ca8db9280
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 8 additions and 44 deletions

View File

@ -171,17 +171,6 @@ public:
*/
int32_t NoticeServiceDie();
/**
* @brief Obtains the corresponding PID and UID;
* This interface is only provided for internal use by IPC/RPC and is not open to the public,
* It may be taken down at any time.
* @param reply Indicates the object returned by the peer process.
* @return Returns {@link ERR_NONE} if the operation is successful; returns an error code
* defined in {@link ipc_types.h} otherwise.
* @since 9
*/
int GetPidUid(MessageParcel &reply);
/**
* @brief Obtains the session name.
* @return Returns the session name of type string.

View File

@ -276,7 +276,6 @@ public:
private:
#ifndef CONFIG_IPC_SINGLE
int GetPidUid(MessageParcel &data, MessageParcel &reply);
std::string GetSessionName();
int32_t GetSessionNameForPidUid(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
int32_t GetGrantedSessionName(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);

View File

@ -321,14 +321,6 @@ int IPCObjectProxy::RemoveSessionName(const std::string &sessionName)
return err;
}
int IPCObjectProxy::GetPidUid(MessageParcel &reply)
{
MessageParcel data;
MessageOption option;
return SendRequestInner(true, GET_PID_UID, data, reply, option);
}
void IPCObjectProxy::OnFirstStrongRef(const void *objectId)
{
// IPC proxy: AcquireHandle->AttachObject

View File

@ -327,10 +327,16 @@ int IPCObjectStub::DBinderGetSessionNameForPidUid(uint32_t code,
int IPCObjectStub::DBinderGetPidUid(uint32_t code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
if (!IPCSkeleton::IsLocalCalling()) {
if (!IPCSkeleton::IsLocalCalling() || !IsSamgrCall()) {
ZLOGE(LABEL, "GET_PID_UID message is not from sa manager");
return IPC_STUB_INVALID_DATA_ERR;
}
return GetPidUid(data, reply);
if (!reply.WriteUint32(getpid()) || !reply.WriteUint32(getuid())) {
ZLOGE(LABEL, "write to parcel fail");
return IPC_STUB_INVALID_DATA_ERR;
}
return ERR_NONE;
}
int IPCObjectStub::DBinderRemoveSessionName(uint32_t code,
@ -698,15 +704,6 @@ int32_t IPCObjectStub::GetSessionNameForPidUid(uint32_t code, MessageParcel &dat
return ERR_NONE;
}
int IPCObjectStub::GetPidUid(MessageParcel &data, MessageParcel &reply)
{
if (!reply.WriteUint32(getpid()) || !reply.WriteUint32(getuid())) {
ZLOGE(LABEL, "write to parcel fail");
return IPC_STUB_INVALID_DATA_ERR;
}
return ERR_NONE;
}
std::string IPCObjectStub::CreateSessionName(int uid, int pid)
{
std::string sessionName = DBINDER_SOCKET_NAME_PREFIX +

View File

@ -143,19 +143,6 @@ HWTEST_F(IPCObjectProxyTest, GetSessionNameForPidUidTest001, TestSize.Level1)
ASSERT_TRUE(ret.size() == 0);
}
/**
* @tc.name: GetPidUidTest001
* @tc.desc: Verify the IPCObjectProxy::GetPidUid function
* @tc.type: FUNC
*/
HWTEST_F(IPCObjectProxyTest, GetPidUidTest001, TestSize.Level1)
{
IPCObjectProxy object(1);
MessageParcel reply;
auto ret = object.GetPidUid(reply);
ASSERT_TRUE(ret != 0);
}
/**
* @tc.name: GetInterfaceDescriptorTest001
* @tc.desc: Verify the IPCObjectProxy::GetInterfaceDescriptor function