mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
敏感信息打印+变量上锁
Signed-off-by: 17333770736 <jiatuo@huawei.com>
This commit is contained in:
parent
2701b8f499
commit
499355e138
@ -71,7 +71,7 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath)
|
|||||||
char path[PATH_MAX + 1] = { 0 };
|
char path[PATH_MAX + 1] = { 0 };
|
||||||
if (inFilePath.empty() || inFilePath.length() > PATH_MAX || inFilePath.length() + 1 > MAX_CONFIG_PATH_LEN ||
|
if (inFilePath.empty() || inFilePath.length() > PATH_MAX || inFilePath.length() + 1 > MAX_CONFIG_PATH_LEN ||
|
||||||
realpath(inFilePath.c_str(), path) == nullptr) {
|
realpath(inFilePath.c_str(), path) == nullptr) {
|
||||||
HILOGE("Get continue config file real path fail, inFilePath %{public}s.", inFilePath.c_str());
|
HILOGE("Get continue config file real path fail, inFilePath %{public}s.", GetAnonymStr(inFilePath).c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +81,11 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!std::filesystem::exists(realFilePath)) {
|
if (!std::filesystem::exists(realFilePath)) {
|
||||||
HILOGE("The real file path %{public}s does not exist in the file system.", realFilePath.c_str());
|
HILOGE("The real file path %{public}s does not exist in the file system.", GetAnonymStr(realFilePath).c_str());
|
||||||
realFilePath = "";
|
realFilePath = "";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HILOGI("The real file path %{public}s exist in the file system.", realFilePath.c_str());
|
HILOGI("The real file path %{public}s exist in the file system.", GetAnonymStr(realFilePath).c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,37 +132,38 @@ bool UpdateAllowAppList(const std::string &cfgJsonStr)
|
|||||||
int32_t LoadContinueConfig()
|
int32_t LoadContinueConfig()
|
||||||
{
|
{
|
||||||
HILOGI("Load continue config, isMissContinueCfg %{public}d, ContinueCfgFullPath %{public}s.",
|
HILOGI("Load continue config, isMissContinueCfg %{public}d, ContinueCfgFullPath %{public}s.",
|
||||||
g_isMissContinueCfg.load(), g_continueCfgFullPath.c_str());
|
g_isMissContinueCfg.load(), GetAnonymStr(g_continueCfgFullPath).c_str());
|
||||||
std::string tempPath = g_continueCfgFullPath;
|
std::string tempPath = g_continueCfgFullPath;
|
||||||
if (!g_isMissContinueCfg.load() &&
|
if (!g_isMissContinueCfg.load() &&
|
||||||
(g_continueCfgFullPath.empty() || !IsValidPath(tempPath, g_continueCfgFullPath))) {
|
(g_continueCfgFullPath.empty() || !IsValidPath(tempPath, g_continueCfgFullPath))) {
|
||||||
char cfgPathBuf[MAX_CONFIG_PATH_LEN] = { 0 };
|
char cfgPathBuf[MAX_CONFIG_PATH_LEN] = { 0 };
|
||||||
char *filePath = GetOneCfgFile(CONTINUE_CONFIG_RELATIVE_PATH.c_str(), cfgPathBuf, MAX_CONFIG_PATH_LEN);
|
char *filePath = GetOneCfgFile(CONTINUE_CONFIG_RELATIVE_PATH.c_str(), cfgPathBuf, MAX_CONFIG_PATH_LEN);
|
||||||
if (filePath == nullptr || filePath != cfgPathBuf) {
|
if (filePath == nullptr || filePath != cfgPathBuf) {
|
||||||
HILOGI("Not find continue config file, relative path %{public}s.", CONTINUE_CONFIG_RELATIVE_PATH.c_str());
|
HILOGI("Not find continue config file, relative path %{public}s.",
|
||||||
|
GetAnonymStr(CONTINUE_CONFIG_RELATIVE_PATH).c_str());
|
||||||
g_isMissContinueCfg.store(true);
|
g_isMissContinueCfg.store(true);
|
||||||
g_continueCfgFullPath = "";
|
g_continueCfgFullPath = "";
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
g_isMissContinueCfg.store(false);
|
g_isMissContinueCfg.store(false);
|
||||||
g_continueCfgFullPath = std::string(filePath);
|
g_continueCfgFullPath = std::string(filePath);
|
||||||
HILOGI("Get Continue config file full path success, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str());
|
HILOGI("Get Continue config file full path success, cfgFullPath %{public}s.",
|
||||||
|
GetAnonymStr(g_continueCfgFullPath).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_isMissContinueCfg.load()) {
|
if (g_isMissContinueCfg.load()) {
|
||||||
HILOGI("Current device does not carry continue config file.");
|
HILOGI("Current device does not carry continue config file.");
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempPath = g_continueCfgFullPath;
|
tempPath = g_continueCfgFullPath;
|
||||||
|
std::string anonymPath = GetAnonymStr(g_continueCfgFullPath);
|
||||||
if (!IsValidPath(tempPath, g_continueCfgFullPath)) {
|
if (!IsValidPath(tempPath, g_continueCfgFullPath)) {
|
||||||
HILOGE("Continue config full path is invalid, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str());
|
HILOGE("Continue config full path is invalid, cfgFullPath %{public}s.", anonymPath.c_str());
|
||||||
return DMS_PERMISSION_DENIED;
|
return DMS_PERMISSION_DENIED;
|
||||||
}
|
}
|
||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
in.open(g_continueCfgFullPath.c_str(), std::ios::binary | std::ios::in);
|
in.open(g_continueCfgFullPath.c_str(), std::ios::binary | std::ios::in);
|
||||||
if (!in.is_open()) {
|
if (!in.is_open()) {
|
||||||
HILOGE("Open continue config json file fail, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str());
|
HILOGE("Open continue config json file fail, cfgFullPath %{public}s.", anonymPath.c_str());
|
||||||
return DMS_PERMISSION_DENIED;
|
return DMS_PERMISSION_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,11 +175,11 @@ int32_t LoadContinueConfig()
|
|||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
if (!UpdateAllowAppList(cfgFileContent)) {
|
if (!UpdateAllowAppList(cfgFileContent)) {
|
||||||
HILOGE("Update allow app list fail, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str());
|
HILOGE("Update allow app list fail, cfgFullPath %{public}s.", anonymPath.c_str());
|
||||||
return DMS_PERMISSION_DENIED;
|
return DMS_PERMISSION_DENIED;
|
||||||
}
|
}
|
||||||
HILOGI("Load continue config success, isMissContinueCfg %{public}d, cfgFullPath %{public}s.",
|
HILOGI("Load continue config success, isMissContinueCfg %{public}d, cfgFullPath %{public}s.",
|
||||||
g_isMissContinueCfg.load(), g_continueCfgFullPath.c_str());
|
g_isMissContinueCfg.load(), anonymPath.c_str());
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,12 +194,12 @@ bool CheckBundleContinueConfig(const std::string &bundleName)
|
|||||||
auto it = std::find(g_allowAppList.begin(), g_allowAppList.end(), bundleName);
|
auto it = std::find(g_allowAppList.begin(), g_allowAppList.end(), bundleName);
|
||||||
if (it == g_allowAppList.end()) {
|
if (it == g_allowAppList.end()) {
|
||||||
HILOGE("Current app is not allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.",
|
HILOGE("Current app is not allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.",
|
||||||
bundleName.c_str(), g_continueCfgFullPath.c_str());
|
bundleName.c_str(), GetAnonymStr(g_continueCfgFullPath).c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HILOGI("Current app is allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.",
|
HILOGI("Current app is allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.",
|
||||||
bundleName.c_str(), g_continueCfgFullPath.c_str());
|
bundleName.c_str(), GetAnonymStr(g_continueCfgFullPath).c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ private:
|
|||||||
std::thread eventThread_;
|
std::thread eventThread_;
|
||||||
std::condition_variable eventCon_;
|
std::condition_variable eventCon_;
|
||||||
std::mutex eventMutex_;
|
std::mutex eventMutex_;
|
||||||
|
std::mutex softbusAdapterListenerMutex_;
|
||||||
std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler_ = nullptr;
|
std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler_ = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace DistributedSchedule
|
} // namespace DistributedSchedule
|
||||||
|
@ -93,14 +93,16 @@ int32_t DSchedAllConnectManager::GetServiceCollaborationManagerProxy()
|
|||||||
#endif
|
#endif
|
||||||
char path[PATH_MAX + 1] = {0};
|
char path[PATH_MAX + 1] = {0};
|
||||||
if (resolvedPath.length() > PATH_MAX || realpath(resolvedPath.c_str(), path) == nullptr) {
|
if (resolvedPath.length() > PATH_MAX || realpath(resolvedPath.c_str(), path) == nullptr) {
|
||||||
HILOGE("Check all connect so real path failed, resolvedPath [%{public}s].", resolvedPath.c_str());
|
HILOGE("Check all connect so real path failed, resolvedPath [%{public}s].",
|
||||||
|
GetAnonymStr(resolvedPath).c_str());
|
||||||
return INVALID_PARAMETERS_ERR;
|
return INVALID_PARAMETERS_ERR;
|
||||||
}
|
}
|
||||||
int32_t (*ServiceCollaborationManagerExport)(ServiceCollaborationManager_API *exportapi) = nullptr;
|
int32_t (*ServiceCollaborationManagerExport)(ServiceCollaborationManager_API *exportapi) = nullptr;
|
||||||
|
|
||||||
dllHandle_ = dlopen(resolvedPath.c_str(), RTLD_LAZY);
|
dllHandle_ = dlopen(resolvedPath.c_str(), RTLD_LAZY);
|
||||||
if (dllHandle_ == nullptr) {
|
if (dllHandle_ == nullptr) {
|
||||||
HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].", resolvedPath.c_str());
|
HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].",
|
||||||
|
GetAnonymStr(resolvedPath).c_str());
|
||||||
return NOT_FIND_SERVICE_REGISTRY;
|
return NOT_FIND_SERVICE_REGISTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,10 @@ int32_t SoftbusAdapter::RegisterSoftbusEventListener(const std::shared_ptr<Softb
|
|||||||
HILOGE("Registering listener failed");
|
HILOGE("Registering listener failed");
|
||||||
return SOFTBUS_INVALID_PARAM;
|
return SOFTBUS_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
softbusAdapterListener_ = listener;
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(softbusAdapterListenerMutex_);
|
||||||
|
softbusAdapterListener_ = listener;
|
||||||
|
}
|
||||||
EventListener eventListener;
|
EventListener eventListener;
|
||||||
eventListener.event = FOREGROUND_APP;
|
eventListener.event = FOREGROUND_APP;
|
||||||
eventListener.freq = EVENT_MID_FREQ;
|
eventListener.freq = EVENT_MID_FREQ;
|
||||||
@ -195,7 +198,10 @@ int32_t SoftbusAdapter::UnregisterSoftbusEventListener(const std::shared_ptr<Sof
|
|||||||
HILOGE("Unregistering listener failed");
|
HILOGE("Unregistering listener failed");
|
||||||
return SOFTBUS_INVALID_PARAM;
|
return SOFTBUS_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
softbusAdapterListener_ = listener;
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(softbusAdapterListenerMutex_);
|
||||||
|
softbusAdapterListener_ = listener;
|
||||||
|
}
|
||||||
EventListener eventListener;
|
EventListener eventListener;
|
||||||
eventListener.event = FOREGROUND_APP;
|
eventListener.event = FOREGROUND_APP;
|
||||||
eventListener.freq = EVENT_MID_FREQ;
|
eventListener.freq = EVENT_MID_FREQ;
|
||||||
|
Loading…
Reference in New Issue
Block a user