From bef4b653a38c20fc67dec6c4fb53cd81b381aa58 Mon Sep 17 00:00:00 2001
From: Esben Haabendal <esben@geanix.com>
Date: Thu, 9 Mar 2023 12:42:52 +0100
Subject: [PATCH] openharmony-standard: Stop param_service littering in /dev

This stops placing temporary files and Unix sockets in /dev, and use /run
instead.  This aligns better with FHS and makes it easier to handle permissions
safely if/when we decide to change uid/gid of the param service.

Signed-off-by: Esben Haabendal <esben@geanix.com>
---
 .../openharmony/files/param.service           |  3 +-
 .../param-paths.patch                         | 40 +++++++++++++++++++
 .../openharmony/openharmony-standard_3.0.bb   |  1 +
 3 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 recipes-openharmony/openharmony/openharmony-standard-3.0/param-paths.patch

diff --git a/recipes-openharmony/openharmony/files/param.service b/recipes-openharmony/openharmony/files/param.service
index 5a26b545..3c73749d 100644
--- a/recipes-openharmony/openharmony/files/param.service
+++ b/recipes-openharmony/openharmony/files/param.service
@@ -3,9 +3,8 @@ Description=OpenHarmony Param Service
 
 [Service]
 Type=notify
-ExecStartPre=install -m 755 -d /dev/unix/socket
+ExecStartPre=install -m 755 -d /run/openharmony/param
 ExecStartPre=install -m 755 -d /data/param
-ExecStartPre=install -m 755 -d /dev/__parameters__
 ExecStart=/usr/bin/param_service
 
 [Install]
diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/param-paths.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/param-paths.patch
new file mode 100644
index 00000000..5cac0a71
--- /dev/null
+++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/param-paths.patch
@@ -0,0 +1,40 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+Patch for //base/startup/init_lite of OpenHarmony 3.0 codebase
+
+Configure param service and getparam/setparam commands to place files and pipes
+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/services/param/include/param_manager.h b/services/param/include/param_manager.h
+index ad605b0c2741..7edad26d777a 100644
+--- a/services/param/include/param_manager.h
++++ b/services/param/include/param_manager.h
+@@ -43,17 +43,10 @@ typedef enum {
+ 
+ #define LABEL_STRING_LEN 128
+ 
+-#ifdef STARTUP_LOCAL
+-#define PIPE_NAME "/tmp/paramservice"
+-#define PARAM_STORAGE_PATH "/media/sf_ubuntu/test/__parameters__/param_storage"
+-#define PARAM_PERSIST_PATH "/media/sf_ubuntu/test/param/persist_parameters"
+-#define PARAM_INFO_PATH "/media/sf_ubuntu/test/__parameters__/param_info"
+-#else
+-#define PIPE_NAME "/dev/unix/socket/paramservice"
+-#define PARAM_STORAGE_PATH "/dev/__parameters__/param_storage"
++#define PIPE_NAME "/run/openharmony/param/pipe"
++#define PARAM_STORAGE_PATH "/run/openharmony/param/storage"
+ #define PARAM_PERSIST_PATH "/data/param/persist_parameters"
+-#define PARAM_INFO_PATH "/dev/__parameters__/param_info"
+-#endif
++#define PARAM_INFO_PATH "/run/openharmony/param/info"
+ 
+ #define SUBSTR_INFO_NAME  0
+ #define SUBSTR_INFO_LABEL 1
diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
index eefcf1a0..db185e4c 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
@@ -69,6 +69,7 @@ SRC_URI += "file://test_xts_acts-Align-tests-list-with-mandatory-set.patch;patch
 SRC_URI += "file://init_lite-silence-GetControlFromEnv-spam.patch;patchdir=${S}/base/startup/init_lite"
 SRC_URI += "file://param_service_standalone.patch;patchdir=${S}/base/startup/init_lite"
 SRC_URI += "file://param_service-sd-notify.patch;patchdir=${S}/base/startup/init_lite"
+SRC_URI += "file://param-paths.patch;patchdir=${S}/base/startup/init_lite"
 SRC_URI += "file://param_service-Add-to-startup-l2-part.patch;patchdir=${S}/base/startup/appspawn_standard"
 
 SRC_URI += "file://base_hiviewdfx_hiview-libfaultlogger-static.patch;patchdir=${S}/base/hiviewdfx/hiview"
-- 
GitLab