Get socket fd through AUL 61/55161/4 accepted/tizen/mobile/20151230.223313 accepted/tizen/tv/20151230.223328 accepted/tizen/wearable/20151230.223339 submit/tizen/20151230.015514 submit/tizen/20151230.054910
authorHyunho Kang <hhstark.kang@samsung.com>
Tue, 22 Dec 2015 08:30:37 +0000 (17:30 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Tue, 29 Dec 2015 07:57:13 +0000 (16:57 +0900)
- Direct fd passing can be a security hole

Change-Id: I2bc507bdd4cf5dfe43e5e48a91376bf0bf784d9b
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/message-port.c

index a5a55c7..51315c3 100755 (executable)
@@ -1215,23 +1215,23 @@ static int __message_port_send_message(const char *remote_appid, const char *rem
 
                if (strcmp(remote_appid, __app_id) != 0) { /* self send */
 
-                       if (socketpair(AF_UNIX, SOCK_DGRAM, 0, port_info->sock_pair) != 0) {
+                       /*  if message-port fail to get socket pair, communicate using GDBus */
+                       if (aul_request_message_port_socket_pair(port_info->sock_pair) != AUL_R_OK) {
                                _LOGE("error create socket pair");
-                               ret = MESSAGEPORT_ERROR_IO_ERROR;
-                               goto out;
-                       }
+                       } else {
 
-                       _LOGI("sock pair : %d, %d", port_info->sock_pair[0], port_info->sock_pair[1]);
+                               _LOGI("sock pair : %d, %d", port_info->sock_pair[0], port_info->sock_pair[1]);
 
-                       fd_list = g_unix_fd_list_new();
-                       g_unix_fd_list_append(fd_list, port_info->sock_pair[1], &err);
-                       g_unix_fd_list_append(fd_list, port_info->sock_pair[0], &err);
+                               fd_list = g_unix_fd_list_new();
+                               g_unix_fd_list_append(fd_list, port_info->sock_pair[1], &err);
+                               g_unix_fd_list_append(fd_list, port_info->sock_pair[0], &err);
 
-                       if (err != NULL) {
-                               _LOGE("g_unix_fd_list_append [%s]", error->message);
-                               ret = MESSAGEPORT_ERROR_IO_ERROR;
-                               g_error_free(err);
-                               goto out;
+                               if (err != NULL) {
+                                       _LOGE("g_unix_fd_list_append [%s]", error->message);
+                                       ret = MESSAGEPORT_ERROR_IO_ERROR;
+                                       g_error_free(err);
+                                       goto out;
+                               }
                        }
 
                }