!2266 toberemove 添加id限制

Merge pull request !2266 from xuqian0131/ToBeRemove
This commit is contained in:
openharmony_ci 2024-11-14 02:23:04 +00:00 committed by Gitee
commit c5b2058ed3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

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;