summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/ecore_con/ecore_con_local.c2
-rw-r--r--src/lib/ecore_con/ecore_con_private.h2
-rw-r--r--src/lib/ecore_con/efl_net_server_unix.c20
-rw-r--r--src/lib/ecore_con/efl_net_server_unix.eo12
-rw-r--r--src/lib/ecore_ipc/ecore_ipc.c56
5 files changed, 37 insertions, 55 deletions
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index 3bf9b97777..1cccf046b0 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -229,7 +229,7 @@ error:
229} 229}
230 230
231#ifdef HAVE_LOCAL_SOCKETS 231#ifdef HAVE_LOCAL_SOCKETS
232static void 232void
233_ecore_con_local_mkpath(const char *path, mode_t mode) 233_ecore_con_local_mkpath(const char *path, mode_t mode)
234{ 234{
235 char *s, *d, *itr; 235 char *s, *d, *itr;
diff --git a/src/lib/ecore_con/ecore_con_private.h b/src/lib/ecore_con/ecore_con_private.h
index 391204f1f2..45864dafdb 100644
--- a/src/lib/ecore_con/ecore_con_private.h
+++ b/src/lib/ecore_con/ecore_con_private.h
@@ -386,6 +386,8 @@ void ecore_con_mempool_shutdown(void);
386 386
387#undef GENERIC_ALLOC_FREE_HEADER 387#undef GENERIC_ALLOC_FREE_HEADER
388 388
389void _ecore_con_local_mkpath(const char *path, mode_t mode);
390
389/* allow windows and posix to use the same error comparison */ 391/* allow windows and posix to use the same error comparison */
390#ifndef SOCKET_ERROR 392#ifndef SOCKET_ERROR
391#define SOCKET_ERROR -1 393#define SOCKET_ERROR -1
diff --git a/src/lib/ecore_con/efl_net_server_unix.c b/src/lib/ecore_con/efl_net_server_unix.c
index 53deb4d3e1..b407d91233 100644
--- a/src/lib/ecore_con/efl_net_server_unix.c
+++ b/src/lib/ecore_con/efl_net_server_unix.c
@@ -24,6 +24,8 @@
24 24
25typedef struct _Efl_Net_Server_Unix_Data 25typedef struct _Efl_Net_Server_Unix_Data
26{ 26{
27 unsigned int leading_directories_create_mode;
28 Eina_Bool leading_directories_create;
27 Eina_Bool unlink_before_bind; 29 Eina_Bool unlink_before_bind;
28} Efl_Net_Server_Unix_Data; 30} Efl_Net_Server_Unix_Data;
29 31
@@ -54,6 +56,9 @@ _efl_net_server_unix_bind(Eo *o, Efl_Net_Server_Unix_Data *pd)
54 56
55 efl_net_server_fd_family_set(o, AF_UNIX); 57 efl_net_server_fd_family_set(o, AF_UNIX);
56 58
59 if (pd->leading_directories_create)
60 _ecore_con_local_mkpath(address, pd->leading_directories_create_mode);
61
57 do 62 do
58 { 63 {
59 fd = efl_net_socket4(AF_UNIX, SOCK_STREAM, 0, 64 fd = efl_net_socket4(AF_UNIX, SOCK_STREAM, 0,
@@ -272,4 +277,19 @@ _efl_net_server_unix_unlink_before_bind_get(Eo *o EINA_UNUSED, Efl_Net_Server_Un
272 return pd->unlink_before_bind; 277 return pd->unlink_before_bind;
273} 278}
274 279
280
281static void
282_efl_net_server_unix_leading_directories_create_set(Eo *o EINA_UNUSED, Efl_Net_Server_Unix_Data *pd, Eina_Bool do_it, unsigned int mode)
283{
284 pd->leading_directories_create = do_it;
285 pd->leading_directories_create_mode = mode;
286}
287
288static void
289_efl_net_server_unix_leading_directories_create_get(Eo *o EINA_UNUSED, Efl_Net_Server_Unix_Data *pd, Eina_Bool *do_it, unsigned int *mode)
290{
291 if (do_it) *do_it = pd->leading_directories_create;
292 if (mode) *mode = pd->leading_directories_create_mode;
293}
294
275#include "efl_net_server_unix.eo.c" 295#include "efl_net_server_unix.eo.c"
diff --git a/src/lib/ecore_con/efl_net_server_unix.eo b/src/lib/ecore_con/efl_net_server_unix.eo
index accd07924c..69a3e39e7e 100644
--- a/src/lib/ecore_con/efl_net_server_unix.eo
+++ b/src/lib/ecore_con/efl_net_server_unix.eo
@@ -23,6 +23,18 @@ class Efl.Net.Server.Unix (Efl.Net.Server.Fd) {
23 unlink_before_bind: bool; [[If $true, server will unlink() the path before bind() is called.]] 23 unlink_before_bind: bool; [[If $true, server will unlink() the path before bind() is called.]]
24 } 24 }
25 } 25 }
26
27 @property leading_directories_create {
28 [[If $true, all parent directories will be created with given mode.
29
30 This is only effective before @Efl.Net.Server.serve is
31 called as it is used from inside that method.
32 ]]
33 values {
34 leading_directories_create: bool; [[If $true, create missing parent directories. Do nothing if $false]]
35 mode: uint; [[The file system permissions to use (file mode)]]
36 }
37 }
26 } 38 }
27 39
28 implements { 40 implements {
diff --git a/src/lib/ecore_ipc/ecore_ipc.c b/src/lib/ecore_ipc/ecore_ipc.c
index e4287aa4fa..8b62435570 100644
--- a/src/lib/ecore_ipc/ecore_ipc.c
+++ b/src/lib/ecore_ipc/ecore_ipc.c
@@ -438,56 +438,6 @@ ecore_ipc_server_add_legacy(Ecore_Ipc_Type compl_type, const char *name, int por
438 ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER); 438 ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER);
439 return svr; 439 return svr;
440} 440}
441#else
442static Eina_Bool
443_ecore_ipc_local_mkpath(const char *path, mode_t mode)
444{
445 Eina_Bool ret = EINA_FALSE;
446 char *s, *d, *itr;
447
448 if (!path) return EINA_FALSE;
449 EINA_SAFETY_ON_TRUE_RETURN_VAL(path[0] != '/', EINA_FALSE);
450
451 s = strdup(path);
452 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
453 d = dirname(s);
454 EINA_SAFETY_ON_NULL_RETURN_VAL(d, EINA_FALSE);
455
456 for (itr = d + 1; *itr != '\0'; itr++)
457 {
458 if (*itr == '/')
459 {
460 *itr = '\0';
461 if (mkdir(d, mode) != 0)
462 {
463 if (errno != EEXIST)
464 {
465 ERR("could not create parent directory '%s' of path '%s': %s", d, path, strerror(errno));
466 goto end;
467 }
468 }
469 *itr = '/';
470 }
471 }
472
473 if (mkdir(d, mode) != 0)
474 {
475 if (errno != EEXIST)
476 ERR("could not create parent directory '%s' of path '%s': %s", d, path, strerror(errno));
477 else
478 {
479 struct stat st;
480 if ((stat(d, &st) != 0) || (!S_ISDIR(st.st_mode)))
481 ERR("could not create parent directory '%s' of path '%s': exists but is not a directory", d, path);
482 else ret = EINA_TRUE;
483 }
484 }
485 else ret = EINA_TRUE;
486
487 end:
488 free(s);
489 return ret;
490}
491#endif 441#endif
492 442
493/* FIXME: need to add protocol type parameter */ 443/* FIXME: need to add protocol type parameter */
@@ -523,12 +473,10 @@ ecore_ipc_server_add(Ecore_Ipc_Type type, const char *name, int port, const void
523 address = ecore_con_local_path_new(EINA_FALSE, name, port); 473 address = ecore_con_local_path_new(EINA_FALSE, name, port);
524 EINA_SAFETY_ON_NULL_GOTO(address, error_server); 474 EINA_SAFETY_ON_NULL_GOTO(address, error_server);
525 475
526 if (!_ecore_ipc_local_mkpath(address, S_IRUSR | S_IWUSR | S_IXUSR))
527 goto error_server;
528
529 new_mask = S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH; 476 new_mask = S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
530 477
531 svr->server = efl_add(EFL_NET_SERVER_UNIX_CLASS, ecore_main_loop_get()); 478 svr->server = efl_add(EFL_NET_SERVER_UNIX_CLASS, ecore_main_loop_get(),
479 efl_net_server_unix_leading_directories_create_set(efl_added, EINA_TRUE, S_IRUSR | S_IWUSR | S_IXUSR));
532 EINA_SAFETY_ON_NULL_GOTO(svr->server, error_server); 480 EINA_SAFETY_ON_NULL_GOTO(svr->server, error_server);
533 } 481 }
534 else if ((type & ECORE_IPC_TYPE) == ECORE_IPC_LOCAL_SYSTEM) 482 else if ((type & ECORE_IPC_TYPE) == ECORE_IPC_LOCAL_SYSTEM)