!1396 systemapi安全问题set接口整改

Merge pull request !1396 from lsl/lsl_systemapi_back
This commit is contained in:
openharmony_ci 2024-09-04 10:54:29 +00:00 committed by Gitee
commit 191e7f8d8a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 0 additions and 47 deletions

View File

@ -139,9 +139,7 @@ private:
static void GetConfigComplete(napi_env env, napi_status status, void* data);
static void GetConfigExecute(napi_env env, void* data);
static bool CheckReadPermission(const std::string &permission);
static bool CheckWritePermission(const std::string &permission);
static bool IsAvailable(napi_env env, napi_callback_info info);
static bool IsAvailableWrite(napi_env env, napi_callback_info info);
static void GetScreenTouchConfigExecute(NAccessibilityConfigData* callbackInfo);
static void EnableAbilityError(size_t& argc, OHOS::Accessibility::RetError& errCode,
napi_env env, napi_value* parameters, NAccessibilityConfigData* callbackInfo);

View File

@ -219,27 +219,6 @@ bool NAccessibilityConfig::CheckReadPermission(const std::string &permission)
return true;
}
bool NAccessibilityConfig::CheckWritePermission(const std::string &permission)
{
HILOG_DEBUG();
uint32_t tokenId = IPCSkeleton::GetCallingTokenID();
int result = TypePermissionState::PERMISSION_GRANTED;
ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(tokenId);
if (tokenType == TOKEN_INVALID) {
HILOG_WARN("AccessToken type invalid!");
return false;
} else {
result = AccessTokenKit::VerifyAccessToken(tokenId, permission);
}
if (result == TypePermissionState::PERMISSION_DENIED) {
HILOG_WARN("AccessTokenID denied!");
return false;
}
HILOG_DEBUG("tokenType %{private}d dAccessTokenID:%{private}u, permission:%{private}s matched!",
tokenType, tokenId, permission.c_str());
return true;
}
bool NAccessibilityConfig::IsAvailable(napi_env env, napi_callback_info info)
{
HILOG_DEBUG();
@ -260,26 +239,6 @@ bool NAccessibilityConfig::IsAvailable(napi_env env, napi_callback_info info)
return true;
}
bool NAccessibilityConfig::IsAvailableWrite(napi_env env, napi_callback_info info)
{
HILOG_DEBUG();
if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(IPCSkeleton::GetCallingFullTokenID())) {
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NOT_SYSTEM_APP);
napi_throw(env, err);
HILOG_ERROR("is not system app");
return false;
}
if (!CheckWritePermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NO_PERMISSION);
napi_throw(env, err);
HILOG_ERROR("have no write permission");
return false;
}
return true;
}
napi_value NAccessibilityConfig::SubscribeState(napi_env env, napi_callback_info info)
{
HILOG_DEBUG();
@ -754,10 +713,6 @@ bool NAccessibilityConfig::SetConfigParseData(napi_env env, NAccessibilityConfig
napi_value NAccessibilityConfig::SetConfig(napi_env env, napi_callback_info info)
{
HILOG_DEBUG();
if (!IsAvailableWrite(env, info)) {
return nullptr;
}
NAccessibilityConfigClass* obj;
size_t argc = ARGS_SIZE_TWO;
napi_value parameters[ARGS_SIZE_TWO] = {0};