storage_service告警清理

Signed-off-by: lvyuanyuan <lvyuanyuan7@huawei.com>
Change-Id: I40ab0ee18295662edf9c6c6921c1fa9652f5b959
This commit is contained in:
lvyuanyuan 2024-05-29 09:43:14 +08:00
parent baed925225
commit 6d8c3f8f9b
7 changed files with 11 additions and 22 deletions

View File

@ -440,7 +440,7 @@ bool BaseKey::DoRestoreKey(const UserAuth &auth, const std::string &path)
if (!auth.secret.IsEmpty() && FileExists(NEED_UPDATE_PATH)) {
keyEncryptType_ = KeyEncryptType::KEY_CRYPT_OPENSSL;
LOGI("set keyEncryptType_ as KEY_CRYPT_OPENSSL success");
} else if (auth.secret.IsEmpty() || (!auth.secret.IsEmpty() && !FileExists(NEED_UPDATE_PATH))) {
} else {
keyEncryptType_ = KeyEncryptType::KEY_CRYPT_HUKS;
LOGI("set keyEncryptType_ as KEY_CRYPT_HUKS success");
}

View File

@ -547,7 +547,6 @@ int KeyManager::DoDeleteUserCeEceSeceKeys(unsigned int user,
std::map<unsigned int, std::shared_ptr<BaseKey>> &userElKey_)
{
int ret = 0;
std::string elPath;
auto it = userElKey_.find(user);
if (it != userElKey_.end()) {
auto elKey = it->second;
@ -555,7 +554,7 @@ int KeyManager::DoDeleteUserCeEceSeceKeys(unsigned int user,
userElKey_.erase(user);
saveLockScreenStatus.erase(user);
} else {
elPath = USER_DIR + "/" + std::to_string(user);
std::string elPath = USER_DIR + "/" + std::to_string(user);
std::shared_ptr<BaseKey> elKey = GetBaseKey(elPath);
if (elKey == nullptr) {
LOGE("Malloc el1 Basekey memory failed");
@ -575,22 +574,18 @@ int KeyManager::DoDeleteUserKeys(unsigned int user)
ret = DoDeleteUserCeEceSeceKeys(user, USER_EL1_DIR, userEl1Key_);
if (ret != 0) {
LOGE("Delete el1 key failed");
ret = -EFAULT;
}
ret = DoDeleteUserCeEceSeceKeys(user, USER_EL2_DIR, userEl2Key_);
if (ret != 0) {
LOGE("Delete el2 key failed");
ret = -EFAULT;
}
ret = DoDeleteUserCeEceSeceKeys(user, USER_EL3_DIR, userEl3Key_);
if (ret != 0) {
LOGE("Delete el3 key failed");
ret = -EFAULT;
}
ret = DoDeleteUserCeEceSeceKeys(user, USER_EL4_DIR, userEl4Key_);
if (ret != 0) {
LOGE("Delete el4 key failed");
ret = -EFAULT;
}
ret = DoDeleteUserCeEceSeceKeys(user, USER_EL5_DIR, userEl5Key_);
if (ret != 0) {

View File

@ -188,9 +188,7 @@ std::string StorageDaemon::GetNeedRestoreFilePathByType(int32_t userId, KeyType
int32_t StorageDaemon::RestoreUserOneKey(int32_t userId, KeyType type)
{
uint32_t flags = 0;
int32_t ret;
ret = GetCryptoFlag(type, flags);
int32_t ret = GetCryptoFlag(type, flags);
if (ret != E_OK) {
return ret;
}
@ -230,8 +228,6 @@ int32_t StorageDaemon::RestoreUserOneKey(int32_t userId, KeyType type)
int32_t StorageDaemon::RestoreUserKey(int32_t userId, uint32_t flags)
{
LOGI("prepare restore user dirs for %{public}d, flags %{public}u", userId, flags);
int32_t ret = E_OK;
if (!IsNeedRestorePathExist(userId, true)) {
LOGE("need_restore file is not existed");
return -EEXIST;
@ -239,7 +235,7 @@ int32_t StorageDaemon::RestoreUserKey(int32_t userId, uint32_t flags)
std::vector<KeyType> type = {EL1_KEY, EL2_KEY, EL3_KEY, EL4_KEY, EL5_KEY};
for (unsigned long i = 0; i < type.size(); i++) {
ret = RestoreUserOneKey(userId, type[i]);
auto ret = RestoreUserOneKey(userId, type[i]);
if (ret != E_OK) {
return ret;
}

View File

@ -441,13 +441,12 @@ int LoadAndSetEceAndSecePolicy(const char *keyDir, const char *dir, int type)
return -EINVAL;
}
char *pathBuf = NULL;
int ret = -ENOTSUP;
ret = SpliceKeyPath(keyDir, strlen(keyDir), PATH_KEYDESC, strlen(PATH_KEYDESC), &pathBuf);
int ret = SpliceKeyPath(keyDir, strlen(keyDir), PATH_KEYDESC, strlen(PATH_KEYDESC), &pathBuf);
if (ret != 0) {
FSCRYPT_LOGE("path splice error");
return ret;
}
uint8_t fscryptVer = KeyCtrlLoadVersion(keyDir);
if (fscryptVer == FSCRYPT_V1) {
if (type == el3Key || type == el4Key) {

View File

@ -75,10 +75,9 @@ ssize_t UeventKernelMulticastRecv(int32_t socket, char *buffer, size_t length)
void NetlinkListener::RecvUeventMsg()
{
auto msg = std::make_unique<char[]>(UEVENT_MSG_LEN + 1);
ssize_t count;
while (1) {
count = UeventKernelMulticastRecv(socketFd_, msg.get(), UEVENT_MSG_LEN);
auto count = UeventKernelMulticastRecv(socketFd_, msg.get(), UEVENT_MSG_LEN);
if (count <= 0) {
(void)memset_s(msg.get(), UEVENT_MSG_LEN + 1, 0, UEVENT_MSG_LEN + 1);
break;

View File

@ -215,7 +215,7 @@ void StorageTestUtils::RmDir(const int32_t userId)
"/data/chipset/el2/",
"/storage/media/"
};
std::string cmd;
for (auto path : paths) {
path.append(std::to_string(userId));
RmDirRecurse(path);
@ -224,14 +224,14 @@ void StorageTestUtils::RmDir(const int32_t userId)
void StorageTestUtils::ClearTestResource()
{
int32_t userIds[] = {
const int32_t userIds[] = {
USER_ID1,
USER_ID2,
USER_ID3,
USER_ID4,
USER_ID5
};
for (auto id : userIds) {
for (const auto id : userIds) {
std::string dstPath(hmdfsTarget);
dstPath.replace(dstPath.find("%d"), strlen("%d"), std::to_string(id));
UMount(dstPath);

View File

@ -20,7 +20,7 @@
namespace OHOS {
bool FileUtilFuzzTest(const uint8_t *data, size_t size)
{
if ((data == nullptr) || (size <= 0)) {
if ((data == nullptr) || (size == 0)) {
return false;
}
Parcel parcel;