summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaya Sugiura <ssugiura@jp.adit-jv.com>2021-07-29 11:01:47 +0900
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-10-05 11:19:26 +0900
commitb9b0d3bd77ef0d51ff68be60b5a47ffc3c709a96 (patch)
treed51374026d912c4625416116ebeeba202a52d11e
parent6759193fc2f4db2758ef9a621ce65e2bc621839b (diff)
downloadDLT-daemon-b9b0d3bd77ef0d51ff68be60b5a47ffc3c709a96.tar.gz
daemon: Create parent directory for unix socket
Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
-rw-r--r--src/daemon/dlt-daemon.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index fd7d3e5..68a51e0 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -818,7 +818,6 @@ int option_file_parser(DltDaemonLocal *daemon_local)
return 0;
}
-#ifdef DLT_DAEMON_USE_FIFO_IPC
static int dlt_mkdir_recursive(const char *dir)
{
int ret = 0;
@@ -838,21 +837,30 @@ static int dlt_mkdir_recursive(const char *dir)
for (p = tmp + 1; ((*p) && (ret == 0)) || ((ret == -1 && errno == EEXIST) && (p != end)); p++)
if (*p == '/') {
*p = 0;
- ret = mkdir(tmp, S_IRWXU);
+ ret = mkdir(tmp,
+ #ifdef DLT_DAEMON_USE_FIFO_IPC
+ S_IRWXU);
+ #else
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH /*S_IRWXU*/);
+ #endif
*p = '/';
}
if ((ret == 0) || ((ret == -1) && (errno == EEXIST)))
- ret = mkdir(tmp, S_IRWXU);
+ ret = mkdir(tmp,
+ #ifdef DLT_DAEMON_USE_FIFO_IPC
+ S_IRWXU);
+ #else
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH /*S_IRWXU*/);
+ #endif
if ((ret == -1) && (errno == EEXIST))
ret = 0;
return ret;
}
-#endif
#ifdef DLT_DAEMON_USE_FIFO_IPC
static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
@@ -937,14 +945,20 @@ int main(int argc, char *argv[])
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
+/* Make sure the parent user directory is created */
#ifdef DLT_DAEMON_USE_FIFO_IPC
- /* Make sure the parent user directory is created */
if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", dltFifoBaseDir);
return -1;
}
+#else
+ if (dlt_mkdir_recursive(DLT_USER_IPC_PATH) != 0) {
+ dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", daemon_local.flags.appSockPath);
+ return -1;
+ }
+
#endif
/* --- Daemon init phase 1 begin --- */