1686862fbSopenharmony_ci/* 2686862fbSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3686862fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4686862fbSopenharmony_ci * you may not use this file except in compliance with the License. 5686862fbSopenharmony_ci * You may obtain a copy of the License at 6686862fbSopenharmony_ci * 7686862fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8686862fbSopenharmony_ci * 9686862fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10686862fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11686862fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12686862fbSopenharmony_ci * See the License for the specific language governing permissions and 13686862fbSopenharmony_ci * limitations under the License. 14686862fbSopenharmony_ci */ 15686862fbSopenharmony_ci 16686862fbSopenharmony_ci#include "fuzz_util.h" 17686862fbSopenharmony_ci 18686862fbSopenharmony_ci#include "accesstoken_kit.h" 19686862fbSopenharmony_ci#include "nativetoken_kit.h" 20686862fbSopenharmony_ci#include "token_setproc.h" 21686862fbSopenharmony_ci 22686862fbSopenharmony_cinamespace OHOS { 23686862fbSopenharmony_cinamespace DistributedSchedule { 24686862fbSopenharmony_cinamespace { 25686862fbSopenharmony_ciconst char* DISTSCHED_PROCESS_NAME = "foundation"; 26686862fbSopenharmony_ci} 27686862fbSopenharmony_ci 28686862fbSopenharmony_civoid FuzzUtil::MockPermission() 29686862fbSopenharmony_ci{ 30686862fbSopenharmony_ci static const char *perms[] = { 31686862fbSopenharmony_ci "ohos.permission.DISTRIBUTED_DATASYNC" 32686862fbSopenharmony_ci }; 33686862fbSopenharmony_ci MockProcessAndPermission(DISTSCHED_PROCESS_NAME, perms, 1); 34686862fbSopenharmony_ci} 35686862fbSopenharmony_ci 36686862fbSopenharmony_civoid FuzzUtil::MockProcessAndPermission(const char* processName, const char *perms[], int32_t permsNum) 37686862fbSopenharmony_ci{ 38686862fbSopenharmony_ci uint64_t tokenId; 39686862fbSopenharmony_ci NativeTokenInfoParams infoInstance = { 40686862fbSopenharmony_ci .dcapsNum = 0, 41686862fbSopenharmony_ci .permsNum = permsNum, 42686862fbSopenharmony_ci .aclsNum = 0, 43686862fbSopenharmony_ci .dcaps = nullptr, 44686862fbSopenharmony_ci .perms = perms, 45686862fbSopenharmony_ci .acls = nullptr, 46686862fbSopenharmony_ci .processName = processName, 47686862fbSopenharmony_ci .aplStr = "system_core", 48686862fbSopenharmony_ci }; 49686862fbSopenharmony_ci tokenId = GetAccessTokenId(&infoInstance); 50686862fbSopenharmony_ci SetSelfTokenID(tokenId); 51686862fbSopenharmony_ci OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); 52686862fbSopenharmony_ci} 53686862fbSopenharmony_ci} 54686862fbSopenharmony_ci}