add check id tobeRemove

Signed-off-by: xuqian <xuqian65@huawei.com>
This commit is contained in:
xuqian 2024-11-12 21:43:19 +08:00
parent 2f13af0102
commit 02b1d328fb

View File

@ -1155,6 +1155,14 @@ ErrCode OsAccountManagerService::GetBackgroundOsAccountLocalIds(std::vector<int3
ErrCode OsAccountManagerService::SetOsAccountToBeRemoved(int32_t localId, bool toBeRemoved)
{
ErrCode res = CheckLocalId(localId);
if (res != ERR_OK) {
return res;
}
if ((localId == Constants::START_USER_ID) || (localId == Constants::ADMIN_LOCAL_ID)) {
ACCOUNT_LOGE("Cannot remove system preinstalled user.");
return ERR_OSACCOUNT_SERVICE_MANAGER_ID_ERROR;
}
if (!PermissionCheck(MANAGE_LOCAL_ACCOUNTS, "")) {
ACCOUNT_LOGE("Permission denied.");
return ERR_ACCOUNT_COMMON_PERMISSION_DENIED;