diff --git a/recipes-openharmony/openharmony/files/deviceauth.service b/recipes-openharmony/openharmony/files/deviceauth.service index aab97854fa0d40cee3f4fe52a90daf4b4fa643f3..106e75eb649723d9e9ed2423a8f150f06f9b8ce0 100644 --- a/recipes-openharmony/openharmony/files/deviceauth.service +++ b/recipes-openharmony/openharmony/files/deviceauth.service @@ -1,10 +1,20 @@ [Unit] -Description=OpenHarmony Device Authentication daemon +Description=OpenHarmony Device Authentication daemon (SA: 4701) +Requires=samgr.service +After=samgr.service +# Logging to hilogd, but seems to work without it +Wants=hilogd.service +After=hilogd.service +# Requires SA: 3510 +Wants=huks.service [Service] -Type=oneshot -ExecStart=/bin/echo "OpenHarmony Device Authentication Service" -RemainAfterExit=yes +Type=notify +User=system +Group=system +SupplementaryGroups=shell +LimitNICE=40 +ExecStart=/usr/bin/deviceauth_service [Install] WantedBy=multi-user.target diff --git a/recipes-openharmony/openharmony/files/openharmony-preinit b/recipes-openharmony/openharmony/files/openharmony-preinit index c05bcbc47ae83f3371dbd5cd3e9ead7cab202d1e..188231c044cbeceb78bd235b518508d24179c8e8 100644 --- a/recipes-openharmony/openharmony/files/openharmony-preinit +++ b/recipes-openharmony/openharmony/files/openharmony-preinit @@ -132,17 +132,6 @@ if systemctl -q is-enabled weston.service; then sleep "$STARTUP_CMD_SLEEP" fi -# trigger: post-fs-data -# "name" : "deviceauth_service", -# "path" : ["/system/bin/deviceauth_service"], -# "uid" : "system", -# "gid" : ["system", "shell"] -if systemctl -q is-enabled deviceauth.service; then - echo >/dev/console "Starting OpenHarmony deviceauth service" - su system -c '/system/bin/deviceauth_service &' # SA: 4701 | Required SA: 3510 - sleep "$STARTUP_CMD_SLEEP" -fi - # trigger: post-fs-data # "name" : "accountmgr", # "path" : ["/system/bin/sa_main", "/system/profile/accountmgr.xml"], diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/deviceauth-sd-notify.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/deviceauth-sd-notify.patch new file mode 100644 index 0000000000000000000000000000000000000000..9728d5deb39f48dde289bdcb37d4d339ae284157 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/deviceauth-sd-notify.patch @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +Patch for //base/security/deviceauth of OpenHarmony 3.0 codebase + +This adds sd_notify(3) ready notification to deviceauth service for better +integration with systemd. + +Signed-off-by: Esben Haabendal <esben@geanix.com> +Upstream-Status: Pending + +diff --git a/frameworks/src/ipc_service.c b/frameworks/src/ipc_service.c +index 46bd82dd8969..48972f55c9d4 100644 +--- a/frameworks/src/ipc_service.c ++++ b/frameworks/src/ipc_service.c +@@ -25,6 +25,8 @@ + #include "ipc_sdk.h" + #include "securec.h" + ++#include <systemd/sd-daemon.h> ++ + #ifdef __cplusplus + extern "C" { + #endif +@@ -1323,9 +1325,11 @@ int32_t main(int32_t argc, char const *argv[]) + } + (void)AddMethodMap(serviceCtx); + LOGI("device authentication service register to IPC manager done, service running..."); ++ sd_notify(0, "READY=1"); + (void)memset_s(&cond, sizeof(cond), 0, sizeof(cond)); + InitHcCond(&cond, NULL); + cond.wait(&cond); ++ sd_notify(0, "STOPPING=1"); + DestroyHcCond(&cond); + return 0; + } +diff --git a/services/BUILD.gn b/services/BUILD.gn +index d6bd3557f656..83db1b07278b 100644 +--- a/services/BUILD.gn ++++ b/services/BUILD.gn +@@ -219,6 +219,8 @@ if (defined(ohos_lite)) { + "safwk:system_ability_fwk", + "samgr_L2:samgr_proxy", + ] ++ ++ libs = [ "systemd" ] + } + + ohos_shared_library("deviceauth_sdk") { diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index 3628982410492e5866ee7ed4ca0cff924c0feb96..26c9b63ec18ecc968443474661f26e1742d626e2 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -79,6 +79,7 @@ SRC_URI += "file://param_service-Add-to-startup-l2-part.patch;patchdir=${S}/base SRC_URI += "file://samgr-sd-notify.patch;patchdir=${S}/foundation/distributedschedule/samgr" SRC_URI += "file://safwk-sd-notify.patch;patchdir=${S}/foundation/distributedschedule/safwk" SRC_URI += "file://installs-sd-notify.patch;patchdir=${S}/foundation/appexecfwk/standard" +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" @@ -1066,7 +1067,7 @@ FILES:${PN}-security-deviceauth = " \ ${bindir}/deviceauth_service \ ${libdir}/libdeviceauth*${SOLIBS} \ " -RDEPENDS:${PN}-security-deviceauth += "musl libcxx libcrypto" +RDEPENDS:${PN}-security-deviceauth += "musl libcxx libcrypto libsystemd" RDEPENDS:${PN}-security-deviceauth += "${PN}-hilog ${PN}-libutils ${PN}-ipc ${PN}-samgr" RDEPENDS:${PN}-security-deviceauth += "${PN}-security-huks ${PN}-syspara ${PN}-dsoftbus" RDEPENDS:${PN} += "${PN}-security-deviceauth"