diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index 1af5c262ec5fb0ab85cde48a190b37e35e062e35..9c4ef44896778f48bf6a33b0bdd453f96e8d701b 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -193,7 +193,7 @@ static UniqueFd GetFileHandleForSpecialCloneCloud(const string &fileName) size_t filePathPrefix = filePath.find_last_of(BConstants::FILE_SEPARATOR_CHAR); if (filePathPrefix == string::npos) { HILOGE("GetFileHandleForSpecialCloneCloud: Invalid fileName"); - AuditLog auditLog = {false, "Open fd failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "Open fd failed", "ADD", "", 1, "FAILED", "GetFileHandleForSpecialCloneCloud", "CommonFile", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return UniqueFd(-1); @@ -203,7 +203,7 @@ static UniqueFd GetFileHandleForSpecialCloneCloud(const string &fileName) bool created = ForceCreateDirectory(path.data()); if (!created) { HILOGE("Failed to create restore folder."); - AuditLog auditLog = {false, "ForceCreateDirectory failed", "ADD", "DataClone in special scenario", 1, + AuditLog auditLog = {false, "ForceCreateDirectory failed", "ADD", "", 1, "FAILED", "GetFileHandleForSpecialCloneCloud", "CommonFile", GetAnonyPath(path)}; HiAudit::GetInstance(false).Write(auditLog); return UniqueFd(-1); @@ -212,7 +212,7 @@ static UniqueFd GetFileHandleForSpecialCloneCloud(const string &fileName) UniqueFd fd(open(fileName.data(), O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)); if (fd < 0) { HILOGE("Open file failed, file name is %{private}s, err = %{public}d", fileName.data(), errno); - AuditLog auditLog = {false, "open fd failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "open fd failed", "ADD", "", 1, "FAILED", "GetFileHandleForSpecialCloneCloud", "CommonFile", GetAnonyPath(fileName)}; HiAudit::GetInstance(false).Write(auditLog); return UniqueFd(-1); @@ -279,7 +279,7 @@ static ErrCode GetIncreFileHandleForSpecialVersion(const string &fileName) UniqueFd fd = GetFileHandleForSpecialCloneCloud(fileName); if (fd < 0) { HILOGE("Failed to open file = %{private}s, err = %{public}d", fileName.c_str(), errno); - AuditLog auditLog = {false, "Open fd failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "Open fd failed", "ADD", "", 1, "FAILED", "GetIncreFileHandleForSpecialVersion", "CommonFile", GetAnonyPath(fileName)}; HiAudit::GetInstance(false).Write(auditLog); errCode = errno; @@ -289,7 +289,7 @@ static ErrCode GetIncreFileHandleForSpecialVersion(const string &fileName) if (mkdir(path.data(), S_IRWXU) && errno != EEXIST) { HILOGE("Failed to create restore folder : %{private}s, err = %{public}d", path.c_str(), errno); errCode = errno; - AuditLog auditLog = {false, "mkdir failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "mkdir failed", "ADD", "", 1, "FAILED", "GetIncreFileHandleForSpecialVersion", "CommonFile", GetAnonyPath(path)}; HiAudit::GetInstance(false).Write(auditLog); } @@ -349,7 +349,7 @@ ErrCode BackupExtExtension::GetIncreFileHandleForNormalVersion(const std::string if (fd < 0) { HILOGE("Failed to open tar file = %{public}s, err = %{public}d", GetAnonyPath(tarName).c_str(), errno); errCode = errno; - AuditLog auditLog = {false, "Open fd failed", "ADD", "DataClone", 1, "FAILED", + AuditLog auditLog = {false, "Open fd failed", "ADD", "", 1, "FAILED", "GetIncreFileHandleForNormalVersion", "CommonFile", GetAnonyPath(tarName)}; HiAudit::GetInstance(false).Write(auditLog); } @@ -432,7 +432,7 @@ static ErrCode IndexFileReady(const TarMap &pkgInfo, sptr proxy) UniqueFd fd(open(INDEX_FILE_BACKUP.data(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)); if (fd < 0) { HILOGE("Failed to open index json file = %{private}s, err = %{public}d", INDEX_FILE_BACKUP.c_str(), errno); - AuditLog auditLog = {false, "Open fd failed", "ADD", "DataClone", 1, "FAILED", "Backup File", + AuditLog auditLog = {false, "Open fd failed", "ADD", "", 1, "FAILED", "Backup File", "IndexFileReady", GetAnonyPath(INDEX_FILE_BACKUP)}; HiAudit::GetInstance(false).Write(auditLog); return BError::GetCodeByErrno(errno); @@ -474,7 +474,7 @@ ErrCode BackupExtExtension::BigFileReady(const TarMap &bigFileInfo, sptr proxy) if (fd < 0) { HILOGE("TarFileReady open file failed, file name is %{public}s, err = %{public}d", tarName.c_str(), errno); errCode = errno; - AuditLog auditLog = {false, "Open fd failed", "ADD", "DataClone", 1, "FAILED", + AuditLog auditLog = {false, "Open fd failed", "ADD", "", 1, "FAILED", "TarFileReady", "tarFile", tarPath}; HiAudit::GetInstance(false).Write(auditLog); } @@ -972,7 +972,7 @@ void BackupExtExtension::RestoreBigFilesForSpecialCloneCloud(const ExtManageInfo } if (chmod(fileName.c_str(), sta.st_mode) != 0) { HILOGE("Failed to chmod filePath, err = %{public}d", errno); - AuditLog auditLog = {false, "chmod file failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "chmod file failed", "ADD", "", 1, "FAILED", "RestoreBigFilesForSpecialCloneCloud", "CommonFile", GetAnonyPath(fileName)}; HiAudit::GetInstance(false).Write(auditLog); errFileInfos_[fileName].push_back(errno); @@ -983,7 +983,7 @@ void BackupExtExtension::RestoreBigFilesForSpecialCloneCloud(const ExtManageInfo if (fd < 0) { HILOGE("Failed to open file = %{public}s, err = %{public}d", GetAnonyPath(fileName).c_str(), errno); errFileInfos_[fileName].push_back(errno); - AuditLog auditLog = {false, "open fd failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "open fd failed", "ADD", "", 1, "FAILED", "RestoreBigFilesForSpecialCloneCloud", "CommonFile", GetAnonyPath(fileName)}; HiAudit::GetInstance(false).Write(auditLog); return; @@ -1113,7 +1113,7 @@ void BackupExtExtension::RestoreBigFileAfter(const string &filePath, const struc if (fd < 0) { errFileInfos_[filePath].push_back(errno); HILOGE("Failed to open file = %{public}s, err = %{public}d", GetAnonyPath(filePath).c_str(), errno); - AuditLog auditLog = {false, "open fd failed", "ADD", "DataClone in special scenario", 1, "FAILED", + AuditLog auditLog = {false, "open fd failed", "ADD", "", 1, "FAILED", "RestoreBigFileAfter", "CommonFile", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return; @@ -1137,7 +1137,7 @@ void BackupExtExtension::RestoreOneBigFile(const std::string &path, if (fd < 0) { HILOGE("Failed to open report file = %{public}s, err = %{public}d", reportPath.c_str(), errno); errFileInfos_[item.hashName].push_back(errno); - AuditLog auditLog = {false, "Open fd failed", "ADD", "DataClone", 1, "FAILED", "RestoreOneBigFile", + AuditLog auditLog = {false, "Open fd failed", "ADD", "", 1, "FAILED", "RestoreOneBigFile", "RestoreOneBigFile", GetAnonyPath(reportPath)}; HiAudit::GetInstance(false).Write(auditLog); throw BError(BError::Codes::EXT_INVAL_ARG, string("open report file failed")); @@ -1149,7 +1149,7 @@ void BackupExtExtension::RestoreOneBigFile(const std::string &path, string filePath = appendTargetPath ? (path + itemFileName) : itemFileName; if (BDir::CheckFilePathInvalid(filePath)) { HILOGE("Check big file path : %{public}s err, path is forbidden", GetAnonyPath(filePath).c_str()); - AuditLog auditLog = {false, "Check file path", "ADD", "DataClone", 1, "FAILED", "CheckFilePathInvalid", + AuditLog auditLog = {false, "Check file path", "ADD", "", 1, "FAILED", "CheckFilePathInvalid", "RestoreOneBigFile", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return; @@ -1164,7 +1164,7 @@ void BackupExtExtension::RestoreOneBigFile(const std::string &path, if (!BFile::MoveFile(fileName, filePath)) { errFileInfos_[filePath].push_back(errno); HILOGE("failed to move the file. err = %{public}d", errno); - AuditLog auditLog = {false, "Move file failed", "ADD", "DataClone", 1, "FAILED", "MoveFile", + AuditLog auditLog = {false, "Move file failed", "ADD", "", 1, "FAILED", "MoveFile", "RestoreOneBigFile", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return; diff --git a/frameworks/native/backup_ext/src/tar_file.cpp b/frameworks/native/backup_ext/src/tar_file.cpp index ab9ab332aaceaeefefaf29d78629efe41af394fc..e340e9b49d7593a33672a83c071ae563c9c32785 100644 --- a/frameworks/native/backup_ext/src/tar_file.cpp +++ b/frameworks/native/backup_ext/src/tar_file.cpp @@ -106,7 +106,7 @@ bool TarFile::TraversalFile(string &filePath, int &err) if (access(filePath.c_str(), F_OK) != 0) { err = errno; HILOGE("File path does not exists, err = %{public}d", errno); - AuditLog auditLog = {false, "access file failed", "ADD", "DataClone", 1, "FAILED", "TraversalFile", + AuditLog auditLog = {false, "access file failed", "ADD", "", 1, "FAILED", "TraversalFile", "Packet File", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return false; @@ -121,14 +121,14 @@ bool TarFile::TraversalFile(string &filePath, int &err) if (lstat(filePath.c_str(), &curFileStat) != 0) { err = errno; HILOGE("Failed to lstat, err = %{public}d", errno); - AuditLog auditLog = {false, "lstat file failed", "ADD", "DataClone", 1, "FAILED", "TraversalFile", + AuditLog auditLog = {false, "lstat file failed", "ADD", "", 1, "FAILED", "TraversalFile", "Packet File", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return false; } if (!AddFile(filePath, curFileStat, err)) { HILOGE("Failed to add file to tar package, file path is:%{public}s", GetAnonyPath(filePath).c_str()); - AuditLog auditLog = {false, "AddFile failed", "ADD", "DataClone", 1, "FAILED", "TraversalFile", + AuditLog auditLog = {false, "AddFile failed", "ADD", "", 1, "FAILED", "TraversalFile", "Packet File", GetAnonyPath(filePath)}; HiAudit::GetInstance(false).Write(auditLog); return false; @@ -316,7 +316,7 @@ bool TarFile::WriteFileContent(const string &fileName, off_t size, int &err) { int fd = open(fileName.c_str(), O_RDONLY | O_CLOEXEC); if (fd < 0) { - AuditLog auditLog = {false, "open fd failed", "ADD", "DataClone", 1, "FAILED", "WriteFileContent", + AuditLog auditLog = {false, "open fd failed", "ADD", "", 1, "FAILED", "WriteFileContent", "Packet File", GetAnonyPath(fileName)}; HiAudit::GetInstance(false).Write(auditLog); err = errno; diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index 66b775c401cfe6afe883ce73f90e8fef320f8061..e1f415e89dfa100823f36734360d015f3d1f25f8 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -342,7 +342,7 @@ vector BundleMgrAdapter::GetBundleInfosForIncrement vector bundleNames; vector bundleInfos; - HILOGI("Begin get bundle infos"); + HILOGI("End get installedBundles count is:%{public}zu", installedBundles.size()); for (auto const &installedBundle : installedBundles) { if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { @@ -385,14 +385,15 @@ vector BundleMgrAdapter::GetFullBundleInfos(int32_t } vector bundleNames; vector bundleInfos; + HILOGI("End get installedBundles count is:%{public}zu", installedBundles.size()); for (auto const &installedBundle : installedBundles) { - HILOGI("Begin get bundle infos, bundleName = %{public}s", installedBundle.name.data()); if (installedBundle.applicationInfo.codePath == HMOS_HAP_CODE_PATH || installedBundle.applicationInfo.codePath == LINUX_HAP_CODE_PATH) { HILOGI("Unsupported applications, name : %{public}s", installedBundle.name.data()); continue; } if (installedBundle.appIndex > 0) { + HILOGI("Current bundle %{public}s is a twin application", installedBundle.name.c_str()); std::string bundleNameIndexInfo = BJsonUtil::BuildBundleNameIndexInfo(installedBundle.name, installedBundle.appIndex); bundleNames.emplace_back(bundleNameIndexInfo); @@ -527,7 +528,8 @@ bool BundleMgrAdapter::IsUser0BundleName(std::string bundleName, int32_t userId) BJsonUtil::BundleDetailInfo bundleDetailInfo = BJsonUtil::ParseBundleNameIndexStr(bundleName); int32_t flags = static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) | static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) | - static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA); + static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA) | + static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION); ErrCode ret = bms->GetCloneBundleInfo(bundleDetailInfo.bundleName, flags, bundleDetailInfo.bundleIndex, installedBundle, userId); if (ret != ERR_OK) { diff --git a/services/backup_sa/src/module_ipc/service_incremental.cpp b/services/backup_sa/src/module_ipc/service_incremental.cpp index edf7ee1e605a9cf3245fe62dcebe41730500f202..67b0fbf7b077faf338a784111342bea2b25e9dad 100644 --- a/services/backup_sa/src/module_ipc/service_incremental.cpp +++ b/services/backup_sa/src/module_ipc/service_incremental.cpp @@ -436,7 +436,7 @@ ErrCode Service::AppIncrementalFileReady(const std::string &fileName, UniqueFd f HILOGD("reverse: Will notify IncrementalBackupOnFileReady"); session_->GetServiceReverseProxy()->IncrementalBackupOnFileReady(callerName, fileName, move(fd), move(manifestFd), errCode); - AuditLog auditLog = { false, "Backup File Ready", "ADD", "CloudDriver", 1, "SUCCESS", "AppIncrementalFileReady", + AuditLog auditLog = { false, "Backup File Ready", "ADD", "", 1, "SUCCESS", "AppIncrementalFileReady", callerName, GetAnonyPath(fileName) }; HiAudit::GetInstance(true).Write(auditLog); if (session_->OnBundleFileReady(callerName, fileName)) { diff --git a/services/backup_sa/src/module_ipc/sub_service.cpp b/services/backup_sa/src/module_ipc/sub_service.cpp index ce7203501efe8b39e2457d0e5904c0ea8b9d1e29..292403c8b0395a003b066d116c25f190c5ab0293 100644 --- a/services/backup_sa/src/module_ipc/sub_service.cpp +++ b/services/backup_sa/src/module_ipc/sub_service.cpp @@ -136,7 +136,7 @@ ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCo fd = session_->OnBundleExtManageInfo(callerName, move(fd)); } session_->GetServiceReverseProxy()->BackupOnFileReady(callerName, fileName, move(fd), errCode); - AuditLog auditLog = { false, "Backup File Ready", "ADD", "DataClone", 1, "SUCCESS", "AppFileReady", + AuditLog auditLog = { false, "Backup File Ready", "ADD", "", 1, "SUCCESS", "AppFileReady", callerName, GetAnonyPath(fileName) }; HiAudit::GetInstance(true).Write(auditLog); if (session_->OnBundleFileReady(callerName, fileName)) { diff --git a/services/backup_sa/src/module_ipc/svc_backup_connection.cpp b/services/backup_sa/src/module_ipc/svc_backup_connection.cpp index f9dc891c68e4e3a66a3c688717c2df9aab531e34..53413cc907d7a00e4cd04e6861db36ae5cd73fa4 100644 --- a/services/backup_sa/src/module_ipc/svc_backup_connection.cpp +++ b/services/backup_sa/src/module_ipc/svc_backup_connection.cpp @@ -47,7 +47,8 @@ void SvcBackupConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el } isConnected_.store(true); string bundleName = element.GetBundleName(); - HILOGI("%{public}s, OnAbilityConnectDone", bundleName.c_str()); + HILOGI("bundleName:%{public}s, OnAbilityConnectDone, bundleNameIndexInfo:%{public}s", bundleName.c_str(), + bundleNameIndexInfo_.c_str()); auto now = std::chrono::system_clock::now(); auto time = std::chrono::system_clock::to_time_t(now); auto ms = std::chrono::duration_cast(now.time_since_epoch()); @@ -68,7 +69,8 @@ void SvcBackupConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el bundleNameIndexInfo_.c_str(), bundleName.c_str()); return; } - callConnected_(move(bundleNameIndexInfo_)); + bundleName = bundleNameIndexInfo_; + callConnected_(move(bundleName)); HILOGI("called end"); } @@ -78,6 +80,14 @@ void SvcBackupConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName isConnected_.store(false); backupProxy_ = nullptr; string bundleName = element.GetBundleName(); + HILOGI("bundleName:%{public}s, OnAbilityDisconnectDone, bundleNameIndexInfo:%{public}s", bundleName.c_str(), + bundleNameIndexInfo_.c_str()); + if (bundleNameIndexInfo_.find(bundleName) == string::npos) { + HILOGE("Current bundle name is wrong, bundleNameIndexInfo:%{public}s, bundleName:%{public}s", + bundleNameIndexInfo_.c_str(), bundleName.c_str()); + return; + } + bundleName = bundleNameIndexInfo_; if (isConnectedDone_ == false) { isConnectedDone_.store(true); HILOGE("It's error that the backup extension dies before the backup sa. name : %{public}s", bundleName.data()); diff --git a/utils/src/b_jsonutil/b_jsonutil.cpp b/utils/src/b_jsonutil/b_jsonutil.cpp index 87e9bb10cdc287bebced2d868b7a6e8bebda4c81..9a2a790e5f42613d2c5c75c2da17768e6aef116f 100644 --- a/utils/src/b_jsonutil/b_jsonutil.cpp +++ b/utils/src/b_jsonutil/b_jsonutil.cpp @@ -35,7 +35,6 @@ namespace { BJsonUtil::BundleDetailInfo BJsonUtil::ParseBundleNameIndexStr(const std::string &bundleNameStr) { - HILOGI("Start parse bundle name and index"); size_t hasPos = bundleNameStr.find(BUNDLE_INDEX_SPLICE); BundleDetailInfo bundleDetailInfo; if (hasPos == std::string::npos) { @@ -52,7 +51,8 @@ BJsonUtil::BundleDetailInfo BJsonUtil::ParseBundleNameIndexStr(const std::string bundleDetailInfo.bundleIndex = BUNDLE_INDEX_DEFAULT_VAL; } bundleDetailInfo.bundleName = bundleName; - HILOGI("End parse bundle name and index"); + HILOGI("End parse bundle name and index, bundleName:%{public}s, index:%{public}d", + bundleDetailInfo.bundleName.c_str(), bundleDetailInfo.bundleIndex); return bundleDetailInfo; }