提交 a5da7c3c 编写于 作者: Y yangguangzhao

Rpc use dynamic permission

Signed-off-by: Nyangguangzhao <yangguangzhao1@huawei.com>
上级 f2e814a3
......@@ -117,6 +117,7 @@ public:
bool DetachBusNameObject(IPCObjectProxy *proxy);
std::string CreateDatabusName(int uid, int pid);
bool DetachProxyObject(binder_uintptr_t binderObject);
std::string QueryBusNameObject(IPCObjectProxy *proxy);
private:
static std::shared_ptr<DBinderRemoteListener> GetRemoteListener();
......@@ -157,7 +158,6 @@ private:
std::string &remoteDeviceId, int pid, int uid);
bool IsDeviceIdIllegal(const std::string &deviceID);
bool AttachBusNameObject(IPCObjectProxy *proxy, const std::string &name);
std::string QueryBusNameObject(IPCObjectProxy *proxy);
std::string GetDatabusNameByProxy(IPCObjectProxy *proxy);
uint32_t GetSeqNumber();
bool RegisterRemoteProxyInner(std::u16string serviceName, binder_uintptr_t binder);
......
......@@ -16,9 +16,12 @@
#include "dbinder_sa_death_recipient.h"
#include "dbinder_service.h"
#include "dbinder_log.h"
#include "ISessionService.h"
#include "log_tags.h"
namespace OHOS {
using Communication::SoftBus::ISessionService;
#ifndef TITLE
#define TITLE __PRETTY_FUNCTION__
#endif
......@@ -51,5 +54,17 @@ void DbinderSaDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
(void)dBinderService->DetachBusNameObject(proxy);
(void)dBinderService->DetachProxyObject(binderObject_);
std::shared_ptr<ISessionService> softbusManager = ISessionService::GetInstance();
if (softbusManager == nullptr) {
DBINDER_LOGE("fail to get softbus service");
return;
}
std::string sessionName = dBinderService->QueryBusNameObject(proxy);
if (sessionName.empty()) {
DBINDER_LOGE("proxy sessionName not found");
return;
}
softbusManager->RemovePermission(sessionName);
}
} // namespace OHOS
......@@ -39,6 +39,13 @@ bool DBinderRemoteListener::StartListener(std::shared_ptr<DBinderRemoteListener>
DBINDER_LOGE("fail to get softbus service");
return false;
}
int pid = static_cast<int>(getpid());
int uid = static_cast<int>(getuid());
if (softbusManager_->GrantPermission(uid, pid, OWN_SESSION_NAME) != ERR_NONE) {
DBINDER_LOGE("fail to Grant Permission softbus name %{public}s", OWN_SESSION_NAME.c_str());
return false;
}
int ret = softbusManager_->CreateSessionServer(OWN_SESSION_NAME, PEER_SESSION_NAME, listener);
if (ret != 0) {
DBINDER_LOGE("fail to create softbus server with ret = %{public}d", ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册