From d126bc20fc5414fb3bc0bdf53bfd9ae03f979a63 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Thu, 20 Jun 2024 08:01:15 +0000 Subject: [PATCH 1/4] change getpid() to getprocpid() Signed-off-by: liuyifei --- frameworks/libhilog/base/hilog_base.c | 2 +- frameworks/libhilog/hilog_printf.cpp | 5 ++++- services/hilogd/main.cpp | 2 +- test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frameworks/libhilog/base/hilog_base.c b/frameworks/libhilog/base/hilog_base.c index 6c26bf2..c482e9c 100644 --- a/frameworks/libhilog/base/hilog_base.c +++ b/frameworks/libhilog/base/hilog_base.c @@ -89,7 +89,7 @@ int HiLogBasePrintArgs( header.type = type; header.level = level; #ifndef __RECV_MSG_WITH_UCRED_ - header.pid = getpid(); + header.pid = getprocpid(); #endif header.tid = (uint32_t)(gettid()); header.domain = domain; diff --git a/frameworks/libhilog/hilog_printf.cpp b/frameworks/libhilog/hilog_printf.cpp index e30f248..80b88f9 100644 --- a/frameworks/libhilog/hilog_printf.cpp +++ b/frameworks/libhilog/hilog_printf.cpp @@ -304,7 +304,10 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int header.type = type; header.level = level; #ifndef __RECV_MSG_WITH_UCRED_ -#ifndef __WINDOWS__ + +#if defined(is_ohos) && is_ohos + header.pid = static_cast(getprocpid()); +#elif not defined(__WINDOWS__) header.pid = getpid(); #else header.pid = static_cast(GetCurrentProcessId()); diff --git a/services/hilogd/main.cpp b/services/hilogd/main.cpp index 2f2836d..f966871 100644 --- a/services/hilogd/main.cpp +++ b/services/hilogd/main.cpp @@ -189,7 +189,7 @@ int HilogdEntry() } ffrt::submit([]() { - string myPid = to_string(getpid()); + string myPid = to_string(getprocpid()); (void)WriteStringToFile(myPid, SYSTEM_BG_STUNE); (void)WriteStringToFile(myPid, SYSTEM_BG_CPUSET); (void)WriteStringToFile(myPid, SYSTEM_BG_BLKIO); diff --git a/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp b/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp index 56f8896..382257b 100644 --- a/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp +++ b/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp @@ -36,7 +36,7 @@ namespace OHOS { header.tv_sec = static_cast(ts.tv_sec); header.tv_nsec = static_cast(ts.tv_nsec); header.mono_sec = static_cast(tsMono.tv_sec); - header.pid = getpid(); + header.pid = getprocpid(); header.tid = static_cast(syscall(SYS_gettid)); header.type = LOG_CORE; header.level = LOG_INFO; -- Gitee From b1b398c74d35fc31f55477709c66e9f20510fd3f Mon Sep 17 00:00:00 2001 From: liuyifei Date: Thu, 20 Jun 2024 08:03:12 +0000 Subject: [PATCH 2/4] update frameworks/libhilog/hilog_printf.cpp. Signed-off-by: liuyifei --- frameworks/libhilog/hilog_printf.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/libhilog/hilog_printf.cpp b/frameworks/libhilog/hilog_printf.cpp index 80b88f9..24c6644 100644 --- a/frameworks/libhilog/hilog_printf.cpp +++ b/frameworks/libhilog/hilog_printf.cpp @@ -304,7 +304,6 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int header.type = type; header.level = level; #ifndef __RECV_MSG_WITH_UCRED_ - #if defined(is_ohos) && is_ohos header.pid = static_cast(getprocpid()); #elif not defined(__WINDOWS__) -- Gitee From a53f197c8b69750d8e749b022ab6e99251b2d033 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Thu, 20 Jun 2024 09:29:01 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=88=A0=E9=99=A4hilogOutput=20other?= =?UTF-8?q?=E5=86=99=E6=9D=83=E9=99=90=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0neverallow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuyifei --- services/hilogd/etc/hilogd.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/hilogd/etc/hilogd.cfg b/services/hilogd/etc/hilogd.cfg index 65d5126..d65bb34 100644 --- a/services/hilogd/etc/hilogd.cfg +++ b/services/hilogd/etc/hilogd.cfg @@ -37,7 +37,7 @@ "family" : "AF_UNIX", "type" : "SOCK_SEQPACKET", "protocol" : "default", - "permissions" : "0666", + "permissions" : "0600", "uid" : "logd", "gid" : "log", "option" : [ -- Gitee From f9fa86180a50fab311d3595aedac1a13ff4c0dc1 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Thu, 20 Jun 2024 09:37:47 +0000 Subject: [PATCH 4/4] update services/hilogd/etc/hilogd.cfg. Signed-off-by: liuyifei --- services/hilogd/etc/hilogd.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/hilogd/etc/hilogd.cfg b/services/hilogd/etc/hilogd.cfg index d65bb34..65d5126 100644 --- a/services/hilogd/etc/hilogd.cfg +++ b/services/hilogd/etc/hilogd.cfg @@ -37,7 +37,7 @@ "family" : "AF_UNIX", "type" : "SOCK_SEQPACKET", "protocol" : "default", - "permissions" : "0600", + "permissions" : "0666", "uid" : "logd", "gid" : "log", "option" : [ -- Gitee