mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 06:50:12 +00:00
forbid setenv
Signed-off-by: yuhaoqiang <yuhaoqiang@huawei.com>
This commit is contained in:
parent
bdde431439
commit
79e194e2e7
@ -18,7 +18,9 @@ ohos_source_set("libhidebug_source") {
|
||||
part_name = "${OHOS_PROFILER_PART_NAME}"
|
||||
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
|
||||
include_dirs = [ "../../interfaces/native/innerkits/include" ]
|
||||
|
||||
if (build_variant == "root") {
|
||||
defines = [ "HIDEBUG_BUILD_VARIANT_ROOT" ]
|
||||
}
|
||||
sources = [ "hidebug_base.c" ]
|
||||
|
||||
external_deps = [
|
||||
@ -35,7 +37,9 @@ ohos_source_set("libhidebug_init_source") {
|
||||
defines = [ "HIDEBUG_IN_INIT" ]
|
||||
|
||||
include_dirs = [ "../../interfaces/native/innerkits/include" ]
|
||||
|
||||
if (build_variant == "root") {
|
||||
defines += [ "HIDEBUG_BUILD_VARIANT_ROOT" ]
|
||||
}
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"init:libinit_module_engine",
|
||||
|
@ -49,14 +49,16 @@
|
||||
#define LOG_PRIV_PUBLIC "{public}"
|
||||
#endif
|
||||
|
||||
#define MAX_PARA_LEN 50
|
||||
#define MAX_PARA_CNT 20
|
||||
#define PARAM_BUF_LEN 128
|
||||
#define QUERYNAME_LEN 80
|
||||
#define COLON_CHR ':'
|
||||
#define SLASH_CHR '/'
|
||||
const char * const LIBC_HOOK_PARAM = "libc.hook_mode";
|
||||
|
||||
#ifdef HIDEBUG_BUILD_VARIANT_ROOT
|
||||
#define MAX_PARA_LEN 50
|
||||
#define MAX_PARA_CNT 20
|
||||
#define QUERYNAME_LEN 80
|
||||
#define COLON_CHR ':'
|
||||
|
||||
struct Params {
|
||||
char key[MAX_PARA_LEN];
|
||||
char value[MAX_PARA_LEN];
|
||||
@ -147,6 +149,24 @@ static bool InitHiDebugEnvParams(const char *queryName)
|
||||
return paramsCnt > 0;
|
||||
}
|
||||
|
||||
static bool InitEnvParam(const char *serviceName)
|
||||
{
|
||||
char paramOutBuf[PARAM_BUF_LEN] = { 0 };
|
||||
if (!QueryParams("const.debuggable", paramOutBuf, PARAM_BUF_LEN) || strcmp(paramOutBuf, "1") != 0) {
|
||||
return false;
|
||||
}
|
||||
char onceName[QUERYNAME_LEN] = "hiviewdfx.debugenv.";
|
||||
if (!ConcatenateParamName(onceName, sizeof(onceName), serviceName)) {
|
||||
return false;
|
||||
}
|
||||
if (InitHiDebugEnvParams(onceName)) {
|
||||
return true;
|
||||
}
|
||||
char persistName[QUERYNAME_LEN] = "persist.hiviewdfx.debugenv.";
|
||||
return ConcatenateParamName(persistName, sizeof(onceName), serviceName) && InitHiDebugEnvParams(persistName);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* FilterServiceName(const char *inputName)
|
||||
{
|
||||
const char *ret = strrchr(inputName, SLASH_CHR);
|
||||
@ -262,17 +282,9 @@ bool InitEnvironmentParam(const char *inputName)
|
||||
SetupMallocHookAtStartup(serviceName);
|
||||
#endif
|
||||
|
||||
char paramOutBuf[PARAM_BUF_LEN] = { 0 };
|
||||
if (!QueryParams("const.debuggable", paramOutBuf, PARAM_BUF_LEN) || strcmp(paramOutBuf, "1") != 0) {
|
||||
return false;
|
||||
}
|
||||
char onceName[QUERYNAME_LEN] = "hiviewdfx.debugenv.";
|
||||
if (!ConcatenateParamName(onceName, sizeof(onceName), serviceName)) {
|
||||
return false;
|
||||
}
|
||||
if (InitHiDebugEnvParams(onceName)) {
|
||||
return true;
|
||||
}
|
||||
char persistName[QUERYNAME_LEN] = "persist.hiviewdfx.debugenv.";
|
||||
return ConcatenateParamName(persistName, sizeof(onceName), serviceName) && InitHiDebugEnvParams(persistName);
|
||||
#ifdef HIDEBUG_BUILD_VARIANT_ROOT
|
||||
return InitEnvParam(serviceName);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
@ -52,6 +52,10 @@ ohos_static_library("libhidebug_init") {
|
||||
|
||||
defines = [ "HIDEBUG_IN_INIT" ]
|
||||
|
||||
if (build_variant == "root") {
|
||||
defines += [ "HIDEBUG_BUILD_VARIANT_ROOT" ]
|
||||
}
|
||||
|
||||
include_dirs = [ "../../interfaces/native/innerkits/include" ]
|
||||
|
||||
sources = [ "../../../frameworks/native/hidebug_base.c" ]
|
||||
|
Loading…
Reference in New Issue
Block a user