summaryrefslogtreecommitdiff
path: root/src/lib/ecore_ipc
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-25 18:01:29 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-25 18:01:29 -0200
commit48049a4ce24d9bc71cdd73033f2fa6c6281f3b87 (patch)
tree25e325a20206e2e6276f9c834729dbdc15abffdd /src/lib/ecore_ipc
parent3346e6973b5e831e0db6ad3cd9034d5f6b663799 (diff)
efl_net_server_unix: add leading_directories_create property.
This allows us to crete any parent directories that are missing.
Diffstat (limited to 'src/lib/ecore_ipc')
-rw-r--r--src/lib/ecore_ipc/ecore_ipc.c56
1 files changed, 2 insertions, 54 deletions
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)