From 532d3638771241229b5e773042420e7cee91e448 Mon Sep 17 00:00:00 2001 From: liveery Date: Wed, 7 Feb 2024 13:42:00 +0000 Subject: [PATCH] fixed 8ac03a5 from https://gitee.com/liveery/startup_init/pulls/2545 fixed 194d191 from https://gitee.com/liveery/startup_init/pulls/2544 fix:modify create socket restoreContent file Feature or Bugfix:Bugfix Binary Source: No Signed-off-by: liveery --- services/init/init_service_socket.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/init/init_service_socket.c b/services/init/init_service_socket.c index 234a72382..2349f9223 100644 --- a/services/init/init_service_socket.c +++ b/services/init/init_service_socket.c @@ -30,6 +30,7 @@ #define SOCKET_BUFF_SIZE (256 * 1024) #define HOS_SOCKET_DIR "/dev/unix/socket" +#define HOS_SOCKET_PATH 64 #define HOS_SOCKET_ENV_PREFIX "OHOS_SOCKET_" #define MAX_SOCKET_ENV_PREFIX_LEN 64 #define MAX_SOCKET_FD_LEN 16 @@ -141,7 +142,13 @@ static int CreateSocket(ServiceSocket *sockopt) } INIT_LOGI("CreateSocket %s success", sockopt->name); - PluginExecCmdByName("restoreContentRecurse", HOS_SOCKET_DIR); + char path[HOS_SOCKET_PATH] = { 0 }; + if (snprintf_s(path, sizeof(path), sizeof(path) - 1, HOS_SOCKET_DIR"/%s", sockopt->name) < 0) { + close(sockopt->sockFd); + return -1; + } + PluginExecCmdByName("restoreContentRecurse", path); + INIT_LOGI("CreateSocket restoreContentRecurse %s success", path); return sockopt->sockFd; }