未验证 提交 3c4f16cc 编写于 作者: O openharmony_ci 提交者: Gitee

!430 支持native 接口校验

Merge pull request !430 from 熊磊/init0315_2
......@@ -77,9 +77,7 @@ bool DeviceInfoStub::CheckPermission(MessageParcel &data, const std::string &per
int32_t result = TypePermissionState::PERMISSION_GRANTED;
int32_t tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken);
if (tokenType == TOKEN_NATIVE) {
#ifdef SUPPORT_NATIVE
result = AccessTokenKit::VerifyNativeToken(callerToken, permission);
#endif
} else if (tokenType == TOKEN_HAP) {
result = AccessTokenKit::VerifyAccessToken(callerToken, permission);
} else {
......@@ -90,7 +88,7 @@ bool DeviceInfoStub::CheckPermission(MessageParcel &data, const std::string &per
DINFO_LOGE("AccessTokenID:%d, permission:%s denied!", callerToken, permission.c_str());
return false;
}
DINFO_LOGI("dAccessTokenID:%d, permission:%s matched!", callerToken, permission.c_str());
DINFO_LOGI("tokenType %d dAccessTokenID:%d, permission:%s matched!", tokenType, callerToken, permission.c_str());
return true;
}
......
......@@ -97,6 +97,7 @@ int SystemWatchParameter(const char *keyprefix, ParameterChangePtr change, void
void SystemDumpParameters(int verbose);
int SysCheckParamExist(const char *name);
long long GetSystemCommitId(void);
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -307,6 +307,12 @@ int SystemGetParameterCommitId(ParamHandle handle, uint32_t *commitId)
return ReadParamCommitId(&g_clientSpace.paramSpace, handle, commitId);
}
long long GetSystemCommitId(void)
{
PARAM_CHECK(g_clientSpace.paramSpace.paramSpace.area != NULL, return 0, "The handle is null");
return g_clientSpace.paramSpace.paramSpace.area->commitId;
}
int SystemGetParameterName(ParamHandle handle, char *name, unsigned int len)
{
PARAM_CHECK(name != NULL && handle != 0, return -1, "The name is null");
......
......@@ -85,6 +85,7 @@ typedef struct {
} ParamSecruityNode;
typedef struct {
atomic_llong commitId;
uint32_t trieNodeCount;
uint32_t paramNodeCount;
uint32_t securityNodeCount;
......
......@@ -70,6 +70,8 @@ static int AddParam(WorkSpace *workSpace, const char *name, const char *value, u
uint32_t offset = AddParamNode(workSpace, name, strlen(name), value, strlen(value));
PARAM_CHECK(offset > 0, return PARAM_CODE_REACHED_MAX, "Failed to allocate name %s", name);
SaveIndex(&node->dataIndex, offset);
long long globalCommitId = atomic_load_explicit(&workSpace->area->commitId, memory_order_relaxed);
atomic_store_explicit(&workSpace->area->commitId, ++globalCommitId, memory_order_release);
}
if (dataIndex != NULL) {
*dataIndex = node->dataIndex;
......@@ -86,6 +88,7 @@ static int UpdateParam(const WorkSpace *workSpace, uint32_t *dataIndex, const ch
uint32_t valueLen = strlen(value);
uint32_t commitId = atomic_load_explicit(&entry->commitId, memory_order_relaxed);
atomic_store_explicit(&entry->commitId, commitId | PARAM_FLAGS_MODIFY, memory_order_relaxed);
long long globalCommitId = atomic_load_explicit(&workSpace->area->commitId, memory_order_relaxed);
if (entry->valueLength < PARAM_VALUE_LEN_MAX && valueLen < PARAM_VALUE_LEN_MAX) {
int ret = memcpy_s(entry->data + entry->keyLength + 1, PARAM_VALUE_LEN_MAX, value, valueLen + 1);
......@@ -94,6 +97,7 @@ static int UpdateParam(const WorkSpace *workSpace, uint32_t *dataIndex, const ch
}
uint32_t flags = commitId & ~PARAM_FLAGS_COMMITID;
atomic_store_explicit(&entry->commitId, (++commitId) | flags, memory_order_release);
atomic_store_explicit(&workSpace->area->commitId, ++globalCommitId, memory_order_release);
futex_wake(&entry->commitId, INT_MAX);
return 0;
}
......
......@@ -83,7 +83,8 @@ static int32_t BShellParamCmdRead(BShellHandle shell, int32_t argc, char *argv[]
static void HandleParamChange(const char *key, const char *value, void *context)
{
PLUGIN_CHECK(key != NULL && value != NULL, return, "Invalid parameter");
printf("Receive parameter change %s %s \n", key, value);
long long commit = GetSystemCommitId();
printf("Receive parameter commit %lld change %s %s \n", commit, key, value);
}
static void *CmdWatcher(void *args)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册