efl_net_dialer_unix: use compositor socket instead of socket4 for connection
authorYeongjong Lee <yj34.lee@samsung.com>
Fri, 13 Mar 2020 04:28:29 +0000 (13:28 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Tue, 5 May 2020 23:37:47 +0000 (08:37 +0900)
since 80c7e8093f8c097b2999e07aa9934dd67509c8a1, fd is -1 when
efl_net_connect_async_with_fd_new is called. this patch change it to use
socket from E compositor because of tizen policy.
(See commit ebfaab3e05f755428aaee021253c8e5255fd388f)

Also, This reverts commit 80c7e8093f8c097b2999e07aa9934dd67509c8a1.

@tizen_fix

Change-Id: Ie824d15ace426f91baa2a9ac1547481f000c5804

src/lib/ecore_con/efl_net_dialer_unix.c
src/lib/ecore_con/efl_net_dialer_unix.eo
src/lib/ecore_ipc/ecore_ipc.c

index b56d7e7..b2ddd03 100644 (file)
@@ -30,6 +30,9 @@ typedef struct _Efl_Net_Dialer_Unix_Data
    Eina_Stringshare *address_dial;
    Eina_Bool connected;
    double timeout_dial;
+   //TIZEN_ONLT(20200313): use compositor socket instead of socket4 for connection
+   int compositor_socket;
+   //
 } Efl_Net_Dialer_Unix_Data;
 
 EOLIAN static Eo*
@@ -38,6 +41,10 @@ _efl_net_dialer_unix_efl_object_constructor(Eo *o, Efl_Net_Dialer_Unix_Data *pd
    o = efl_constructor(efl_super(o, MY_CLASS));
    if (!o) return NULL;
 
+   //TIZEN_ONLT(20200313): use compositor socket instead of socket4 for connection
+   efl_net_dialer_unix_compositor_socket_set(o, -1);
+   //
+
    efl_net_dialer_timeout_dial_set(o, 30.0);
    return o;
 }
@@ -144,9 +151,7 @@ _efl_net_dialer_unix_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Unix_Data *pd, co
    EINA_SAFETY_ON_TRUE_RETURN_VAL(address[0] == '\0', EINVAL);
    EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_net_dialer_connected_get(o), EISCONN);
    EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(o), EBADF);
-   // TIZEN ONLY (20180125): smack issue: use fd from E
-   //EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_loop_fd_get(o) >= 0, EALREADY);
-   //
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_loop_fd_get(o) >= 0, EALREADY);
 
    if (pd->connect.thread)
      {
@@ -183,7 +188,7 @@ _efl_net_dialer_unix_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Unix_Data *pd, co
    pd->connect.thread = efl_net_connect_async_with_fd_new((const struct sockaddr *)&addr, addrlen, SOCK_STREAM, 0,
                                                   efl_io_closer_close_on_exec_get(o),
                                                   _efl_net_dialer_unix_connected,
-                                                  efl_loop_fd_get(o), o);
+                                                  pd->compositor_socket, o);
    //
    EINA_SAFETY_ON_NULL_RETURN_VAL(pd->connect.thread, EINVAL);
 
@@ -244,4 +249,12 @@ _efl_net_dialer_unix_efl_io_closer_close(Eo *o, Efl_Net_Dialer_Unix_Data *pd EIN
    return efl_io_closer_close(efl_super(o, MY_CLASS));
 }
 
+//TIZEN_ONLT(20200313): use compositor socket instead of socket4 for connection
+EOLIAN static void
+_efl_net_dialer_unix_compositor_socket_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Unix_Data *pd, int socket)
+{
+   pd->compositor_socket = socket;
+}
+//
+
 #include "efl_net_dialer_unix.eo.c"
index a9a7693..e98dfbd 100644 (file)
@@ -8,6 +8,24 @@ class @beta Efl.Net.Dialer_Unix extends Efl.Net.Socket_Unix implements Efl.Net.D
       implemented.
     ]]
 
+    //TIZEN_ONLY(20200313): use compositor socket instead of socket4 for connection
+    methods {
+       @property compositor_socket {
+          [[In Tizen, the security does not allow 1 application to create
+            socket and other applications to connect to that socket.
+            All sockets should be created by system daemon or service.
+
+            Therefore, we request the E compositor to create sockets for us.
+            This should be set before @Efl.Net.Dialer.dial.
+          ]]
+          set { }
+          values {
+             socket: int; [[Socket from E compositor.]]
+          }
+       }
+    }
+    //
+
     implements {
         Efl.Object.constructor;
         Efl.Object.invalidate;
index f756693..f003b7e 100644 (file)
@@ -712,6 +712,9 @@ ecore_ipc_server_with_fd_connect(Ecore_Ipc_Type type, char *name, int port, int
           }
 
         svr->dialer.dialer = efl_add(EFL_NET_DIALER_UNIX_CLASS, efl_main_loop_get());
+        //TIZEN_ONLY(20200313): use compositor socket instead of socket4 for connection
+        efl_net_dialer_unix_compositor_socket_set(svr->dialer.dialer, fd);
+        //
         EINA_SAFETY_ON_NULL_GOTO(svr->dialer.dialer, error_dialer);
      }
    else if ((type & ECORE_IPC_TYPE) == ECORE_IPC_LOCAL_SYSTEM)
@@ -720,6 +723,9 @@ ecore_ipc_server_with_fd_connect(Ecore_Ipc_Type type, char *name, int port, int
         EINA_SAFETY_ON_NULL_GOTO(address, error_dialer);
 
         svr->dialer.dialer = efl_add(EFL_NET_DIALER_UNIX_CLASS, efl_main_loop_get());
+        //TIZEN_ONLY(20200313): use compositor socket instead of socket4 for connection
+        efl_net_dialer_unix_compositor_socket_set(svr->dialer.dialer, fd);
+        //
         EINA_SAFETY_ON_NULL_GOTO(svr->dialer.dialer, error_dialer);
      }
 #endif /* EFL_NET_DIALER_UNIX_CLASS */