Skip to content
Snippets Groups Projects
Commit 26cefa2a authored by Esben Haabendal's avatar Esben Haabendal
Browse files

openharmony-standard: Run faultloggerd as systemd service


Signed-off-by: default avatarEsben Haabendal <esben@geanix.com>
parent 9d7c2a48
No related branches found
No related tags found
1 merge request!109Systemd service integration and stability improvements
......@@ -2,9 +2,17 @@
Description=OpenHarmony FaultLogger daemon
[Service]
Type=oneshot
ExecStart=/bin/echo "OpenHarmony FaultLogger Service"
RemainAfterExit=yes
Type=notify
# UserType::OVERSEAS_COMMERCIAL
ExecStartPre=setparam ro.logsystem.usertype 6
ExecStartPre=!install -o root -g system -m 0755 -d /run/openharmony/faultlogger
ExecStartPre=!install -o system -g log -m 0770 -d /data/log
ExecStartPre=!install -o system -g system -m 0770 -d /data/log/faultlog
ExecStartPre=!install -o system -g system -m 0770 -d /data/log/faultlog/temp
User=root
Group=system
SupplementaryGroups=log
ExecStart=/usr/bin/faultloggerd
[Install]
WantedBy=multi-user.target
......@@ -136,12 +136,6 @@ fi
#sa_main /system/profile/dps_service.xml & # SA: 1401 180 3502
#sleep "$STARTUP_CMD_SLEEP"
if systemctl -q is-enabled faultloggerd.service; then
echo >/dev/console "Starting OpenHarmony faultlogger service"
setparam ro.logsystem.usertype 6 # UserType::OVERSEAS_COMMERCIAL
/system/bin/faultloggerd &
fi
# trigger: boot?
# "name" : "hdcd",
# "path" : ["/system/bin/hdcd"],
......
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: Apache-2.0
Patch for //base/hiviewdfx/faultloggerd of OpenHarmony 3.0 codebase
This adds sd_notify(3) ready notification to faultlogger service for better
integration with systemd.
Signed-off-by: Esben Haabendal <esben@geanix.com>
Upstream-Status: Pending
diff --git a/services/fault_logger_daemon.cpp b/services/fault_logger_daemon.cpp
index ed7794cfbfc7..e0b35c44a48c 100644
--- a/services/fault_logger_daemon.cpp
+++ b/services/fault_logger_daemon.cpp
@@ -32,6 +32,8 @@
#include <hilog/log.h>
#include <securec.h>
+#include <systemd/sd-daemon.h>
+
#include "fault_logger_daemon.h"
#include "faultloggerd_client.h"
@@ -44,11 +46,7 @@ constexpr int32_t MAX_CONNECTION = 4;
constexpr int32_t REQUEST_BUF_SIZE = 1024;
constexpr int32_t MSG_BUF_SIZE = 256;
constexpr int32_t SYSTEM_UID = 1000;
-#if defined(USE_MUSL)
-static const char FAULTLOGGERD_SOCK_PATH[] = "/dev/unix/socket/faultloggerd.server";
-#else
-static const char FAULTLOGGERD_SOCK_PATH[] = "/dev/socket/faultloggerd.server";
-#endif
+static const char FAULTLOGGERD_SOCK_PATH[] = "/run/openharmony/faultlogger/server";
static const char FAULTLOGGERD_BASE_PATH[] = "/data/log/faultlog/temp/";
static std::string GetRequestTypeName(int32_t type)
@@ -254,6 +252,7 @@ int32_t StartServer(int argc, char *argv[])
return -1;
}
+ sd_notify(0, "READY=1");
struct sockaddr_un clientAddr;
socklen_t clientAddrSize = sizeof(clientAddr);
int connectionFd = -1;
diff --git a/services/BUILD.gn b/services/BUILD.gn
index f48777a7cdbf..847e3cf79510 100644
--- a/services/BUILD.gn
+++ b/services/BUILD.gn
@@ -63,6 +63,7 @@ ohos_executable("faultloggerd") {
"$faultloggerd_path/interfaces/innerkits/faultloggerd_client:libfaultloggerd",
"//utils/native/base:utils",
]
+ libs = [ "systemd" ]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: Apache-2.0
Patch for //base/hiviewdfx/faultloggerd of OpenHarmony 3.0 codebase
Configure faultloggerd service to place Unix socket in /run instead of /dev (where
they obviously does not belong).
Having a dedicated directory for this makes it easier to handle permissions in a
safe way.
Signed-off-by: Esben Haabendal <esben@geanix.com>
Upstream-Status: Inappropriate [configuration]
diff --git a/interfaces/innerkits/faultloggerd_client/faultloggerd_client.cpp b/interfaces/innerkits/faultloggerd_client/faultloggerd_client.cpp
index 704ae9c0cbd7..4456eb29b87c 100644
--- a/interfaces/innerkits/faultloggerd_client/faultloggerd_client.cpp
+++ b/interfaces/innerkits/faultloggerd_client/faultloggerd_client.cpp
@@ -31,11 +31,7 @@
namespace {
static const int32_t SOCKET_BUFFER_SIZE = 256;
-#if defined(USE_MUSL)
-static const char FAULTLOGGERD_SOCK_PATH[] = "/dev/unix/socket/faultloggerd.server";
-#else
-static const char FAULTLOGGERD_SOCK_PATH[] = "/dev/socket/faultloggerd.server";
-#endif
+static const char FAULTLOGGERD_SOCK_PATH[] = "/run/openharmony/faultlogger/server";
}
static int ReadFileDescriptorFromSocket(int socket)
......@@ -82,6 +82,8 @@ SRC_URI += "file://installs-sd-notify.patch;patchdir=${S}/foundation/appexecfwk/
SRC_URI += "file://deviceauth-sd-notify.patch;patchdir=${S}/base/security/deviceauth"
SRC_URI += "file://base_hiviewdfx_hiview-libfaultlogger-static.patch;patchdir=${S}/base/hiviewdfx/hiview"
SRC_URI += "file://faultloggerd-socket-path.patch;patchdir=${S}/base/hiviewdfx/faultloggerd"
SRC_URI += "file://faultloggerd-sd-notify.patch;patchdir=${S}/base/hiviewdfx/faultloggerd"
# Patch to allow /system/profile and /system/usr to be symlinks to /usr/lib/openharmony
SRC_URI += "file://foundation_distributedschedule_safwk-slash-system-symlink.patch;patchdir=${S}/foundation/distributedschedule/safwk"
......@@ -1623,7 +1625,7 @@ FILES:${PN}-faultlogger = " \
${libdir}/libfaultloggerd*${SOLIBS} \
${libdir}/libdfx_signalhandler*${SOLIBS} \
"
RDEPENDS:${PN}-faultlogger += "musl libcxx"
RDEPENDS:${PN}-faultlogger += "musl libcxx libsystemd"
RDEPENDS:${PN}-faultlogger += "${PN}-libutils ${PN}-hilog"
RDEPENDS:${PN} += "${PN}-faultlogger"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment