From 33bf686c8b80159c3ce43fdfc9b514df6c992512 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Tue, 22 Dec 2015 17:30:37 +0900 Subject: [PATCH] Get socket fd through AUL - Direct fd passing can be a security hole Change-Id: I2bc507bdd4cf5dfe43e5e48a91376bf0bf784d9b Signed-off-by: Hyunho Kang --- src/message-port.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/message-port.c b/src/message-port.c index a5a55c7..51315c3 100755 --- a/src/message-port.c +++ b/src/message-port.c @@ -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; + } } } -- 2.7.4