diff options
author | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2016-12-19 11:58:55 -0200 |
---|---|---|
committer | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2016-12-19 13:03:33 -0200 |
commit | ae054e6c0bb5cab6ca126c152057e5243ab31dfa (patch) | |
tree | 77856e1288f725a0b2049dff09d95947099e99f3 /src/lib | |
parent | 482437ee14885a21a94ee0d110474253ae3202ab (diff) |
ecore_con/ecore_ipc legacy: fail early for local sockets.
In the old/legacy API the socket would be opened early in non-blocking
mode (connect returned errno==EINPROGRESS), with UNIX socket being
path-validated early and returning NULL as 'server' handle.
Some applications relied on this instead of monitoring the "ERROR"
events, considering the connection to be successful if there was a
handle -- this was the case with Terminology after it moved from DBus
to Ecore_Ipc.
Although this is not correct, we must keep compatibility and thus we
stat() in compatibility layer, failing early as the old API would do.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/ecore_con/ecore_con_legacy.c | 12 | ||||
-rw-r--r-- | src/lib/ecore_ipc/ecore_ipc.c | 13 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/ecore_con/ecore_con_legacy.c b/src/lib/ecore_con/ecore_con_legacy.c index 29d829a209..e99b4a90bd 100644 --- a/src/lib/ecore_con/ecore_con_legacy.c +++ b/src/lib/ecore_con/ecore_con_legacy.c | |||
@@ -1807,6 +1807,8 @@ _ecore_con_server_dialer_set(Ecore_Con_Server *svr, Eo *dialer) | |||
1807 | (type == ECORE_CON_LOCAL_SYSTEM)) | 1807 | (type == ECORE_CON_LOCAL_SYSTEM)) |
1808 | { | 1808 | { |
1809 | char *path = ecore_con_local_path_new(type == ECORE_CON_LOCAL_SYSTEM, svr->name, svr->port); | 1809 | char *path = ecore_con_local_path_new(type == ECORE_CON_LOCAL_SYSTEM, svr->name, svr->port); |
1810 | struct stat st; | ||
1811 | |||
1810 | if (!path) | 1812 | if (!path) |
1811 | { | 1813 | { |
1812 | ERR("could not create local path for name='%s', port=%d", svr->name, svr->port); | 1814 | ERR("could not create local path for name='%s', port=%d", svr->name, svr->port); |
@@ -1817,6 +1819,16 @@ _ecore_con_server_dialer_set(Ecore_Con_Server *svr, Eo *dialer) | |||
1817 | eina_strlcpy(address, path, sizeof(address)); | 1819 | eina_strlcpy(address, path, sizeof(address)); |
1818 | free(path); | 1820 | free(path); |
1819 | } | 1821 | } |
1822 | |||
1823 | if ((stat(address, &st) != 0) | ||
1824 | #ifdef S_ISSOCK | ||
1825 | || (!S_ISSOCK(st.st_mode)) | ||
1826 | #endif | ||
1827 | ) | ||
1828 | { | ||
1829 | DBG("%s is not a socket", address); | ||
1830 | return EINA_FALSE; | ||
1831 | } | ||
1820 | } | 1832 | } |
1821 | 1833 | ||
1822 | if ((svr->type & ECORE_CON_NO_PROXY) == ECORE_CON_NO_PROXY) | 1834 | if ((svr->type & ECORE_CON_NO_PROXY) == ECORE_CON_NO_PROXY) |
diff --git a/src/lib/ecore_ipc/ecore_ipc.c b/src/lib/ecore_ipc/ecore_ipc.c index dfacf933bc..40a1e1e8a7 100644 --- a/src/lib/ecore_ipc/ecore_ipc.c +++ b/src/lib/ecore_ipc/ecore_ipc.c | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
7 | #include <sys/stat.h> | ||
7 | 8 | ||
8 | #ifdef HAVE_ARPA_INET_H | 9 | #ifdef HAVE_ARPA_INET_H |
9 | # include <arpa/inet.h> | 10 | # include <arpa/inet.h> |
@@ -761,9 +762,21 @@ ecore_ipc_server_connect(Ecore_Ipc_Type type, char *name, int port, const void * | |||
761 | #ifdef EFL_NET_DIALER_UNIX_CLASS | 762 | #ifdef EFL_NET_DIALER_UNIX_CLASS |
762 | if ((type & ECORE_IPC_TYPE) == ECORE_IPC_LOCAL_USER) | 763 | if ((type & ECORE_IPC_TYPE) == ECORE_IPC_LOCAL_USER) |
763 | { | 764 | { |
765 | struct stat st; | ||
766 | |||
764 | address = ecore_con_local_path_new(EINA_FALSE, name, port); | 767 | address = ecore_con_local_path_new(EINA_FALSE, name, port); |
765 | EINA_SAFETY_ON_NULL_GOTO(address, error_dialer); | 768 | EINA_SAFETY_ON_NULL_GOTO(address, error_dialer); |
766 | 769 | ||
770 | if ((stat(address, &st) != 0) | ||
771 | #ifdef S_ISSOCK | ||
772 | || (!S_ISSOCK(st.st_mode)) | ||
773 | #endif | ||
774 | ) | ||
775 | { | ||
776 | DBG("%s is not a socket", address); | ||
777 | goto error_dialer; | ||
778 | } | ||
779 | |||
767 | svr->dialer.dialer = efl_add(EFL_NET_DIALER_UNIX_CLASS, ecore_main_loop_get()); | 780 | svr->dialer.dialer = efl_add(EFL_NET_DIALER_UNIX_CLASS, ecore_main_loop_get()); |
768 | EINA_SAFETY_ON_NULL_GOTO(svr->dialer.dialer, error_dialer); | 781 | EINA_SAFETY_ON_NULL_GOTO(svr->dialer.dialer, error_dialer); |
769 | } | 782 | } |